Sunday, September 1, 2024

Kubernetes - ReplicaSet [part 8]


 

ReplicaSets:

ReplicaSet acts as cluster wide Pod manager and ensuring that right types & number of Pods are running at all times.  It is providing the underpinning of self-healing for our applications at the infrastructure level.

 The reconciliation loop is the notion of desire state versus observed or current state.  The reconciliation loop is constantly running, observing the current level of the Pods and taking action in case of different state.

The ReplicaSet controller will notice that a Pod is missing and create a new copy, but still Pod is still running is available to developers for interactive debugging rather than debugging from logs.

ReplicaSet is define in the spec section while create a configuration file.

apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
  name: kuard
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: kuard
        version: "2"
    spec:
      containers:
        - name: kuard
          image: "gcr.io/kuar-demo/kuard-amd64:green"

ReplicaSet monitor cluster state using a set of Pod labels. Labels are used to filter Pod listings and track Pods running within a cluster.  

Scaling up the ReplicaSet thorough command:

#kubectl scale replicasets podname --replicas=4

The pods will be delete along with replica set when we have remove it. We need to set a --cascade flag to false if you want to retain the pods after delete a replica set.

#kubectl delete rs podname --cascade=false

No comments:

Post a Comment