Ansible playbook for kubeadm-based Kubernetes cluster installation on Linux
This Ansible playbook automates the installation and configuration of a Kubernetes cluster on Linux, with a single control plane node and multiple worker nodes, using the most recent stable Kubernetes release.
We understand that there’s Kubespray, which is much more powerful and allows for a lot of customizations, but this playbook is lightweight and simple. It might be a good option for those looking to set up a quick and easy development and testing environment of Kubernetes on Linux.
Suitable Environment: Development & Testing
System Requirements: Minimum 2 GB RAM & 2 vCPU
Supported Platforms: Baremetal, Virtual Machines, Cloud Instances
- RedHat-based ( Fedora, RHEL, Rocky Linux, Almalinux, Oracle Linux )
- Debian-based ( Debian, Ubuntu )
- SUSE-based ( OpenSUSE, SLES )
- Please install Ansible on the machine where you plan to run the playbook if you haven’t done so already.
- Prepare the cluster nodes by installing any of the above mentioned supported Linux distributions, even with a minimal installation.
- Please ensure that you have DNS set up that resolves all the involved hosts, or update the host files on all hosts with the necessary entries for each involved host.
- Create a common Linux user on all cluster nodes, which will be used for the cluster installation.
- Enable passwordless SSH authentication from the Ansible host to all cluster nodes using the common user created earlier.
- Ensure the common user has passwordless sudo privileges on all cluster nodes.
The main playbook installs and configures the latest stable versions of the following required components.
- Container orchestrator: kubernetes
- Container runtime: containerd
- Low-level container runtime: runc ( dependency for containerd )
- CNI plugin: calico
- csi-driver-nfs
- csi-driver-smb
- MetalLB LoadBalancer
Step 1) Copy and execute the below command snippet to extract the tarball for the most recent stable release of this Ansible project.
curl -sSL https://github.com/Muthukumar-Subramaniam/install-k8s-on-linux/releases/latest/download/inst-k8s-ansible.tar.gz | tar -xzvf - && cd inst-k8s-ansible
- Only private IP addresses, as defined in RFC 1918 are allowed.
- The deployment is configured to accept CIDR prefixes exclusively within the /16 to /28 range.
- Ensure that the selected CIDR prefix does not conflict with any existing networks in your infrastructure.
- Choose a CIDR prefix that provides sufficient address space for your cluster.
./setup.py
./inst-k8s-ansible.yaml
Expected Outcome:
./optional-k8s-csi-nfs-driver.yaml
Expected Outcome:
./optional-k8s-csi-smb-driver.yaml
Expected Outcome:
Note: Please make sure to change the address pool range in the playbook as per your environment and requirement.
./optional-install-metallb.yaml
Expected Outcome:
That's all for now! Your trust and engagement means a lot, and we hope you find the playbook useful.
- This playbook is a useful resource for experimenting with Kubernetes and can be customized to meet your specific requirements.
- The playbook utilizes the GitHub API to fetch the current stable versions of all required software components.
- Compatible with a wide range of Linux distributions.
- Your feedback and contributions are invaluable to the success of this project.
- Please report any bugs, suggest new features, or contribute directly to the codebase.