You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
6.9 KiB

  1. # Offline environment
  2. In case your servers don't have access to the internet directly (for example
  3. when deploying on premises with security constraints), you need to get the
  4. following artifacts in advance from another environment where has access to the internet.
  5. * Some static files (zips and binaries)
  6. * OS packages (rpm/deb files)
  7. * Container images used by Kubespray. Exhaustive list depends on your setup
  8. * [Optional] Python packages used by Kubespray (only required if your OS doesn't provide all python packages/versions
  9. listed in `requirements.txt`)
  10. * [Optional] Helm chart files (only required if `helm_enabled=true`)
  11. Then you need to setup the following services on your offline environment:
  12. * an HTTP reverse proxy/cache/mirror to serve some static files (zips and binaries)
  13. * an internal Yum/Deb repository for OS packages
  14. * an internal container image registry that need to be populated with all container images used by Kubespray
  15. * [Optional] an internal PyPi server for python packages used by Kubespray
  16. * [Optional] an internal Helm registry for Helm chart files
  17. You can get artifact lists with [generate_list.sh](/contrib/offline/generate_list.sh) script.
  18. In addition, you can find some tools for offline deployment under [contrib/offline](/contrib/offline/README.md).
  19. ## Configure Inventory
  20. Once all artifacts are accessible from your internal network, **adjust** the following variables
  21. in [your inventory](/inventory/sample/group_vars/all/offline.yml) to match your environment:
  22. ```yaml
  23. # Registry overrides
  24. kube_image_repo: "{{ registry_host }}"
  25. gcr_image_repo: "{{ registry_host }}"
  26. docker_image_repo: "{{ registry_host }}"
  27. quay_image_repo: "{{ registry_host }}"
  28. kubeadm_download_url: "{{ files_repo }}/kubernetes/{{ kube_version }}/kubeadm"
  29. kubectl_download_url: "{{ files_repo }}/kubernetes/{{ kube_version }}/kubectl"
  30. kubelet_download_url: "{{ files_repo }}/kubernetes/{{ kube_version }}/kubelet"
  31. # etcd is optional if you **DON'T** use etcd_deployment=host
  32. etcd_download_url: "{{ files_repo }}/kubernetes/etcd/etcd-{{ etcd_version }}-linux-{{ image_arch }}.tar.gz"
  33. cni_download_url: "{{ files_repo }}/kubernetes/cni/cni-plugins-linux-{{ image_arch }}-{{ cni_version }}.tgz"
  34. crictl_download_url: "{{ files_repo }}/kubernetes/cri-tools/crictl-{{ crictl_version }}-{{ ansible_system | lower }}-{{ image_arch }}.tar.gz"
  35. # If using Calico
  36. calicoctl_download_url: "{{ files_repo }}/kubernetes/calico/{{ calico_ctl_version }}/calicoctl-linux-{{ image_arch }}"
  37. # If using Calico with kdd
  38. calico_crds_download_url: "{{ files_repo }}/kubernetes/calico/{{ calico_version }}.tar.gz"
  39. # Containerd
  40. containerd_download_url: "{{ files_repo }}/containerd-{{ containerd_version }}-linux-{{ image_arch }}.tar.gz"
  41. runc_download_url: "{{ files_repo }}/runc.{{ image_arch }}"
  42. nerdctl_download_url: "{{ files_repo }}/nerdctl-{{ nerdctl_version }}-{{ ansible_system | lower }}-{{ image_arch }}.tar.gz"
  43. # Insecure registries for containerd
  44. containerd_insecure_registries:
  45. "{{ registry_addr }}":"{{ registry_host }}"
  46. # CentOS/Redhat/AlmaLinux/Rocky Linux
  47. ## Docker / Containerd
  48. docker_rh_repo_base_url: "{{ yum_repo }}/docker-ce/$releasever/$basearch"
  49. docker_rh_repo_gpgkey: "{{ yum_repo }}/docker-ce/gpg"
  50. # Fedora
  51. ## Docker
  52. docker_fedora_repo_base_url: "{{ yum_repo }}/docker-ce/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}"
  53. docker_fedora_repo_gpgkey: "{{ yum_repo }}/docker-ce/gpg"
  54. ## Containerd
  55. containerd_fedora_repo_base_url: "{{ yum_repo }}/containerd"
  56. containerd_fedora_repo_gpgkey: "{{ yum_repo }}/docker-ce/gpg"
  57. # Debian
  58. ## Docker
  59. docker_debian_repo_base_url: "{{ debian_repo }}/docker-ce"
  60. docker_debian_repo_gpgkey: "{{ debian_repo }}/docker-ce/gpg"
  61. ## Containerd
  62. containerd_debian_repo_base_url: "{{ ubuntu_repo }}/containerd"
  63. containerd_debian_repo_gpgkey: "{{ ubuntu_repo }}/containerd/gpg"
  64. containerd_debian_repo_repokey: 'YOURREPOKEY'
  65. # Ubuntu
  66. ## Docker
  67. docker_ubuntu_repo_base_url: "{{ ubuntu_repo }}/docker-ce"
  68. docker_ubuntu_repo_gpgkey: "{{ ubuntu_repo }}/docker-ce/gpg"
  69. ## Containerd
  70. containerd_ubuntu_repo_base_url: "{{ ubuntu_repo }}/containerd"
  71. containerd_ubuntu_repo_gpgkey: "{{ ubuntu_repo }}/containerd/gpg"
  72. containerd_ubuntu_repo_repokey: 'YOURREPOKEY'
  73. ```
  74. For the OS specific settings, just define the one matching your OS.
  75. If you use the settings like the one above, you'll need to define in your inventory the following variables:
  76. * `registry_host`: Container image registry. If you _don't_ use the same repository path for the container images that
  77. the ones defined
  78. in [Download's role defaults](https://github.com/kubernetes-sigs/kubespray/blob/master/roles/download/defaults/main.yml)
  79. , you need to override the `*_image_repo` for these container images. If you want to make your life easier, use the
  80. same repository path, you won't have to override anything else.
  81. * `registry_addr`: Container image registry, but only have [domain or ip]:[port].
  82. * `files_repo`: HTTP webserver or reverse proxy that is able to serve the files listed above. Path is not important, you
  83. can store them anywhere as long as it's accessible by kubespray. It's recommended to use `*_version` in the path so
  84. that you don't need to modify this setting everytime kubespray upgrades one of these components.
  85. * `yum_repo`/`debian_repo`/`ubuntu_repo`: OS package repository depending on your OS, should point to your internal
  86. repository. Adjust the path accordingly.
  87. ## Install Kubespray Python Packages
  88. ### Recommended way: Kubespray Container Image
  89. The easiest way is to use [kubespray container image](https://quay.io/kubespray/kubespray) as all the required packages
  90. are baked in the image.
  91. Just copy the container image in your private container image registry and you are all set!
  92. ### Manual installation
  93. Look at the `requirements.txt` file and check if your OS provides all packages out-of-the-box (Using the OS package
  94. manager). For those missing, you need to either use a proxy that has Internet access (typically from a DMZ) or setup a
  95. PyPi server in your network that will host these packages.
  96. If you're using an HTTP(S) proxy to download your python packages:
  97. ```bash
  98. sudo pip install --proxy=https://[username:password@]proxyserver:port -r requirements.txt
  99. ```
  100. When using an internal PyPi server:
  101. ```bash
  102. # If you host all required packages
  103. pip install -i https://pypiserver/pypi -r requirements.txt
  104. # If you only need the ones missing from the OS package manager
  105. pip install -i https://pypiserver/pypi package_you_miss
  106. ```
  107. ## Run Kubespray as usual
  108. Once all artifacts are in place and your inventory properly set up, you can run kubespray with the
  109. regular `cluster.yaml` command:
  110. ```bash
  111. ansible-playbook -i inventory/my_airgap_cluster/hosts.yaml -b cluster.yml
  112. ```
  113. If you use [Kubespray Container Image](#recommended-way:-kubespray-container-image), you can mount your inventory inside
  114. the container:
  115. ```bash
  116. docker run --rm -it -v path_to_inventory/my_airgap_cluster:inventory/my_airgap_cluster myprivateregisry.com/kubespray/kubespray:v2.14.0 ansible-playbook -i inventory/my_airgap_cluster/hosts.yaml -b cluster.yml
  117. ```