Your First Pod and Declarative YAML · CKA
A Pod is the smallest deployable unit in Kubernetes.
Learn with progress and quizzesFirst, understand the concepts.
Pod
A Pod contains one or more containers that share networking and volumes. In practice, Pods are usually managed by a controller such as a Deployment.
Declarative management
Describe the desired state in YAML and apply it. Generating and inspecting YAML with dry-run is a quick way to get started.
Why it matters
A YAML file declares intent rather than execution results. Reapplying it does not continuously create differently named Pods. Distinguish name and namespace from the server-assigned UID.
Work through the reasoning
Separate creation from observation
Inspect metadata.name and container name/image in the dry-run output. After apply, separate your spec from server-populated status and identity fields in get -o yaml.
Look beyond Running
Running is a Pod phase. Inspect each container’s ready, restartCount, and state to understand availability and repeated failures. For multiple containers, identify which one each observation describes.
Learn by doing.
You need kubectl and access to your own practice Kubernetes cluster. Each lab is independent. Check your current context first, then run the commands in your own terminal.
Create an nginx Pod in a dedicated practice namespace, then inspect its status and YAML.
kubectl create namespace study-pods --dry-run=client -o yaml | kubectl apply -f -
kubectl run web --image=nginx:stable -n study-pods --dry-run=client -o yaml > web.yaml
kubectl apply -f web.yaml
kubectl get pods -n study-pods -o wide
kubectl get pod web -n study-pods -o yamlHow to check your result
Check the web Pod’s status and container image. If it is not Running, investigate the Events section of describe.
Apply what you learned
If you delete a Pod and recreate it under the same name, are its UID and emptyDir data retained?
Reveal the reasoning after trying
It is a new object with a new UID. The old Pod’s emptyDir is not carried over. Reusing a name does not preserve an execution instance; durable data needs separate persistent storage.
Ready to check your understanding?
Which options output YAML without creating a resource on the server?
- --force -o yaml
- --dry-run=client -o yaml
- --watch
- --all-namespaces
Reveal the reasoning after trying
--dry-run=client -o yaml
--dry-run=client prepares the object without creating it on the server, and -o yaml selects the YAML output format.