What is ReplicationController in Kubernetes?
Replication Controller ensure that number of specified replicas run at a time.
ReplicationControllr control POD make sure desired number of PODs always be ready for service request.
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.
Behavior:
Keeps POD running
Gives Direct Control of PODs.
Benefits:
Restart PODs , Desired State.
Fine grained control for scaling..
In above diagram we can see replication controller with pod count 2 and selector v1 keeps 2 PODs up.
and in second diagram we can see RC keep one POD always up.
When a node fails, only pods backed by a replication controller are recreated.
In above diagram we can see POD1 dies with node-1. POD2 created new replica on node2
Create Replication Controller:
Execute below command:
kubectl apply -f https://k8s.io/examples/controllers/replication.yaml
The output is similar to this:
replicationcontroller/nginx created
Replication Controller Yaml File:
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 |
No comments:
Post a Comment