Skip to content

Ansible playbook for a kubeadm-based Kubernetes cluster installation on Linux (Red Hat, Debian, and SUSE-based distributions) with a single control plane node and multiple worker nodes for development and testing purposes.

License

Notifications You must be signed in to change notification settings

Muthukumar-Subramaniam/install-k8s-on-linux

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

Supported Linux distributions:

  • RedHat-based ( Fedora, RHEL, Rocky Linux, Almalinux, Oracle Linux )
  • Debian-based ( Debian, Ubuntu )
  • SUSE-based ( OpenSUSE, SLES )

Prerequisites:

  • 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.

Optional playbooks are available to install the following components once the cluster is ready.


Step-by-Step Workflow:

Step 1) Copy and execute the below command snippet to extract the tarball for the most recent stable release of this Ansible project.

stable release

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

Step 2) Update the host-control-plane file with the necessary hostname.

Screenshot-host-control-plane-file

Step 3) Update the host-workers file with the necessary hostnames.

Screenshot-host-workers-file

Step 4) Update the pod-network-cidr file with the desired pod network CIDR.

Screenshot-pod-network-cidr-file
  • 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.

Step 5) Run the setup.py script to prepare the environment for the Ansible playbook.

./setup.py
Screenshot-setup-script-run

Step 6) Run the playbook if the setup.py script completes successfully.

./inst-k8s-ansible.yaml

Expected Outcome:

Screenshot-end-output-of-playbook-run

Great work! Your cluster is now ready to use.

Optional Step 1) To install CSI NFS Driver for the kubernetes cluster if required.

./optional-k8s-csi-nfs-driver.yaml

Expected Outcome:

Screenshot-csi-driver-nfs

Optional Step 2) To install CSI SMB Driver for the kubernetes cluster if required.

./optional-k8s-csi-smb-driver.yaml

Expected Outcome:

Screenshot-csi-driver-smb

Optional Step 3) To install MetalLB loadbalancer for the kubernetes cluster if required.

Note: Please make sure to change the address pool range in the playbook as per your environment and requirement.

Screenshot-metallb-ip-pool
./optional-install-metallb.yaml

Expected Outcome:

Screenshot-metallb

That's all for now! Your trust and engagement means a lot, and we hope you find the playbook useful.

Kindly note:

  • 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.

Have lots of fun!

About

Ansible playbook for a kubeadm-based Kubernetes cluster installation on Linux (Red Hat, Debian, and SUSE-based distributions) with a single control plane node and multiple worker nodes for development and testing purposes.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published