pod.yaml manifest and deploy a simple NGINX Pod without using kubectl run. Defining Pods in YAML is ideal for version control, reproducibility, and automation in CI/CD pipelines.
1. Create the YAML file
- Open your terminal and launch your editor to create pod.yaml:
- Every Pod manifest requires four top-level fields:
2. Add metadata
Undermetadata, set a unique name and labels to organize and select resources:
YAML is sensitive to spaces. Always use two spaces per indent level and avoid tabs.
3. Define the Pod spec
Insidespec, list your containers. Each entry needs at least name and image:
containers.
Save and exit your editor (e.g., in Vim: Esc then :wq).
4. Verify the manifest
Inspect the content to ensure indentation and syntax are correct:5. Deploy the Pod
Apply the YAML manifest to create the Pod:kubectl apply -f is idempotent and tracks changes, while kubectl create -f errors if the object already exists. For iterative edits, prefer apply.STATUS transitions to Running.
6. Inspect and debug
For detailed Pod information and events:Quick Reference
| Command | Description | Example |
|---|---|---|
| Create or update resource | Apply YAML manifest | kubectl apply -f pod.yaml |
| List Pods | View Pod status | kubectl get pod nginx |
| Describe Pod | Detailed Pod and event logs | kubectl describe pod nginx |
Links and References
Next, explore advanced manifest templating with Kustomize and Helm.