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

Note

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

kubesphere-login

Appendix

Image list of KubeSphere 3.4

  1. ##k8s-images
  2. kubesphere/kube-apiserver:v1.23.10
  3. kubesphere/kube-controller-manager:v1.23.10
  4. kubesphere/kube-proxy:v1.23.10
  5. kubesphere/kube-scheduler:v1.23.10
  6. kubesphere/kube-apiserver:v1.24.3
  7. kubesphere/kube-controller-manager:v1.24.3
  8. kubesphere/kube-proxy:v1.24.3
  9. kubesphere/kube-scheduler:v1.24.3
  10. kubesphere/kube-apiserver:v1.22.12
  11. kubesphere/kube-controller-manager:v1.22.12
  12. kubesphere/kube-proxy:v1.22.12
  13. kubesphere/kube-scheduler:v1.22.12
  14. kubesphere/kube-apiserver:v1.21.14
  15. kubesphere/kube-controller-manager:v1.21.14
  16. kubesphere/kube-proxy:v1.21.14
  17. kubesphere/kube-scheduler:v1.21.14
  18. kubesphere/pause:3.7
  19. kubesphere/pause:3.6
  20. kubesphere/pause:3.5
  21. kubesphere/pause:3.4.1
  22. coredns/coredns:1.8.0
  23. coredns/coredns:1.8.6
  24. calico/cni:v3.23.2
  25. calico/kube-controllers:v3.23.2
  26. calico/node:v3.23.2
  27. calico/pod2daemon-flexvol:v3.23.2
  28. calico/typha:v3.23.2
  29. kubesphere/flannel:v0.12.0
  30. openebs/provisioner-localpv:2.10.1
  31. openebs/linux-utils:2.10.0
  32. library/haproxy:2.3
  33. kubesphere/nfs-subdir-external-provisioner:v4.0.2
  34. kubesphere/k8s-dns-node-cache:1.15.12
  35. ##kubesphere-images
  36. kubesphere/ks-installer:v3.4.0
  37. kubesphere/ks-apiserver:v3.4.0
  38. kubesphere/ks-console:v3.4.0
  39. kubesphere/ks-controller-manager:v3.4.0
  40. kubesphere/ks-upgrade:v3.4.0
  41. kubesphere/kubectl:v1.22.0
  42. kubesphere/kubectl:v1.21.0
  43. kubesphere/kubectl:v1.20.0
  44. kubesphere/kubefed:v0.8.1
  45. kubesphere/tower:v0.2.0
  46. minio/minio:RELEASE.2019-08-07T01-59-21Z
  47. minio/mc:RELEASE.2019-08-07T23-14-43Z
  48. csiplugin/snapshot-controller:v4.0.0
  49. kubesphere/nginx-ingress-controller:v1.1.0
  50. mirrorgooglecontainers/defaultbackend-amd64:1.4
  51. kubesphere/metrics-server:v0.4.2
  52. redis:5.0.14-alpine
  53. haproxy:2.0.25-alpine
  54. alpine:3.14
  55. osixia/openldap:1.3.0
  56. kubesphere/netshoot:v1.0
  57. ##kubeedge-images
  58. kubeedge/cloudcore:v1.9.2
  59. kubeedge/iptables-manager:v1.9.2
  60. kubesphere/edgeservice:v0.2.0
  61. ##gatekeeper-images
  62. openpolicyagent/gatekeeper:v3.5.2
  63. ##openpitrix-images
  64. kubesphere/openpitrix-jobs:v3.4.0
  65. ##kubesphere-devops-images
  66. kubesphere/devops-apiserver:ks-v3.4.0
  67. kubesphere/devops-controller:ks-v3.4.0
  68. kubesphere/devops-tools:ks-v3.4.0
  69. kubesphere/ks-jenkins:v3.4.0-2.319.1
  70. jenkins/inbound-agent:4.10-2
  71. kubesphere/builder-base:v3.2.2
  72. kubesphere/builder-nodejs:v3.2.0
  73. kubesphere/builder-maven:v3.2.0
  74. kubesphere/builder-maven:v3.2.1-jdk11
  75. kubesphere/builder-python:v3.2.0
  76. kubesphere/builder-go:v3.2.0
  77. kubesphere/builder-go:v3.2.2-1.16
  78. kubesphere/builder-go:v3.2.2-1.17
  79. kubesphere/builder-go:v3.2.2-1.18
  80. kubesphere/builder-base:v3.2.2-podman
  81. kubesphere/builder-nodejs:v3.2.0-podman
  82. kubesphere/builder-maven:v3.2.0-podman
  83. kubesphere/builder-maven:v3.2.1-jdk11-podman
  84. kubesphere/builder-python:v3.2.0-podman
  85. kubesphere/builder-go:v3.2.0-podman
  86. kubesphere/builder-go:v3.2.2-1.16-podman
  87. kubesphere/builder-go:v3.2.2-1.17-podman
  88. kubesphere/builder-go:v3.2.2-1.18-podman
  89. kubesphere/s2ioperator:v3.2.1
  90. kubesphere/s2irun:v3.2.0
  91. kubesphere/s2i-binary:v3.2.0
  92. kubesphere/tomcat85-java11-centos7:v3.2.0
  93. kubesphere/tomcat85-java11-runtime:v3.2.0
  94. kubesphere/tomcat85-java8-centos7:v3.2.0
  95. kubesphere/tomcat85-java8-runtime:v3.2.0
  96. kubesphere/java-11-centos7:v3.2.0
  97. kubesphere/java-8-centos7:v3.2.0
  98. kubesphere/java-8-runtime:v3.2.0
  99. kubesphere/java-11-runtime:v3.2.0
  100. kubesphere/nodejs-8-centos7:v3.2.0
  101. kubesphere/nodejs-6-centos7:v3.2.0
  102. kubesphere/nodejs-4-centos7:v3.2.0
  103. kubesphere/python-36-centos7:v3.2.0
  104. kubesphere/python-35-centos7:v3.2.0
  105. kubesphere/python-34-centos7:v3.2.0
  106. kubesphere/python-27-centos7:v3.2.0
  107. quay.io/argoproj/argocd:v2.3.3
  108. quay.io/argoproj/argocd-applicationset:v0.4.1
  109. ghcr.io/dexidp/dex:v2.30.2
  110. redis:6.2.6-alpine
  111. ##kubesphere-monitoring-images
  112. jimmidyson/configmap-reload:v0.5.0
  113. prom/prometheus:v2.34.0
  114. kubesphere/prometheus-config-reloader:v0.55.1
  115. kubesphere/prometheus-operator:v0.55.1
  116. kubesphere/kube-rbac-proxy:v0.11.0
  117. kubesphere/kube-state-metrics:v2.5.0
  118. prom/node-exporter:v1.3.1
  119. prom/alertmanager:v0.23.0
  120. thanosio/thanos:v0.25.2
  121. grafana/grafana:8.3.3
  122. kubesphere/kube-rbac-proxy:v0.8.0
  123. kubesphere/notification-manager-operator:v1.4.0
  124. kubesphere/notification-manager:v1.4.0
  125. kubesphere/notification-tenant-sidecar:v3.2.0
  126. ##kubesphere-logging-images
  127. kubesphere/elasticsearch-curator:v5.7.6
  128. kubesphere/elasticsearch-oss:6.8.22
  129. kubesphere/fluentbit-operator:v0.13.0
  130. docker:19.03
  131. kubesphere/fluent-bit:v1.8.11
  132. kubesphere/log-sidecar-injector:1.1
  133. elastic/filebeat:6.7.0
  134. kubesphere/kube-events-operator:v0.4.0
  135. kubesphere/kube-events-exporter:v0.4.0
  136. kubesphere/kube-events-ruler:v0.4.0
  137. kubesphere/kube-auditing-operator:v0.2.0
  138. kubesphere/kube-auditing-webhook:v0.2.0
  139. ##istio-images
  140. istio/pilot:1.11.1
  141. istio/proxyv2:1.11.1
  142. jaegertracing/jaeger-operator:1.27
  143. jaegertracing/jaeger-agent:1.27
  144. jaegertracing/jaeger-collector:1.27
  145. jaegertracing/jaeger-query:1.27
  146. jaegertracing/jaeger-es-index-cleaner:1.27
  147. kubesphere/kiali-operator:v1.38.1
  148. kubesphere/kiali:v1.38
  149. ##example-images
  150. busybox:1.31.1
  151. nginx:1.14-alpine
  152. joosthofman/wget:1.0
  153. nginxdemos/hello:plain-text
  154. wordpress:4.8-apache
  155. mirrorgooglecontainers/hpa-example:latest
  156. fluent/fluentd:v1.4.2-2.0
  157. perl:latest
  158. kubesphere/examples-bookinfo-productpage-v1:1.16.2
  159. kubesphere/examples-bookinfo-reviews-v1:1.16.2
  160. kubesphere/examples-bookinfo-reviews-v2:1.16.2
  161. kubesphere/examples-bookinfo-details-v1:1.16.2
  162. kubesphere/examples-bookinfo-ratings-v1:1.16.3
  163. ##weave-scope-images
  164. weaveworks/scope:1.13.0

Feedback

Was this page Helpful?

Yes No