☸️ Kubernetes YAML Bug-Hunt
Find the errors in the 10 YAML snippets below. Click "Show Answer" to verify.
apiVersion: v1
kind: Pod
metadata:
name: web-pod
spec:
containers:
- name: nginx
image: nginx:latest
The Error: Indentation. The spec key has a leading space. It must align perfectly with metadata.
spec:
containers:
name: alpine
image: alpine
The Error: containers is an array. You need a - before name.
apiVersion: v1
kind: Deployment
metadata:
name: my-deploy
The Error: Deployments belong to apps/v1, not v1.
selector:
app: frontend
---
labels:
app: web-ui
The Error: The Service is looking for 'frontend', but the Pod is 'web-ui'. They won't connect!
labels:
env: prod
labels:
team: ops
The Error: You cannot have the same key (labels) twice in the same block.
resources:
requests:
cpu: "500mb"
The Error: CPU is measured in cores or millicores (500m), not megabytes (mb).
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: webserver
The Error: The Deployment selector MUST match the labels in the Pod template.
volumeMounts:
- name: data
volumes:
- name: config
The Error: The volumeMounts name must match an existing name in the volumes list.
ports:
- port: 80
name: http
- port: 443
name: http
The Error: Port names within a Service must be unique. You can't have two named 'http'.
livenessProbe:
periodSeconds: 10
timeoutSeconds: 15
The Error: Timeout cannot be greater than the period. You can't wait 15s for a check that happens every 10s.