Bird
0
0

Identify the error in this Deployment YAML snippet:

medium📝 Troubleshoot Q6 of 15
Kubernetes - ReplicaSets and Deployments
Identify the error in this Deployment YAML snippet:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  replicas: 2
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      container:
      - name: myapp-container
        image: myapp:1.0
AThe metadata.name is missing namespace.
BThe image tag '1.0' is invalid.
CThe selector is missing 'matchExpressions'.
DThe key 'container' should be 'containers' (plural).
Step-by-Step Solution
Solution:
  1. Step 1: Check container spec syntax

    The pod spec requires a containers list, not container.
  2. Step 2: Validate other fields

    The image tag '1.0' is valid, selector with matchLabels is correct, and namespace is optional (defaults to 'default').
  3. Final Answer:

    The key 'container' should be 'containers' (plural). -> Option D
  4. Quick Check:

    Pod spec uses containers (plural) list [OK]
Quick Trick: Use 'containers' plural key in pod spec [OK]
Common Mistakes:
  • Using singular 'container' instead of 'containers'
  • Assuming image tag format is always wrong
  • Thinking namespace is mandatory in metadata

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes