Bitpath

Boss lesson · Unit 01

A Deployment for the shop

Replicas, labels and selectors, and a ReplicaSet that replaces what you delete.

13 exercisesabout 3 min

What you practise

  • Replicas, labels and selectors, a ReplicaSet replacing a deleted pod, why you rarely create a pod yourself

Try a question from this lesson

Pick one

A controller must keep 3 Pods of the shop's web app alive. Pods get random names and are replaced often. How can it tell which Pods are its own to count?

Hint

It must survive a Pod being replaced by one with a new name on a different node.

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Deployment: a count, a query, a template

A Deployment keeps a set of identical Pods running. Its spec has three parts.

replicas: how many. selector: the label query that finds its Pods. template: the Pod to create when one is missing, written as a Pod manifest without apiVersion and kind.

The template's labels must satisfy the selector, or the Deployment could never find the Pods it makes.

YAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels: {app: web}
    spec:
      containers:
        - name: web
          image: shop/web:1.4

Concept

Deployment, ReplicaSet, Pods

A Deployment does not create Pods directly. It creates a ReplicaSet, and the ReplicaSet's only job is the count: keep exactly replicas Pods that match the selector.

The Deployment sits above it so that it can swap one ReplicaSet for another when the template changes. That is a rollout, in the last unit.

The names show the chain: a ReplicaSet is the Deployment's name plus a hash of the template, and each Pod adds five random characters.

Deployment  web
ReplicaSet  web-6b7f9c5d4
Pod         web-6b7f9c5d4-x2k9q
Pod         web-6b7f9c5d4-h8m4t
Pod         web-6b7f9c5d4-p5z7n

10 more exercises in the app

  • 2× fill the blanks
  • 4× multiple choice
  • 2× type the answer
  • 1× order the lines
  • 1× true or false

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy