What Is ReplicationController In Kubernetes

What Is ReplicationController In Kubernetes

What Is ReplicationController In Kubernetes

Hello Everyone

Welcome to CloudAffaire and this is Debjeet.

In the last blog post, we have discussed pod in Kubernetes.

https://cloudaffaire.com/what-is-pod-in-kubernetes/

In this blog post, we will discuss ReplicationController in Kubernetes. In real world sceanrios we hardly deploy a pod directly. Instead pods are deployed using pod controller. ReplicationController is one of the pod controller which ensures that a specified number of pod replicas are running at any one time.

What Is ReplicationController?

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.

Note: ReplicationController is replaced by the ReplicaSet controller.

What Is ReplicationController In Kubernetes

How a ReplicationController 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. For example, your pods are re-created on a node after disruptive maintenance such as a kernel upgrade. For this reason, you should use a ReplicationController even if your application requires only a single pod. A ReplicationController is similar to a process supervisor, but instead of supervising individual processes on a single node, the ReplicationController supervises multiple pods across multiple nodes.

ReplicationController is often abbreviated to “rc” in discussion, and as a shortcut in kubectl commands. A simple case is to create one ReplicationController object to reliably run one instance of a Pod indefinitely. A more complex use case is to run several identical replicas of a replicated service, such as web servers.

ReplicationController manifest file syntax:

replicationcontrollerMetadata attributes:

  • annotations: Key value map stored with a resource for arbitrary metadata.
  • clusterName: The name of the cluster which the object belongs to.
  • creationTimestamp: Timestamp representing the server time when this object was created.
  • deletionGracePeriodSeconds: Seconds allowed for gracefully terminate before forcefully removed from the system.
  • deletionTimestamp: RFC 3339 date and time at which this resource will be deleted. Is not directly settable by a client.
  • finalizers: Must be empty before the object is deleted from the registry.
  • generateName: Optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided.
  • generation: A sequence number representing a specific generation of the desired state. Populated by the system. Read-only.
  • initializers: An initializer is a controller which enforces some system invariant at object creation time.
  • labels: Map of string keys and values that can be used to organize and categorize (scope and select) objects.
  • name: Name must be unique within a namespace.
  • namespace: Namespace defines the space within each name must be unique, default namespace is default.
  • ownerReferences: List of objects depended by this object.
  • resourceVersion: An opaque value that represents the internal version of this object used to determine when objects have changed.
  • selfLink: SelfLink is a URL representing this object. Populated by the system. Read-only.
  • uid: UID is the unique in time and space value for this object

replicationcontrollerSpec attributes:

  • minReadySeconds: Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0
  • replicas: Replicas is the number of desired replicas. This is a pointer to distinguish between explicit zero and unspecified. Defaults to 1.
  • selector: Selector is a label query over pods that should match the Replicas count. If Selector is empty, it is defaulted to the labels present on the Pod template. Label keys and values that must match in order to be controlled by this replication controller, if empty defaulted to labels on Pod template.
  • template: Template is the object that describes the pod that will be created if insufficient replicas are detected.

ReplicationController Demo:

Step 1: Create the replication controller.

Step 2: View replication controller details.

Step 3: Scale up and scale down the number of replicas.

Step 4: Delete a pod managed by replication controller.

Step 5: Make a connection to the pod managed by replication controller.

Step 6: Cleanup.

Hope you enjoyed this article. In real world sceanrios we hardly deploy a pod directly. Instead pods are deployed using pod controller. In the next blog post, we will discuss one of the pod controller replicaset.

To get more details on Kubernetes you can follow the below link.

https://kubernetes.io/docs/home/

To get more details on Docker you can follow the below links.

https://docs.docker.com/

https://cloudaffaire.com/category/devops/docker/

 

Leave a Reply

Close Menu