In Kubernetes, a ReplicationController (sometimes called a âReplicaSetâ in more moderen variations of Kubernetes) is a controller that guarantees {that a} specified choice of replicas of a Pod are working at any given time.
The ReplicationController is liable for tracking the state of the Pods it manages and taking corrective motion if the specified state does no longer fit the real state. For instance, if a Pod fails or is terminated, the ReplicationController will create a brand new Pod to switch it.
Listed here are some key options of ReplicationControllers in Kubernetes:
-
ReplicationControllers make certain that a specified choice of replicas of a Pod are working: You’ll be able to specify the choice of replicas you need to run within the desired state, and the ReplicationController will make certain that this quantity is maintained.
-
ReplicationControllers can be utilized for scaling and rolling updates: Via expanding or reducing the choice of replicas, you’ll scale your utility up or down. Moreover, you’ll use ReplicationControllers to accomplish rolling updates of your utility, by means of regularly changing outdated Pods with new ones.
-
ReplicationControllers are self-healing: If a Pod fails or is terminated, the ReplicationController will create a brand new Pod to switch it. This guarantees that the specified choice of replicas is at all times maintained, even within the face of disasters or mistakes.
-
ReplicationControllers can be utilized with labels and selectors: You’ll be able to use labels and selectors to specify which Pods are controlled by means of a ReplicationController. This lets you set up teams of comparable Pods as a unmarried unit.
-
ReplicationControllers are being changed by means of ReplicaSets: As of Kubernetes model 1.9, ReplicationControllers are being phased out and changed by means of ReplicaSets. ReplicaSets give you the identical capability as ReplicationControllers, however with extra complicated options for managing Pods.
Total, ReplicationControllers (and their more moderen similar, ReplicaSets) are a key element of Kubernetes for managing the deployment and scaling of containerized packages. Via making sure that the specified choice of replicas are working, and mechanically changing failed or terminated Pods, ReplicationControllers supply a competent and self-healing basis for working containerized workloads in Kubernetes.
Replication Controllers were changed by means of ReplicaSets in Kubernetes, however listed here are some examples of managing them the usage of the command line interface (CLI):
Create a replication controller:
$ kubectl create -f rc-definition.yaml
This command will create a replication controller in keeping with the configuration specified within the rc-definition.yaml document.
Get details about the replication controllers:
$ kubectl get replicationcontroller
This command will show details about the entire replication controllers within the Kubernetes cluster, together with their title, desired and present choice of replicas, and the picture used.
Scale the replication controller:
$ kubectl scale replicationcontroller my-rc --replicas=3
This command will scale the my-rc replication controller to 3 replicas.
Replace the replication controller:
$ kubectl rolling-update my-rc --image=picture:v2
This command will replace the my-rc replication controller to make use of the picture:v2 picture, the usage of a rolling replace solution to decrease downtime.
Delete a replication controller:
$ kubectl delete replicationcontroller my-rc
This command will delete the my-rc replication controller from the Kubernetes cluster.
Those are only a few examples of the numerous instructions to be had for managing replication controllers in Kubernetes.