Challenge - 5 Problems
Deployment YAML Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of kubectl apply with a Deployment YAML
You run
What is the expected output of the command?
kubectl apply -f deployment.yaml with this YAML content:apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 3
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: nginx
image: nginx:1.21
ports:
- containerPort: 80What is the expected output of the command?
Kubernetes
apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: replicas: 3 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: nginx image: nginx:1.21 ports: - containerPort: 80
Attempts:
2 left
💡 Hint
Think about what resource type is defined in the YAML and what kubectl reports after applying it.
✗ Incorrect
The YAML defines a Deployment named 'myapp'. When you apply it, kubectl reports 'deployment.apps/myapp created' indicating the Deployment resource was created successfully.
❓ Configuration
intermediate2:00remaining
Correct label selector in Deployment YAML
You want to create a Deployment that manages pods labeled
app: frontend. Which selector field in the Deployment spec correctly matches these pods?Attempts:
2 left
💡 Hint
The selector must exactly match the labels on the pods you want to manage.
✗ Incorrect
The selector must match the pod labels exactly. Since pods have label 'app: frontend', the selector must be 'matchLabels: app: frontend'.
❓ Troubleshoot
advanced2:00remaining
Why does this Deployment fail to create pods?
You apply this Deployment YAML but no pods are created:
What is the most likely reason pods are not created?
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deploy
spec:
replicas: 2
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test-app
spec:
containers:
- name: busybox
image: busybox
command: ['sleep', '3600']What is the most likely reason pods are not created?
Attempts:
2 left
💡 Hint
Check if the selector labels and pod labels are exactly the same.
✗ Incorrect
The selector expects pods with label 'app: test' but the pod template has label 'app: test-app'. This mismatch causes no pods to be created.
🔀 Workflow
advanced3:00remaining
Order the steps to update a Deployment image safely
Put these steps in the correct order to update a Deployment's container image with zero downtime:
Attempts:
2 left
💡 Hint
Think about editing first, then applying, then monitoring rollout, then verifying pods.
✗ Incorrect
First edit the YAML to change the image, then apply it. Next monitor rollout status to ensure update success, finally verify pods are running the new image.
✅ Best Practice
expert2:30remaining
Best practice for specifying resource requests in Deployment YAML
Which option shows the best practice for specifying CPU and memory resource requests and limits in a container spec within a Deployment YAML?
Attempts:
2 left
💡 Hint
Resource values must be strings with units like 'm' for millicores and 'Mi' for memory.
✗ Incorrect
The best practice is to specify resource requests and limits as strings with units, e.g., "500m" for CPU and "256Mi" for memory. This ensures Kubernetes interprets them correctly.