Tuesday, 7 October 2025

Deploy Highly Available Applications Using Kubernetes ReplicationController (nginx:latest)

Our course you can check :-   Udemy course 

Ques:-  

DevOps team is establishing a ReplicationController to deploy multiple pods for hosting applications that require a highly available infrastructure. Follow the specifications below to create the ReplicationController:

Create a ReplicationController using the nginx image with latest tag, and name it nginx-replicationcontroller.

Assign labels app as nginx_app, and type as front-end. Ensure the container is named nginx-container and set the replica count to 3.

All pods should be running state post-deployment.


Ans:-

🔍 What is a ReplicationController?

A ReplicationController (RC) is a Kubernetes object that:

  • Ensures a fixed number of pod replicas are running.
  • Automatically creates new pods if some fail or are deleted.
  • Uses a label selector to manage the pods it controls.

⚠️ Note: ReplicationController has largely been replaced by Deployments and ReplicaSets, which offer more advanced features like rolling updates and rollbacks.


Use Cases of ReplicationController

  • High Availability: Ensures multiple instances of an application are always running.
  • Fault Tolerance: Automatically replaces failed pods.
  • Load Distribution: Helps distribute traffic across multiple pod replicas.
  • Legacy Support: Still used in older Kubernetes setups or for backward compatibility.

🆚 ReplicationController vs ReplicaSet

Feature  ReplicationControllerReplicaSet
Label selector    Exact match only        Supports set-based
Rolling updates     Not supported   Supported via Deployment
Preferred usage        Legacy      Modern Kubernetes




raj@jumphost ~$ cat pod.yaml 
apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx-replicationcontroller
  labels:
    app: nginx_app
    type: front-end
spec:
  replicas: 3
  selector:
    app: nginx_app
    type: front-end
  template:
    metadata:
      labels:
        app: nginx_app
        type: front-end
    spec:
      containers:
      - name: nginx-container
        image: nginx:latest
        ports:
        - containerPort: 80

raj@jumphost ~$ kubectl apply -f pod.yaml 
replicationcontroller/nginx-replicationcontroller created

raj@jumphost ~$ kubectl get replicationcontroller
NAME                          DESIRED   CURRENT   READY   AGE
nginx-replicationcontroller   3         3         3       59s

raj@jumphost ~$ kubectl get pod
NAME                                READY   STATUS    RESTARTS   AGE
nginx-replicationcontroller-7mf6t   1/1     Running   0          68s
nginx-replicationcontroller-kbmqx   1/1     Running   0          68s
nginx-replicationcontroller-n82rj   1/1     Running   0          68s
raj@jumphost ~$ 

No comments:

Post a Comment