Kubernetes CKA sample exam question 18 with answer

Question
Create a pod called pod-jxc56fv using details mentioned below:
securityContext:
runAsUser: 1000
fsGroup: 2000
image=redis:alpine

Answer
Generate YAML for pod:

kubectl run pod-jxc56fv --image=redis:alpine --dry-run=client -o yaml > pod.yaml
Open Kubernetes Documentation, search for securityContext, open pod.yam and modify it in this way:
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: pod-jxc56fv
  name: pod-jxc56fv
spec:
  securityContext:
    runAsUser: 1000
    fsGroup: 2000
  containers:
  - image: redis:alpine
    name: pod-jxc56fv
Apply and verify:
kubectl apply -f pod.yaml
kubectl exec -it pod-jxc56fv -- whoami