Kubernetes CKA sample exam question 69 with answer

Question
Create a static Pod named my-static-pod in Namespace default on cluster3-master1.
It should be of image nginx:1.16-alpine and have resource requests for 10m CPU and 20Mi memory.
Then create a NodePort Service named static-pod-service which exposes that static Pod on port 80 and check if it has Endpoints and if its reachable throuugh the cluster3-master1 internal IP address.

Answer
Generate static pod manifest:

kubectl run my-static-pod --image=nginx:1.16-alpine --dry-run=client -o yaml
SSH to master node:
ssh cluster3-master1
Open a new file inside /etc/kubernetes/manifests/my-static-pod.yaml with adjusted contents:
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: my-static-pod
  name: my-static-pod
spec:
  containers:
  - image: nginx:1.16-alpine
    name: my-static-pod
    resources:
      requests:
        memory: 20Mi
        cpu: 10m
Save the file and exit the master node. Check the pods status until the static pod is available:
kubectl get po -w
Expose the static pod as Service:
kubectl expose po my-static-pod-cluster3-master1 --type=NodePort --name=static-pod-service --port=80 --target-port=80
Check the Endpoints:
kubectl get ep
The service endpoint should appear there