/vagrant-ansible-kubernetes

Ansible scripts to be used with Vagrant/Terraform to create Kubernetes clusters

Primary LanguageShellGNU Lesser General Public License v3.0LGPL-3.0

ansible-kubernetes

Ansible scripts to be used with Vagrant/Terraform to create Kubernetes clusters.

Initial version: Vagrant+Ansible+VirtualBox

The initial version is essentially what is proposed in this blog post from March 2019: "Kubernetes Setup Using Ansible and Vagrant" on the Kubernetes Blog, by Naresh L J (Infosys).

It has been slightly modified and tested using:

Ansible 2.5.1
Vagrant 2.2.9
VirtualBox-5.2.42_Ubuntur137960

on Ubuntu 18.04 LTS.

Installing Kubernetes

Assuming you already have Vagrant, Ansible and VirtualBox (or other Hypervisor with suitable Vagrant driver) installed, install Kubernetes across the cluster of VMs using the vagrant up command.

Once successfully complete check that the cluster is functioning by:

Check all nodes are created/running

vagrant status

which should show something like

Current machine states:

k8s-master                running (virtualbox)
node-1                    running (virtualbox)
node-2                    running (virtualbox)

Log into the master node

vagrant ssh k8s-master

list nodes of the cluster

once logged in:

vagrant@k8s-master:~$ kubectl get nodes

should show something like

NAME         STATUS   ROLES    AGE     VERSION
k8s-master   Ready    master   8h      v1.14.1
node-1       Ready    <none>   6h6m    v1.14.1
node-2       Ready    <none>   5h58m   v1.14.1

To Add to this version

  • Recuperate kubeconfig info locally
  • Test kubecongfig locally
  • Create some pods, services and test access
  • Use latest Ubuntu LTS (currently 18.04.x)

Future versions

The intention is to keep this repo updated with best practices and ideas from other implementations, for example:

and using other tools:

  • rpm(/yum/dnf)-based distributions
  • rancher/k3s
  • etcdadm, nodeadm, ...