使用 ks-installer 离线升级

ks-installer is recommended for users whose Kubernetes clusters were not set up via KubeSphere Installer, but hosted by cloud vendors. This tutorial is for upgrading KubeSphere only. Cluster operators are responsible for upgrading Kubernetes themselves beforehand.

Prerequisites

  • You need to have a KubeSphere cluster running version 2.1.1.

警告

If your KubeSphere version is v2.1.0 or earlier, please upgrade to v2.1.1 first.

  • Docker Registry

You need to have a harbor or other Docker registry.

提示

You can quick start yourself docker registry

警告

In v3.0.0, KubeSphere refactors many of its components such as Fluent Bit Operator and IAM. Make sure you back up any important components in case you heavily customized them but not from console.

Step 1: Prepare Installation Images

As you install KubeSphere in an air-gapped environment, you need to prepare an image package containing all the necessary images in advance.

  1. Download the image list file images-list.txt from a machine that has access to the Internet through the following command:

    1. curl -L -O https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/images-list.txt

    备注

    This file lists images under ##+modulename based on different modules. You can add your own images to this file following the same rule. To view the complete file, see Appendix.

  2. Download offline-installation-tool.sh.

    1. curl -L -O https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/offline-installation-tool.sh
  3. Make the .sh file executable.

    1. chmod +x offline-installation-tool.sh
  4. You can execute the command ./offline-installation-tool.sh -h to see how to use the script:

    1. root@master:/home/ubuntu# ./offline-installation-tool.sh -h
    2. Usage:
    3. ./offline-installation-tool.sh [-l IMAGES-LIST] [-d IMAGES-DIR] [-r PRIVATE-REGISTRY] [-v KUBERNETES-VERSION ]
    4. Description:
    5. -b : save kubernetes' binaries.
    6. -d IMAGES-DIR : the dir of files (tar.gz) which generated by `docker save`. default: ./kubesphere-images
    7. -l IMAGES-LIST : text file with list of images.
    8. -r PRIVATE-REGISTRY : target private registry:port.
    9. -s : save model will be applied. Pull the images in the IMAGES-LIST and save images as a tar.gz file.
    10. -v KUBERNETES-VERSION : download kubernetes' binaries. default: v1.17.9
    11. -h : usage message
  5. Pull images in offline-installation-tool.sh.

    1. ./offline-installation-tool.sh -s -l images-list.txt -d ./kubesphere-images

    备注

    You can choose to pull images as needed. For example, you can delete ##k8s-images and related images under it in images-list.text as you already have a Kubernetes cluster.

Step 2: Push Images to Private Registry

Transfer your packaged image file to your local machine and execute the following command to push it to the registry.

  1. ./offline-installation-tool.sh -l images-list.txt -d ./kubesphere-images -r dockerhub.kubekey.local

备注

The domain name is dockerhub.kubekey.local in the command. Make sure you use your own registry address.

Step 3: Download Deployment Files

Similar to installing KubeSphere on an existing Kubernetes cluster in an online environment, you also need to download cluster-configuration.yaml and kubesphere-installer.yaml first.

  1. Execute the following commands to download these two files and transfer them to your machine that serves as the taskbox for installation.

    1. curl -L -O https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/cluster-configuration.yaml
    2. curl -L -O https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/kubesphere-installer.yaml
  2. Edit cluster-configuration.yaml to add your private image registry. For example, dockerhub.kubekey.local is the registry address in this tutorial, then use it as the value of .spec.local_registry as below:

    1. spec:
    2. persistence:
    3. storageClass: ""
    4. authentication:
    5. jwtSecret: ""
    6. local_registry: dockerhub.kubekey.local # Add this line manually; make sure you use your own registry address.

    备注

    You can enable pluggable components in this YAML file to explore more features of KubeSphere. Refer to Enable Pluggle Components for more details.

  3. Save cluster-configuration.yaml after you finish editing. Replace ks-installer with your own registry address with the following command:

    1. sed -i "s#^\s*image: kubesphere.*/ks-installer:.*# image: dockerhub.kubekey.local/kubesphere/ks-installer:v3.0.0#" kubesphere-installer.yaml

    警告

    dockerhub.kubekey.local is the registry address in the command. Make sure you use your own registry address.

Step 4: Upgrade Kubesphere

Execute the following commands after you make sure that all steps above are completed.

  1. kubectl apply -f kubesphere-installer.yaml && kubectl apply -f cluster-configuration.yaml

Step 5: Verify Installation

When the installation finishes, you can see the content as follows:

  1. #####################################################
  2. ### Welcome to KubeSphere! ###
  3. #####################################################
  4. Console: http://192.168.0.2:30880
  5. Account: admin
  6. Password: P@88w0rd
  7. NOTES
  8. 1. After logging into the console, please check the
  9. monitoring status of service components in
  10. the "Cluster Management". If any service is not
  11. ready, please wait patiently until all components
  12. are ready.
  13. 2. Please modify the default password after login.
  14. #####################################################
  15. https://kubesphere.io 20xx-xx-xx xx:xx:xx
  16. #####################################################

Now, you will be able to access the web console of KubeSphere through http://{IP}:30880 with the default account and password admin/P@88w0rd.

备注

To access the console, make sure the port 30880 is opened in your security group.

kubesphere-login