Interview Q&A / Docker & Kubernetes

BeginnerQuick answer1 min readUpdated 3 Oct 2026

Explain the main parts of a Kubernetes Deployment YAML.

SHORT ANSWER

apiVersion and kind identify the object, metadata names it, spec.replicas sets the count, spec.selector says which Pods it owns, and spec.template is the Pod blueprint whose labels must match the selector.

Explain it simply

A Deployment file is like an order form for a tiffin service: how many boxes (replicas), what goes in each box (template), and how to recognise your boxes (selector and labels).

apiVersion: apps/v1 and kind: Deployment say what this is. metadata.name names it. Under spec, replicas: 3 is the desired Pod count. selector.matchLabels is how the Deployment finds the Pods it owns. template is a full Pod spec with its own metadata.labels and containers; the template labels must include the selector labels, or Kubernetes rejects the YAML. Optional fields like strategy set how updates roll out.

Apply it with kubectl apply -f deploy.yaml. Editing the file and re-applying updates the same Deployment.

Example

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: nginx
          image: nginx:1.27

What to say in the interview

"A Deployment has apiVersion, kind, metadata, and a spec with replicas, a selector, and a Pod template. The template labels must match the selector so the Deployment can find its Pods."

Common mistakes

  • Mismatch between selector.matchLabels and template labels.

#kubernetes#deployment#yaml

Related questions

Practise more Docker & Kubernetes questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Docker & Kubernetes quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.