Repaso
EspaƱol
Cloud & DevOpsIntermediateOPS-46

What does this manifest declare?

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
spec:
  replicas: 3
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
        - name: api
          image: myrepo/api:1.4.2
          ports:
            - containerPort: 8080

Options

  1. Keep 3 Pods of myrepo/api:1.4.2, tied to labels app: api (Correct option)
  2. Run 8080 copies of the app on every node of the cluster
  3. Create a database named api that has three replicas
  4. Open port 3 on the node so that the app can be reached

Answer

Keep 3 Pods running from image myrepo/api:1.4.2; the selector ties the Deployment to Pods labeled app: api

Why

A Deployment is a desired-state declaration: "I want 3 replicas of this Pod template".

template describes each Pod (labels and containers). selector.matchLabels tells the Deployment which Pods belong to it, so the labels in template.metadata.labels must match.

If a Pod dies, Kubernetes creates another to keep 3. Changing the image tag triggers a rolling update.

Remember

Deployment = desired replicas + Pod template; labels link them.

Key terms

Practice this question in Repaso