Kubernetes Replication Controller
A replication controller (RC) in kubernetes is a supervisor for long-running pods. Kubernetes RC helps in launching and running number of pods with specified number of replicas to help in failure.
Example of ReplicationController
This example ReplicationController config runs four copies of the nginx web server with name replication.yaml
apiVersion: v1 kind: ReplicationController metadata: name: nginx spec: replicas: 4 selector: app: nginx template: metadata: name: nginx labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80
Run the example job by downloading the example file and then run this below command:
kubectl apply -f replication.yaml
Check on the status of the ReplicationController using this below command:
kubectl describe replicationcontrollers/nginx
Name: nginx Namespace: default Selector: app=nginx Labels: app=nginx Annotations: <none> Replicas: 4 current / 4 desired Pods Status: 0 Running / 4 Waiting / 0 Succeeded / 0 Failed Pod Template: Labels: app=nginx Containers: nginx: Image: nginx Port: 80/TCP Environment: <none> Mounts: <none> Volumes: <none> Events: FirstSeen LastSeen Count From SubobjectPath Type Reason Message --------- -------- ----- ---- ------------- ---- ------ ------- 20s 20s 1 {replication-controller } Normal SuccessfulCreate Created pod: nginx-qrm3m 20s 20s 1 {replication-controller } Normal SuccessfulCreate Created pod: nginx-3ntk0 20s 20s 1 {replication-controller } Normal SuccessfulCreate Created pod: nginx-4ok8v 20s 20s 1 {replication-controller } Normal SuccessfulCreate Created pod: nginx-4ok8v