This article provides a method to create a simple 3-node kubernetes (k8s) cluster as shown in the image below using ansible. This k8s cluster is built using the latest stable version of kubernetes and the containerd runtime on RHEL 8 nodes.
- 3 pre-provisioned RHEL 8 nodes with connectivity to the Internet to download packages and images from repositories and registries.
- A user account (auto.svc in my playbook) with sudo (root) privileges provisioned on the ansible control node and all RHEL 8 nodes. Also ensure that the user’s SSH keys are set up to allow execution of the ansible playbook.
- The pod network and service network cidr configured in vars/main.yaml. Ensure that you do not use CIDRs that overlap with your external network.
STEP 1: Download the ansible playbook on the ansible control node
git clone https://github.com/cybergavin/kubernetes.git
STEP 2: Configure the required variables
Set the POD and SERVICE network CIDR blocks in vars/main.yaml
STEP 3: Configure the inventory
Add details for the pre-provisioned RHEL 8 nodes to the files/inventory
STEP 4: Execute the playbook
ansible-playbook -i files/inventory k8s_create.yaml
On the control-plane node, you should see output similar to below when checking the status of the k8s cluster with kubectl:
NOTE: You may use the above playbook to create kubernetes cluster with more worker nodes. However, the above playbook caters to a control-plane with a single master node.