Sobes.tech
Junior — Middle

Explain the purpose and working principle of ReplicaSet in Kubernetes.

sobes.tech AI

Answer from AI

A ReplicaSet in Kubernetes is responsible for maintaining a specified number of copies (replicas) of the same pod in the cluster. If a pod crashes or is deleted, the ReplicaSet automatically creates a new one to keep the number of replicas constant.

How it works:

  • You specify the desired number of replicas in the ReplicaSet manifest.
  • The ReplicaSet monitors the current state and compares it with the desired state.
  • If there are fewer replicas, it creates new pods; if there are more, it deletes the excess.

This ensures high availability and fault tolerance of applications in Kubernetes.