Sure shot question 3: Join a Worker Node to a Kubernetes Cluster and Deploy a Pod

Question Format

 

Please join node01 worker node to the cluster, and you have to deploy a pod in the node01, 

pod name should be web and image should be nginx

 

Prerequisites

 

Before proceeding, ensure you have:

A running Kubernetes cluster with a control plane node.

kubeadm, kubelet, and kubectl installed on all nodes.

Administrative access to node01.

 

Step 1: Retrieve the Join Command

 

SSH into the master node:

  1. ssh user@master-node

Generate a join command with a token:

  1. kubeadm token create --print-join-command

Example output:

  1. kubeadm join <master-ip>:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash>

Copy this command for later use on node01.

Step 2: Join node01 to the Cluster

SSH into node01:

  1. ssh user@node01

Run the copied kubeadm join command:

  1. sudo kubeadm join <master-ip>:6443 --token <token> --discovery-token-ca-cert-hash sha256:<hash>

Verify the node has joined successfully:

  1. kubectl get nodes

You should see node01 in the list with a Ready status.

Step 3: Deploy a Pod on node01

Create an nginx pod and schedule it on node01:

  1. kubectl run web --image=nginx --restart=Never --overrides='{"spec": {"nodeName": "node01"}}'

Verify the pod is running:

  1. kubectl get pods -o wide

Ensure the NODE column shows node01.