Sobes.tech
Junior

What do you know about the Replication Controller?

sobes.tech AI

Answer from AI

Replication Controller (RC) is a deprecated resource in Kubernetes that ensures a specified number of pods with a certain template are running at any given time. It manages the lifecycle of pods, automatically restarts them on failures, and creates new pods as needed to maintain the desired number of replicas.

Main functions and limitations of RC:

  • Maintaining the desired number of replicas: Ensures that the specified number of pods are always running.
  • Self-healing: Restarts or creates pods in case of their deletion, failure, or node crash.
  • Scaling: Allows manual increase or decrease of the number of replicas.
  • Updating: Does not provide built-in strategies for "seamless" updates of pods (e.g., Rolling Update). Additional mechanisms or orchestration are required for this.
  • Deprecated: Replaced by a more functional and flexible resource — Deployment.

Deployment uses ReplicaSet (a successor to RC with extended selector capabilities) to manage pods and adds features such as:

  • Update strategies (Rolling Update, Recreate).
  • Rollback to previous version.
  • Pause and resume deployment.

Example of an RC manifest:

apiVersion: v1
kind: ReplicationController
metadata:
  name: myapp-rc
spec:
  replicas: 3 # Desired number of pods
  selector:
    app: myapp # Selector to find pods managed by RC
  template: # Template for creating new pods
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp-container
        image: nginx:latest # Container image
        ports:
        - containerPort: 80

Despite being deprecated, understanding RC is important for understanding the evolution of pod management resources in Kubernetes and the principles of how ReplicaSet and Deployment, which replaced it, work. In new deployments, Deployment should be used instead of Replication Controller.