Replication Controller in Kubernetes

In the previous posts we’ve seen Introduction to Kubernetes Pods and Deploy your first Pod in Kubernetes, In this post we will be seeing, What is Replication Controller in Kubernetes.

So let’s get started!!

What is Replication Controller?

Replication Controller make sure that at least n number of pods are running in our Kubernetes cluster, where n is the number of of replicas we define.

So Replication Controller maintains the desired number of Pods always.

Link between RC and Pod

How does RCA knows which Pod to manage? – It happens via a keyword label and selectors.

In the RC we define selectors which basically points to the label defined in Pod.

So let’s write manifest.yml

Create a file replicationController.yml

apiVersion: v1
kind: ReplicationController
  name: rcontroller-nginx
  replicas: 3                    
    app: my-nginx-app
      name: nginx-pod
        app: my-nginx-app
        - name: nginx-container
          image: nginx

Now deploy the above RC using

kubectl apply -f replicationController.yml 

let’s check our pods using

kubectl get pods to verify the same!!

Now let’s say we want to scale our pods from 3 to 5

kubectl scale rc rcontroller-nginx --replicas 5

Verify the pods using kubectl get pods.

Let’s delete one pod and check if any new pods get created.

kubectl delete pod <podname>

You might be seeing one new Pod being created and it’s been 7 seconds it’s up.

This all how you can get started with Replication Controller, do post queries in comment section if you have one.!!!!

Happy Learning!

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s