Setup K8S control-plane (master) and worker nodes¶
Setting up a Kubernetes (K8S) cluster involves configuring control-plane (master) and worker nodes. Below is a step-by-step guide to set up a basic Kubernetes cluster using kubeadm.
Prepare All Nodes (Master & Worker Nodes)¶
Perform these steps on all nodes (control-plane and workers).
Prerequisites¶
-
Update System and Install Dependencies
-
Disable Swap (Required)
-
Enable IPv4 forward
Install Container Runtime (containerd)¶
-
Install containerd
-
Configure containerd
-
Enable systemd cgroup driver
Enable systemd cgroup driver -
Restart containerd
Install Kubernetes Components¶
-
Add Kubernetes APT repository
-
Install Kubernetes tools
Initialize Cluster (Master Node)¶
Perform these steps only on the control-plane node.
Set Hostname¶
Set unique hostnames (e.g., k8s-control-plane)
| Set Hostname | |
|---|---|
Initialize Cluster¶
-
Initialize the control-plane with
kubeadmInitialize the control-plane with kubeadm -
/etc/kubernetes/directory structure
Configure kubectl¶
- Set up the admin configuration
Install CNI Plugin (Calico)¶
-
Apply CNI network
-
Wait for pods to be ready
Wait for pods to be ready
Join Cluster (Worker Nodes)¶
Perform these steps on each worker node.
Set Hostname¶
Set unique hostnames (e.g., k8s-worker1, k8s-worker2)
| Set unique hostname | |
|---|---|
Join Cluster¶
Run the kubeadm join command from the control-plane node’s kubeadm init output.
Verify Cluster (Master Node)¶
Perform these steps only on the control-plane node.
Verify Cluster¶
On the control-plane node, check node status.
| Verify cluster | |
|---|---|
Ready state.
Test Cluster¶
-
Deploy nginx application
Deploy nginx application -
Expose nginx service
Expose nginx service -
Test nginx deployment service
Access Nginx using anyTest nginx service NodeIPand the assignedNodePort.