This guide provides instructions to set up a Kubernetes cluster using kubeadm
on Ubuntu 22.04 servers from Contabo VPS. The steps are based on a DigitalOcean tutorial but have been adapted for the updated environment and software versions. Additional inspiration and guidance were provided by the kubernetes-playbooks repository by Torgeir L. Hatlevik.
- Three Contabo VPS servers running Ubuntu 22.04.
- SSH access to each server with
root
privileges. - Basic knowledge of Ansible for automating the setup process.
Prepare your hosts
file to list the master and worker nodes:
[masters]
master ansible_host=<MASTER_IP> ansible_user=root
[workers]
worker1 ansible_host=<WORKER1_IP> ansible_user=root
worker2 ansible_host=<WORKER2_IP> ansible_user=root
Create a user ubuntu
and configure passwordless sudo access. The playbook is defined in initial.yml
.
Run the playbook:
ansible-playbook -i hosts initial.yml
Install necessary dependencies and disable swap. The playbook is defined in kube-dependencies.yml
.
Run the playbook:
ansible-playbook -i hosts kube-dependencies.yml
Initialize the master node. The playbook is defined in master.yml
.
Run the playbook:
ansible-playbook -i hosts master.yml
Join worker nodes to the cluster. The playbook is defined in worker.yml
.
Run the playbook:
ansible-playbook -i hosts worker.yml
To verify the cluster setup, SSH into the master node and run:
kubectl get nodes
You should see a list of your master and worker nodes in the Ready
state.
This setup guide was inspired by:
- The DigitalOcean tutorial
- The kubernetes-playbooks repository by Torgeir L. Hatlevik, which provided invaluable guidance, especially regarding Kubernetes dependencies and APT key setup.