A replication controller (RC) is a supervisor for long-running pods. An RC will launch a specified number of pods called replicas and makes sure that they keep running
Ensure that specified number of pords running at any time.
If any extra pods are running it will kill that pod and vice varsa.
New Pod get launch when they get fail, get deleted or terminited.
- High Availability
- Load Balancing
Below are the segments need to define in Relication Controller Manifest file.
- API verion
- MetaData
- Speficaication
- Template
apiVersion: v1
kind: ReplicationController
metadata: # MetaData contain 2 things name and Label (optional). Name of the replication controller
name: nginxreplication # Name of the Replication controller
spec: # Specfication contain 2 things 1. Replicas and 2. Pods (Template)
replicas: 3
selector: # Replication controller will know the pods using selector this selector name same as lable name in metadata
app: nginx # name of the application in which perticular controller is running
template: # In this section we can define the pod configration
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginximage
image: nginx # Image Name
ports:
- containerPort: 80
kubectl create -f name_of_replication_menifest_file.yml
kubectl get pods
kubectl get rc
kubectl scale --replicas=<number of pods > rc/controller_name
example : kubectl scale --replicas=10 rc/nginx
kubectl describe rc/<replication_controller_name>
kubectl describe pods <pad_name>
kubectl delete rc/<name of replication controller >