Air-gapped Installation on Kubernetes

The air-gapped installation is almost the same as the online installation except that you must create a local registry to host Docker images. This tutorial demonstrates how to install KubeSphere on Kubernetes in an air-gapped environment.

Before you follow the steps below, read Prerequisites first.

Step 1: Prepare a Private Image Registry

You can use Harbor or any other private image registries. This tutorial uses Docker registry as an example with self-signed certificates (If you have your own private image registry, you can skip this step).

Use self-signed certificates

  1. Generate your own certificate by executing the following commands:

    1. mkdir -p certs
    1. openssl req \
    2. -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key \
    3. -x509 -days 36500 -out certs/domain.crt
  2. Make sure you specify a domain name in the field Common Name when you are generating your own certificate. For instance, the field is set to dockerhub.kubekey.local in this example.

    self-signed-cert

Start the Docker registry

Run the following commands to start the Docker registry:

  1. docker run -d \
  2. --restart=always \
  3. --name registry \
  4. -v "$(pwd)"/certs:/certs \
  5. -v /mnt/registry:/var/lib/registry \
  6. -e REGISTRY_HTTP_ADDR=0.0.0.0:443 \
  7. -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
  8. -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
  9. -p 443:443 \
  10. registry:2

Note

Docker uses /var/lib/docker as the default directory where all Docker related files, including images, are stored. It is recommended you add additional storage volumes with at least 100G mounted to /var/lib/docker and /mnt/registry respectively. See fdisk command for reference.

Configure the registry

  1. Add an entry to /etc/hosts to map the hostname (i.e. the registry domain name; in this case, it is dockerhub.kubekey.local) to the private IP address of your machine as below.

    1. # docker registry
    2. 192.168.0.2 dockerhub.kubekey.local
  2. Execute the following commands to copy the certificate to a specified directory and make Docker trust it.

    1. mkdir -p /etc/docker/certs.d/dockerhub.kubekey.local
    1. cp certs/domain.crt /etc/docker/certs.d/dockerhub.kubekey.local/ca.crt

    Note

    The path of the certificate is related to the domain name. When you copy the path, use your actual domain name if it is different from the one set above.

  3. To verify whether the private registry is effective, you can copy an image to your local machine first, and use docker push and docker pull to test it.

Step 2: 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.1.0/images-list.txt

    Note

    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.1.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. [email protected]:/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

    Note

    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 3: Push Images to Your 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

Note

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

Step 4: 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.1.0/cluster-configuration.yaml
    2. curl -L -O https://github.com/kubesphere/ks-installer/releases/download/v3.1.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.

    Note

    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

    Warning

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

Step 5: Start Installation

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

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

Step 6: 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: [email protected]
  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/[[email protected]](https://kubesphere.io/cdn-cgi/l/email-protection).

Note

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

kubesphere-login

Appendix

Image list of KubeSphere v3.1.0

  1. ##k8s-images
  2. kubesphere/kube-apiserver:v1.20.4
  3. kubesphere/kube-scheduler:v1.20.4
  4. kubesphere/kube-proxy:v1.20.4
  5. kubesphere/kube-controller-manager:v1.20.4
  6. kubesphere/kube-apiserver:v1.19.8
  7. kubesphere/kube-scheduler:v1.19.8
  8. kubesphere/kube-proxy:v1.19.8
  9. kubesphere/kube-controller-manager:v1.19.8
  10. kubesphere/kube-apiserver:v1.18.6
  11. kubesphere/kube-scheduler:v1.18.6
  12. kubesphere/kube-proxy:v1.18.6
  13. kubesphere/kube-controller-manager:v1.18.6
  14. kubesphere/kube-apiserver:v1.17.9
  15. kubesphere/kube-scheduler:v1.17.9
  16. kubesphere/kube-proxy:v1.17.9
  17. kubesphere/kube-controller-manager:v1.17.9
  18. kubesphere/pause:3.1
  19. kubesphere/pause:3.2
  20. kubesphere/etcd:v3.4.13
  21. calico/cni:v3.16.3
  22. calico/kube-controllers:v3.16.3
  23. calico/node:v3.16.3
  24. calico/pod2daemon-flexvol:v3.16.3
  25. coredns/coredns:1.6.9
  26. kubesphere/k8s-dns-node-cache:1.15.12
  27. openebs/provisioner-localpv:2.3.0
  28. openebs/linux-utils:2.3.0
  29. kubesphere/nfs-client-provisioner:v3.1.0-k8s1.11
  30. ##csi-images
  31. csiplugin/csi-neonsan:v1.2.0
  32. csiplugin/csi-neonsan-ubuntu:v1.2.0
  33. csiplugin/csi-neonsan-centos:v1.2.0
  34. csiplugin/csi-provisioner:v1.5.0
  35. csiplugin/csi-attacher:v2.1.1
  36. csiplugin/csi-resizer:v0.4.0
  37. csiplugin/csi-snapshotter:v2.0.1
  38. csiplugin/csi-node-driver-registrar:v1.2.0
  39. csiplugin/csi-qingcloud:v1.2.0
  40. ##kubesphere-images
  41. kubesphere/ks-apiserver:v3.1.0
  42. kubesphere/ks-console:v3.1.0
  43. kubesphere/ks-controller-manager:v3.1.0
  44. kubesphere/ks-installer:v3.1.0
  45. kubesphere/kubectl:v1.17.0
  46. kubesphere/kubectl:v1.18.0
  47. kubesphere/kubectl:v1.19.0
  48. kubesphere/kubectl:v1.20.0
  49. redis:5.0.5-alpine
  50. alpine:3.10.4
  51. haproxy:2.0.4
  52. nginx:1.14-alpine
  53. minio/minio:RELEASE.2019-08-07T01-59-21Z
  54. minio/mc:RELEASE.2019-08-07T23-14-43Z
  55. mirrorgooglecontainers/defaultbackend-amd64:1.4
  56. kubesphere/nginx-ingress-controller:v0.35.0
  57. osixia/openldap:1.3.0
  58. csiplugin/snapshot-controller:v2.0.1
  59. kubesphere/kubefed:v0.7.0
  60. kubesphere/tower:v0.2.0
  61. kubesphere/prometheus-config-reloader:v0.42.1
  62. kubesphere/prometheus-operator:v0.42.1
  63. prom/alertmanager:v0.21.0
  64. prom/prometheus:v2.26.0
  65. prom/node-exporter:v0.18.1
  66. kubesphere/ks-alerting-migration:v3.1.0
  67. jimmidyson/configmap-reload:v0.3.0
  68. kubesphere/notification-manager-operator:v1.0.0
  69. kubesphere/notification-manager:v1.0.0
  70. kubesphere/metrics-server:v0.4.2
  71. kubesphere/kube-rbac-proxy:v0.8.0
  72. kubesphere/kube-state-metrics:v1.9.7
  73. openebs/provisioner-localpv:2.3.0
  74. thanosio/thanos:v0.18.0
  75. grafana/grafana:7.4.3
  76. ##kubesphere-logging-images
  77. kubesphere/elasticsearch-oss:6.7.0-1
  78. kubesphere/elasticsearch-curator:v5.7.6
  79. kubesphere/fluentbit-operator:v0.5.0
  80. kubesphere/fluentbit-operator:migrator
  81. kubesphere/fluent-bit:v1.6.9
  82. elastic/filebeat:6.7.0
  83. kubesphere/kube-auditing-operator:v0.1.2
  84. kubesphere/kube-auditing-webhook:v0.1.2
  85. kubesphere/kube-events-exporter:v0.1.0
  86. kubesphere/kube-events-operator:v0.1.0
  87. kubesphere/kube-events-ruler:v0.2.0
  88. kubesphere/log-sidecar-injector:1.1
  89. docker:19.03
  90. ##istio-images
  91. istio/pilot:1.6.10
  92. istio/proxyv2:1.6.10
  93. jaegertracing/jaeger-agent:1.17
  94. jaegertracing/jaeger-collector:1.17
  95. jaegertracing/jaeger-es-index-cleaner:1.17
  96. jaegertracing/jaeger-operator:1.17.1
  97. jaegertracing/jaeger-query:1.17
  98. kubesphere/kiali:v1.26.1
  99. kubesphere/kiali-operator:v1.26.1
  100. ##kubesphere-devops-images
  101. kubesphere/ks-jenkins:2.249.1
  102. jenkins/jnlp-slave:3.27-1
  103. kubesphere/s2ioperator:v3.1.0
  104. kubesphere/s2irun:v2.1.1
  105. kubesphere/builder-base:v2.1.0
  106. kubesphere/builder-nodejs:v2.1.0
  107. kubesphere/builder-maven:v2.1.0
  108. kubesphere/builder-go:v2.1.0
  109. kubesphere/s2i-binary:v2.1.0
  110. kubesphere/tomcat85-java11-centos7:v2.1.0
  111. kubesphere/tomcat85-java11-runtime:v2.1.0
  112. kubesphere/tomcat85-java8-centos7:v2.1.0
  113. kubesphere/tomcat85-java8-runtime:v2.1.0
  114. kubesphere/java-11-centos7:v2.1.0
  115. kubesphere/java-8-centos7:v2.1.0
  116. kubesphere/java-8-runtime:v2.1.0
  117. kubesphere/java-11-runtime:v2.1.0
  118. kubesphere/nodejs-8-centos7:v2.1.0
  119. kubesphere/nodejs-6-centos7:v2.1.0
  120. kubesphere/nodejs-4-centos7:v2.1.0
  121. kubesphere/python-36-centos7:v2.1.0
  122. kubesphere/python-35-centos7:v2.1.0
  123. kubesphere/python-34-centos7:v2.1.0
  124. kubesphere/python-27-centos7:v2.1.0
  125. kubesphere/notification:flyway_v2.1.2
  126. kubesphere/notification:v2.1.2
  127. ##openpitrix-images
  128. kubesphere/openpitrix-jobs:v3.1.0
  129. ##weave-scope-images
  130. weaveworks/scope:1.13.0
  131. ##kubeedge-images
  132. kubeedge/cloudcore:v1.6.1
  133. kubesphere/edge-watcher:v0.1.0
  134. kubesphere/kube-rbac-proxy:v0.5.0
  135. kubesphere/edge-watcher-agent:v0.1.0
  136. ##example-images-images
  137. kubesphere/examples-bookinfo-productpage-v1:1.16.2
  138. kubesphere/examples-bookinfo-reviews-v1:1.16.2
  139. kubesphere/examples-bookinfo-reviews-v2:1.16.2
  140. kubesphere/examples-bookinfo-reviews-v3:1.16.2
  141. kubesphere/examples-bookinfo-details-v1:1.16.2
  142. kubesphere/examples-bookinfo-ratings-v1:1.16.3
  143. busybox:1.31.1
  144. joosthofman/wget:1.0
  145. kubesphere/netshoot:v1.0
  146. nginxdemos/hello:plain-text
  147. wordpress:4.8-apache
  148. mirrorgooglecontainers/hpa-example:latest
  149. java:openjdk-8-jre-alpine
  150. fluent/fluentd:v1.4.2-2.0
  151. perl:latest