A group of very simple Ansible playbooks to deploy the most basic Kubernetes Cluster
The main inspiration for these playbooks comes from this Digital Ocean article
Ultimately, the desire is to simplify the deployment of a basic Kubernetes cluster as much as possible without getting into any of the nasty details. The Kubernetes community have done fantastic work in the past few years to simplify kubeadm and other tools so if you want to pay them back, please consider becoming a K8s contributor
First make sure you align with the requirements set out below, then run the Ansible playbooks and finally test if the deployment was successful.
There are three requirements to get started, make sure:
- You have 4 nodes (Check out the Tested On Section to see tested OS')
- 1 Node for Ansible Controller
- 1 Node for Control Plane
- 2 Nodes for Worker
- You have Ansible installed on the Ansible Controller
Ubuntu 20.04:
sudo apt install ansible
- Your Ansible Controller has root ssh key access to the Control Plane and Worker Nodes
Ubuntu 20.04:
Create the SSH Pub/Priv Keys:
Upload the ssh public key to your Github account. Then import them as root on your other nodes:
# On Ansible Controller: ssh-keygen -t ed25519
# On Control Plane and Worker Nodes: sudo su # Enter user password at prompt ssh-import-id-gh <github-username>
Add details about all the nodes you will deploy K8s on in the hosts
file
To deploy the Playbook, simply run the following command:
ansible-playbook -i hosts k8s-deploy.yml
Assuming no errors came up, congratulations, you've deployed a Kubernetes Cluster!! 🎉 🎉
To make sure the Kubernetes cluster deployment was a success, log into the Control Plane node with the ubuntu
username:
ssh ubuntu@control_plane_ip
Then check if all the nodes are connected to the K8s cluster:
kubectl get nodes
If the following prints, you're in the clear and ready to deploy workloads:
control1 Ready control-plane,master 74m v1.22.4
worker1 Ready <none> 72m v1.22.4
worker2 Ready <none> 72m v1.22.4
If you like to add or change some of the code in this repo feel free to open a pull request and I will take look as soon as possible.
Operating System | Virtual Machine | Bare Metal | CPU Architecture | Kubernetes Version |
---|---|---|---|---|
Ubuntu 20.04 | Yes | No | x86 | 1.22 |
Ubuntu 22.04 | Yes | No | x86 | 1.24 |
- Test on Raspberry Pi
- Test on RHEL Distro
- Add Group Vars configuration file
- Test on Ubuntu Bare Metal
MIT