# Copy ``inventory/sample`` as ``inventory/mycluster`` cp -rfp inventory/sample inventory/online_env
# Update Ansible inventory file with inventory builder declare -a IPS=(online-env-ip) CONFIG_FILE=inventory/online_env/hosts.yaml python3 contrib/inventory_builder/inventory.py ${IPS[@]}
# Review and change parameters under ``inventory/mycluster/group_vars`` cat inventory/online_env/group_vars/all/all.yml # Update cat inventory/online_env/group_vars/k8s_cluster/k8s-cluster.yml
# Clean up old Kubernetes cluster with Ansible Playbook - run the playbook as root # The option `--become` is required, as for example cleaning up SSL keys in /etc/, # uninstalling old packages and interacting with various systemd daemons. # Without --become the playbook will fail to run! # And be mind it will remove the current kubernetes cluster (if it's running)! ansible-playbook -i inventory/online_env/hosts.yaml --become --user={online_env_username} --become-user=root --ask-become-pass reset.yml
# Deploy Kubespray with Ansible Playbook - run the playbook as root # The option `--become` is required, as for example writing SSL keys in /etc/, # installing packages and interacting with various systemd daemons. # Without --become the playbook will fail to run! # Add--user={username} & --ask-become-pass ansible-playbook -i inventory/online_env/hosts.yaml --become --user={online_env_username} --become-user=root --ask-become-pass cluster.yml
Error
Or add Add–user={username} & –ask-become-pass to reset and cluster
fatal: [node1]: FAILED! => {“attempts”: 4, “censored”: “the output has been hidden due to the fact that ‘no_log: true’ was specified for this result”, “changed”: false} Run: vi inventory/{yourcluster}/group_vars/all/mirror.yml, add mirror
Test
Run:sudo kubectl get pods -A
On online env
Clone Kubespray-offline on online-env
Note: You must execute this process on the same OS of k8s target nodes.
Before download offline files, check and edit configurations in kubespray-offlineconfig.sh. If you don’t have container runtime (docker or containerd), install it first.
To use Docker CE
run install-docker.sh to install Docker CE.
To use containerd
run./install-containerd.sh to install containerd and nerdctl.
set docker environment variable to /usr/local/bin/nerdctl in config.sh. Then, download all files
Create and place offline.yml file to your group_vars/all/offline.yml of your inventory directory. You need to change YOUR_HOST with your registry/nginx host IP.
runc_donwload_url differ from kubespray official document, and must include runc_version.
The insecure registries configurations of containerd were changed from kubespray 2.23.0. You need to set containerd_registries_mirrors instead of containerd_insecure_registries.
Error
Install requirement.txt error You can download whl and install offline
Deploy offline repo configurations
Deploy offline repo configurations which use your yum_repo/ubuntu_repo to all target nodes using ansible. First, copy offline setup playbook to kubespray directory.
1
cp -r ${outputs_dir}/playbook ${kubespray_dir}
Then execute offline-repo.yml playbook.
1 2
cd ${kubespray_dir} ansible-playbook -i ${your_inventory_file} offline-repo.yml
Run kubespray
Run kubespray ansible playbook.
1 2
# Example ansible-playbook -i inventory/mycluster/hosts.yaml --become --become-user=root cluster.yml