Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Kubespray (henceforth KS) is a composition of Ansible playbooks, inventory, provisioning tools, and domain knowledge for generic OS/Kubernetes clusters configuration management tasks. Kubespray provides:

...

Now we are ready to clone the repository from GitHub to the SA

Code Block
languagebash
titleClone repo
collapsetrue
$ git clone https://github.com/kubernetes-sigs/kubespray.git
# After the download, enter the following folder
# (the location of the other files that will be presented in the guide are relative to it)
$ cd kubespray

...

Code Block
languagebash
titleDeploy cluster
collapsetrue
# Install dependencies (any missing packages will be reported)
$ sudo pip3 install -r requirements.txt
# Copy the folder, so that you always have a default from which to start over
$ cp -rfp inventory/sample inventory/mycluster
# Create an array with the IPs of the cluster VMs
$ declare -a IPS=(<IP_VM1> <IP_VM2> <IP_VM3>)
# Automatically generates the possible cluster structure
$ CONFIG_FILE=inventory/mycluster/hosts.yaml python3 contrib/inventory_builder/inventory.py ${IPS[@]}
# Review and change parameters
$ cat inventory/mycluster/group_vars/all/all.yml
$ cat inventory/mycluster/group_vars/k8s-cluster/k8s-cluster.yml
$ cat inventory/mycluster/group_vars/k8s-cluster/addons.yml
# Deploy Kubespray with Ansible Playbook
$ ansible-playbook -i inventory/mycluster/hosts.yaml  --become --become-user=root cluster.yml

Before launching KS, it is recommended that you take a look at the files mentioned above, which contain various parameters to customize the cluster. However, we will talk about these files in more detail in the next sub-chapter.

Info
titleInfo

Ansible uses existing privilege escalation systems to execute tasks with root privileges or with another user’s permissions. The become keyword leverages existing privilege escalation tools like sudo.