This example demonstrates the setup of a single-master, multi-node Kubernetes cluster, running locally in three VMs. You can run the Ansible playbook against any three servers, but this example includes a Vagrantfile, which allows Vagrant to automatically build three VirtualBox VMs and then runs the playbook agains them automatically.
Before building the cluster, you need to install the following:
Then, in this directory, run:
$ ansible-galaxy install -r requirements.yml
$ vagrant up
After a few minutes, the three VMs will be booted, and the Ansible playbook will have installed Kubernetes using the main.yml
playbook.
You can log into the master node with the command:
$ vagrant ssh kube1
From there, run sudo su
to switch to the root user, and then you can use kubectl
to manage the Kubernetes cluster.
You can run a playbook to run a test deployment and service in the cluster, and verify they are working correctly:
$ ansible-playbook -i inventory test-deployment.yml