Versions Compared

Key

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

...

Before using KS, some preliminary steps are required. Obviously the first thing is to create on OpenStack the VMs (you can automate this with TerraForm), that will be part of the cluster, and a VM, which we will call ServerAnsible (henceforth SA) and that it will have Ansible installed on it, from which to implement it. Communication via SSH from SA to other machines must be allowed. For example, you can create a key pair with the ssh-keygen command, depositing the private part on the SA and the public part on the cluster VMs. It is advisable to perform at least one access test between the SA and the other VMs, both for a connection test and to automatically register the VMs in the $HOME/.ssh/known_hosts file.

...

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
# Run "python3 contrib/inventory_builder/inventory.py help" for more information (more details below)
$ 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 (this may take 15-20 minutes)
$ ansible-playbook -i inventory/mycluster/hosts.yaml --become --become-user=root cluster.yml

...