Ansible scripts to be used with Vagrant/Terraform to create Kubernetes clusters.
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.
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:
vagrant status
which should show something like
Current machine states:
k8s-master running (virtualbox)
node-1 running (virtualbox)
node-2 running (virtualbox)
vagrant ssh k8s-master
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
- Recuperate kubeconfig info locally
- Test kubecongfig locally
- Create some pods, services and test access
- Use latest Ubuntu LTS (currently 18.04.x)
The intention is to keep this repo updated with best practices and ideas from other implementations, for example:
- https://github.com/kairen/kubeadm-ansible
- https://github.com/alisonbuss/cluster-kubernetes-ansible-vagrant
- http://michele.sciabarra.com/2018/02/12/devops/Kubernetes-with-KubeAdm-Ansible-Vagrant/
- https://github.com/jeremievallee/kubernetes-vagrant-ansible
and using other tools:
- rpm(/yum/dnf)-based distributions
- rancher/k3s
- etcdadm, nodeadm, ...