Question Format
please deploy a pod on node01 as per the below specification
Pod name: web-pod
Container name = web
image: nginx
Prerequisites
Before proceeding, ensure you have:
A running Kubernetes cluster with node01 joined.
kubectl access to the cluster.
node01 in a Ready state.
Step 1: Verify node01 Status
Check if node01 is ready:
- kubectl get nodes
Ensure node01 appears with the Ready status.
Step 2: Deploy the Pod (Imperative Method - Faster for CKA Exam!)
Run the following command to deploy the pod immediately without writing a YAML file:
- kubectl run web-pod --image=nginx --restart=Never --overrides='{"spec": {"nodeName": "node01"}}'
This command schedules web-pod directly onto node01, saving time during the exam.
Alternative Imperative Approach (Generate YAML, Then Edit)
Generate a base YAML file from an imperative command:
- kubectl run web-pod --image=nginx -o yaml > web-pod.yaml
Edit web-pod.yaml to specify node01:
apiVersion: v1
kind: Pod
metadata:
name: web-pod
spec:
nodeName: node01
containers:
- name: web
image: nginx
Apply the modified YAML file:
- kubectl apply -f web-pod.yaml
Step 3: Deploy the Pod (Declarative Method)
Create a YAML file named web-pod.yaml with the following content:
apiVersion: v1
kind: Pod
metadata:
name: web-pod
spec:
nodeName: node01
containers:
- name: web
image: nginx
Apply the YAML configuration to deploy the pod:
- kubectl apply -f web-pod.yaml
Step 4: Verify the Pod Deployment
Check if the pod is running:
- kubectl get pods -o wide
Ensure web-pod is scheduled on node01.