k8s.github.io

ReplicaSets

In this section, we will take a look at the below

Controllers are brain behind kubernetes

What is a Replica and Why do we need a replication controller?

rc

rc1

Difference between ReplicaSet and Replication Controller

Creating a Replication Controller

Replication Controller Definition File

rc2

    apiVersion: v1
    kind: ReplicationController
    metadata:
      name: myapp-rc
      labels:
        app: myapp
        type: front-end
    spec:
     template:
        metadata:
          name: myapp-pod
          labels:
            app: myapp
            type: front-end
        spec:
         containers:
         - name: nginx-container
           image: nginx
     replicas: 3

Creating a ReplicaSet

ReplicaSet Definition File

rs

    apiVersion: apps/v1
    kind: ReplicaSet
    metadata:
      name: myapp-replicaset
      labels:
        app: myapp
        type: front-end
    spec:
     template:
        metadata:
          name: myapp-pod
          labels:
            app: myapp
            type: front-end
        spec:
         containers:
         - name: nginx-container
           image: nginx
     replicas: 3
     selector:
       matchLabels:
        type: front-end

ReplicaSet requires a selector definition when compare to Replication Controller.

Labels and Selectors

What is the deal with Labels and Selectors? Why do we label pods and objects in kubernetes?

labels

How to scale replicaset

K8s Reference Docs: