liveBook · Manning

ReplicaSet

As explained in Machine Learning Platform Engineering

A Kubernetes ReplicaSet is a controller that maintains a specified number of identical pod replicas.

A ReplicaSet keeps a Kubernetes application running at a declared replica count by creating pods from a shared pod template and selecting them through labels. section 3.3.3

Configure the controller around three operational decisions:

  • Set apiVersion to apps/v1 and kind to ReplicaSet. section 3.3.3
  • Define a pod template containing metadata, labels, the application container, image, and port. section 3.3.3
  • Set replicas to the desired count and make selector.matchLabels match the template labels. section 3.3.3

Scaling and replacement

Creating a ReplicaSet with replicas: 3 produces three running pods. Deleting one causes another pod to appear; kubectl scale ReplicaSet joker-replicaset --replicas=4 raises the target to four. section 3.3.3

Listing 3.5 replicaset.yaml: creating a ReplicaSet
apiVersion: apps/v1    #1
kind: ReplicaSet    #2
metadata:
  name: joker-replicaset    #3
  labels:
      app: fast-api    #4
spec:
  template:    #5
    metadata:
      name: joker    
      labels:
          app: fast-api    #6
    spec:
      containers:
      - name: hello-joker
        image: varunmallya/hello-joker:v1
        ports:
        - containerPort: 8083
  replicas: 3    #7
  selector:
    matchLabels:    #8
      app: fast-api

Inspect the complete replicaset.yaml manifest, including the pod template, selector, container image, port, and replica count. section 3.3.3

How Machine Learning Platform Engineering covers it

How deep it goes
Explains manifest fields, label selection, creation, replacement, and scaling, but does not descend into controller internals.
Examples
Uses hello-joker pods, replicaset.yaml, kubectl creation, pod deletion, and scaling from three to four replicas.
What it assumes
Assumes basic Kubernetes objects, YAML manifests, pods, labels, and kubectl commands.
What you can do after
Operate/configure ReplicaSets with YAML and kubectl, then verify replacement and scaling behavior.
How it connects
Connects ReplicaSets to pods, pod templates, labels, selectors, deployments, and kubectl.

Also explained in

Compare how 5 books explain ReplicaSet →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.