Kubernetes CKA sample exam question 50 with answer

Question
Create a single pod of image httpd:2.4.41-alpine in namespace default.
The pod should be named pod1 and the container should be named pod1-container.
The pod should only be scheduled on a master node, do not add new labels any nodes.

Answer
Get all node names. This will be helpful for scheduling:

kubectl get nodes
Generate pod manifest:
kubectl run pod1 --image=httpd:2.4.41-alpine --dry-run=client -o yaml
Adjust manifest to match the following:
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: pod1
  name: pod1
spec:
  containers:
  - image: httpd:2.4.41-alpine
    name: pod1-container
  nodeName: cluster1-master1
Apply and test:
kubectl apply -f pod1.yaml
kubectl get po pod1 -o wide
The pod should be scheduled on master node named cluster1-master1