Certified Kubernetes Application Developer (CKAD) · Free practice question 2 of 12
Downward API Pod IP as env
An app at Tregothnan Tea must log its own Pod IP address at startup, read from an environment variable named MY_POD_IP. Which env entry supplies it?
- A.{name: MY_POD_IP, valueFrom: {configMapKeyRef: {name: pod, key: ip}}}
- B.{name: MY_POD_IP, value: $(POD_IP)}
- C.{name: MY_POD_IP, valueFrom: {resourceFieldRef: {resource: status.podIP}}}
- D.{name: MY_POD_IP, valueFrom: {fieldRef: {fieldPath: status.podIP}}}
Show answer and explanation
Correct answer: D. {name: MY_POD_IP, valueFrom: {fieldRef: {fieldPath: status.podIP}}}
Why: The downward API exposes Pod fields to environment variables through valueFrom.fieldRef, and status.podIP is a supported field path. resourceFieldRef is for container requests and limits, $(POD_IP) only expands variables already defined in the container, and a ConfigMap cannot know each Pod's IP.
More free Certified Kubernetes Application Developer (CKAD) questions
- Generating a Pod manifest skeleton
- fsGroup for shared volume ownership
- Indexed Job completion index
- Pulling and unpacking a chart locally
- Kustomize namePrefix and references
- Watching Pod status changes live
- tcpSocket probe for a non-HTTP server
- ExternalName Service for an outside host
- StatefulSet per-Pod DNS name
- Ways to consume a Secret in a container
- Checking quota usage in a namespace