Skip to content

Replication Controller

How RC works?

If there are too many pods, the ReplicationController terminates the extra pods. If there are too few, the ReplicationController starts more pods. Unlike manually created pods, the pods maintained by a ReplicationController are automatically replaced if they fail, are deleted, or are terminated.

  • A ReplicationController ensures that a specified number of pod replicas are running at any one time. In other words, a ReplicationController makes sure that a pod or a homogeneous set of pods is always up and available.
  • Replication controller can span multiple nodes.
  • Replication controller (RC) is the old tech while Replica Set (RS) is the new one.
Exmaple RC
apiVersion: v1
kind: ReplicationController
metadata:           # this metadata is for RC
  name: nginx
    env: dev        # label for RC
spec:               # spec for RC
  replicas: 3       # total replicas for RC. Defaults to 1 if not specified
    app: nginx      # A ReplicationController manages all the pods with labels that match this selector
  template:         # This template is for pod, if new one has to be created. This is the required component
    metadata:       # this metadata is for POD
      name: nginx
        app: nginx  # If specified, the .spec.template.metadata.labels must be equal to the .spec.selector, or it will be rejected by the API
    spec:           # spec for pods
      - name: nginx-by-amar
        image: nginx
        - containerPort: 80

Deleting only a ReplicationController

You can delete a ReplicationController without affecting any of its pods. Using kubectl, specify the --cascade=orphan option to kubectl delete.