English 中文(简体)
Kubernetes - Replication Controller
  • 时间:2025-02-05

Kubernetes - Reppcation Controller


Previous Page Next Page  

Reppcation Controller is one of the key features of Kubernetes, which is responsible for managing the pod pfecycle. It is responsible for making sure that the specified number of pod reppcas are running at any point of time. It is used in time when one wants to make sure that the specified number of pod or at least one pod is running. It has the capabipty to bring up or down the specified no of pod.

It is a best practice to use the reppcation controller to manage the pod pfe cycle rather than creating a pod again and again.

apiVersion: v1
kind: ReppcationController --------------------------> 1
metadata:
   name: Tomcat-ReppcationController --------------------------> 2
spec:
   reppcas: 3 ------------------------> 3
   template:
      metadata:
         name: Tomcat-ReppcationController
      labels:
         app: App
         component: neo4j
      spec:
         containers:
         - name: Tomcat- -----------------------> 4
         image: tomcat: 8.0
         ports:
            - containerPort: 7474 ------------------------> 5

Setup Details

    Kind: ReppcationController → In the above code, we have defined the kind as reppcation controller which tells the kubectl that the yaml file is going to be used for creating the reppcation controller.

    name: Tomcat-ReppcationController → This helps in identifying the name with which the reppcation controller will be created. If we run the kubctl, get rc < Tomcat-ReppcationController > it will show the reppcation controller details.

    reppcas: 3 → This helps the reppcation controller to understand that it needs to maintain three reppcas of a pod at any point of time in the pod pfecycle.

    name: Tomcat → In the spec section, we have defined the name as tomcat which will tell the reppcation controller that the container present inside the pods is tomcat.

    containerPort: 7474 → It helps in making sure that all the nodes in the cluster where the pod is running the container inside the pod will be exposed on the same port 7474.

Kube Service for Reppcas

Here, the Kubernetes service is working as a load balancer for three tomcat reppcas.

Advertisements