Create a Kubernetes cluster from scratch with multipass virtual machines and ansible.
To create the vms run the cluster-deploy
script in this way: ./cluster-deploy
This script will perform the below steps:
- Create and start 3 vms (with names
control-plane-node
,kube-node-1
,kube-node-2
) - Add the public key
./keys/key.pub
in each vm'sauthorized_keys
- Create the ansible
inventory
file by getting each vm's ip.
./bin/install-ansible-collections-and-roles
Installs ansible collections and roles../bin/ansible-playbook 00-prequirements.yml
Installs basic configuration requirements for each node../bin/ansible-playbook 01-crio.yml
Installs cri-o as container runtime./bin/ansible-playbook 02-kube-install.yml
Installs kubernetes deployment tools (kubeadm, kubelet, kubectl)../bin/ansible-playbook 03-kube-cluster.yml
Setups the kubernetes cluster and installs Calico networking.
You can access the cluster directly with kubectl
, the script took the .kube/config from control-plane-node
kubectl get nodes
You can access kubernetes cluster through control-plane-node
by opening a shell to it with multipass shell control-plane-node
.
multipass shell control-plane-node
kubectl get nodes
In this repo virtual machines are set with 3 GB RAM and 2 CPUs; you can modify those values in the cluster-deploy script.
The official documentation infact suggests:
2 GiB or more of RAM per machine--any less leaves little room for your apps. At least 2 CPUs on the machine that you use as a control-plane node.
If something went wrong during the cluster deployment you can get the following error:
HTTP Error 500: Internal Server Error
don't be discouraged it may be a momentaneous issue;
undeploy the cluster running the script
./cluster-destroy
Check if there are no virtual machines running
multipass list
Deploy again the cluster
./cluster-deploy