Skip to content

This a multi node cluster playground which offers a production-like environment using Vagrant and Ansible for provisioning the cluster on multiple providers such as VirtualBox, KVM/libvirt, and so on.

License

Notifications You must be signed in to change notification settings

ricardoamaro/multinode-kubernetes-cluster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi node Kubernetes Cluster

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.

./kubernetes-setup/Diagram.png

Requirements

Note that Docker might be supported in the future, depending on having a fully working image that can fit with the Ansible playbooks.

Quick reference

Using config.yaml external file

It is advisable to copy the file `config.sample` to `config.yaml` in order to set configuration.

Running kubectl

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

Notes

Installing libvirt plugin and running

On Ubuntu

# 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

On Centos/Redhat/FEdora

# 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

Default pool images

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

Running

Temporary uncomment the line `#provider = “libvirt”` in the Vagrantfile. Run `vagrant up` as normal.

About

This a multi node cluster playground which offers a production-like environment using Vagrant and Ansible for provisioning the cluster on multiple providers such as VirtualBox, KVM/libvirt, and so on.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published