Sunday, September 11, 2022

Kubernetes Replication Controller

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.


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.

====================

apiVersion: v1

kind: ReplicationController

metadata:

  name: nginx

spec:

  replicas: 3

  selector:

    app: nginx

  template:

    metadata:

      name: nginx

      labels:

        app: nginx

    spec:

      containers:

      - name: nginx

        image: nginx

        ports:

        - containerPort: 80

=============================



root@ip-172-31-35-19:~# kubectl apply -f replicacontrol.yml

replicationcontroller/nginx created

root@ip-172-31-35-19:~# kubectl get rc

NAME    DESIRED   CURRENT   READY   AGE

nginx   3         3         3       6s

root@ip-172-31-35-19:~#



root@ip-172-31-35-19:~# kubectl label pod web-app  app=nginx
pod/web-app labeled
root@ip-172-31-35-19:~# kubectl get pods --show-labels
NAME            READY   STATUS    RESTARTS   AGE    LABELS
apache-server   1/1     Running   0          11h    env=dev,owner=kishor,test=kishor
myweb           1/1     Running   0          11h    run=myweb
nginx-ffrvl     1/1     Running   0          5m3s   app=nginx
nginx-hwzcx     1/1     Running   0          5m3s   app=nginx
nginx-t5tvp     1/1     Running   0          5m3s   app=nginx

No comments:

Post a Comment

Sample Game App Deployment on EKS cluster

 https://padmakshi.medium.com/setting-up-an-eks-cluster-and-deploying-a-game-application-a-step-by-step-guide-08790e0be117