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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

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 )

Also, the latest stable versions of the following components will be installed.

Please install Ansible if you haven't already.

  • Create a common Linux user on all nodes to be used for the cluster.
  • Enable passwordless SSH authentication from the Ansible host to all cluster nodes.
  • Ensure that the common user has sudo privileges without a password on all cluster nodes.

Workflow:

1) Download the tarball for the most recent stable release of this Ansible project.

stable release

var_latest_version=$(curl -skL https://api.github.com/repos/Muthukumar-Subramaniam/install-k8s-on-linux/releases/latest | jq -r '.tag_name' 2>>/dev/null | tr -d '[:space:]')
wget https://github.com/Muthukumar-Subramaniam/install-k8s-on-linux/releases/download/${var_latest_version}/inst-k8s-ansible.tar.gz
tar -xzvf inst-k8s-ansible.tar.gz
cd inst-k8s-ansible

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

Screenshot-host-control-plane-file

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

Screenshot-host-workers-file

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.

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

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

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

./inst-k8s-ansible.yaml

Expected Outcome:

Screenshot-end-output-of-playbook-run

7) Once the Kubernetes cluster is successfully installed and ready, you can optionally install the following CSI drivers.

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

Expected Outcome:

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

Expected Outcome:

Screenshot-csi-driver-smb

8) You can also optionally install the MetalLB LoadBalancer 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

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

Stars

Watchers

Forks

Packages

No packages published