This a multi node cluster playground which offers a production-like environment using kubeadm, Vagrant and Ansible for provisioning the cluster on multiple providers such as VirtualBox and KVM/libvirt. By using Ansible as the infrastructure automation engine we can have playbooks written in yaml that offer inventory management the infrastructure-as-code way.
- Vagrant: https://www.vagrantup.com/downloads.html
- Ansible: https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html
- VirtualBox as the provider. https://www.virtualbox.org/wiki/Downloads
- kubectl installed locally, https://kubernetes.io/docs/tasks/tools/install-kubectl/
Note that Docker might be supported in the future, depending on having a fully working image that can fit with the Ansible playbooks.
It is advisable to copy the file `config.sample` to `config.yaml` in order to set configuration.
After pulling this repository run `vagrant up` on the base folder. When the cluster is up and running you can ssh and can use `kubectl` on the master:
$ vagrant ssh k8s-master $ kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-master Ready master 4m28s v1.19.0 node-1 Ready <none> 2m12s v1.19.0 node-2 NotReady <none> 1s v1.19.0
Or if you have `kubectl` installed locally, try:
$ kubectl --kubeconfig=.kube/config get nodes NAME STATUS ROLES AGE VERSION k8s-master Ready master 4m28s v1.19.0 node-1 Ready <none> 2m12s v1.19.0 node-2 NotReady <none> 1s v1.19.0
# Install deb # https://releases.hashicorp.com/vagrant/2.2.10/vagrant_2.2.10_x86_64.deb sudo apt-get install -y libvirt-dev make gcc ruby-dev qemu-kvm libvirt0 virt-manager libguestfs-tools vagrant plugin install vagrant-libvirt
# use the rpm from hashicorp yum install -y https://releases.hashicorp.com/vagrant/2.2.10/vagrant_2.2.10_x86_64.rpm yum install -y libvirt libvirt-devel make gcc rpm-build ruby-devel zlib-devel qemu-kvm vagrant plugin install vagrant-libvirt
Vagrant expects a storage pool named ‘default’. In case you don’t have it already, run the following:
mkdir -p /var/lib/libvirt/default virsh pool-define-as --name default --type dir --target /var/lib/libvirt/default virsh pool-autostart default virsh pool-start default
Temporary uncomment the line `#provider = “libvirt”` in the Vagrantfile. Run `vagrant up` as normal.