Overview

Kubernetes is the next Evolution of Docker swarm, so in order to configure it, we have to firstly configure the Docker (just without the swarm this time) We will configure 3 servers again:

One master

Two Workers

Since I hate seeing only Debian based, I will do it in both: Ubuntu and Centos. Firstly we will be the Ubuntu. So let's get going:

Provision the VMs

You can return use the first section of the Vagrant advanced configurations or you can continue here, where we will do pretty much the same. I like wasting space :D

So let's get going with Vagrant again :)

Kubernetes Vagrantfile

As you can see, we are refering to two files here:

master-playbook.yml - Ansible Playbook for the Master node

node-playbook.yml - Ansible Playbook for the other Nodes.

Please create the following files as follows:

Configure the Master Playbook

Let's start building the master playbook:

Master Playbook File

Remove the swap

Please bare in mind that the kubelet won't install if the swap is enabled, so we have to add the following:

Remove the swap

Install Kubelet, kubeadm, kubectl

After that, we can add a task to install the: kubelet, kubeadm and kubectl using the below code.

Add Kubelet, kubeadm and kubectl

Initialize the Kubernetes

Finally, we can add the Tasks for the Initialization as follows:

Initialize Kubernetes

Configure Vagrant User for the Cluster

Since we are using vagrant, we can setup vagrant to access the Kubernetes Cluster using the following Task:

Configure Vagrant user

Configure the Network provider and policy engine

Configure network provider and policy Engine

Configure the Node Playbook

To configure the other nodes, create a node-playbook.yml with all the data above, except the initialization of the Kerberos. We will setup a join file which will be used in the playbook for the other nodes:

Generate Join Command

The generated, from Kubernetes, join command will be saved in file called: “join-command” which will be executed by the playbook:

Configure handlers

We have to also setup the handlers for checking the Docker daemon:

Configure handlers

Finally we can configure the node-playbook.yml

Node-playbook.yml config