Shashikant shah

Sunday 13 December 2020

What is repplicationController in Kubernetes. Part-06

 

1.Replication controller



i) The replication controller monitors pods and automatically restarts them if they fail. 

ii) (Replication controller) selector name  match to (pods) label name.  

iii) Replication controllers and pods are associated with “labels”.

iv) Creating a “rc” with count of 1 ensure that a pod is always available.

v) If the whole node fails, the replication controller  respawn all the pods of that node on some different node.


There are two option for add lable and selector in RC.yml files.
First option :-
spec:
  replicas: 4         # 4 replica pods
  template:
    metadata:
      name: firstpod  
      labels: 
       type: app     # pods label name & default use rc selector name.

Second option add selector
spec:
  replicas: 4         # 4 replica pods
  selector:
           type: app  # use rc selector name.
  template:
    metadata:
      name: firstpod  
      labels: 
       type: app    # pods label name & default .





















Check rc label and selector.

# kubectl get rc -o wide --show-labels


Check the pods label.

# kubectl get pods -o wide --show-labels




Help for how to create rc yaml file.

# kubectl explain rc

OR

# kubectl explain rc  --recursive | less

Check rc.yaml file
# kubectl apply -f rc.yaml --dry-run=client

Create a replicationController
# kubectl  appliy  -f rc.yaml
# kubectl get rc
# kubectl get pods
# kubectl get pods --show-labels
# kubectl get pods -l type=app
# kubectl describe rc  <rc_name>
# get pods  -o wide --watch
 
Scaling up
# kubectl scale rc firstrc --replicas=5
 
Scaling down
# kubectl scale rc firstrc --replicas=4
 
ReplicationController edit
# kubectl edit <rc_nmae>
 
Replace rc configuration and edit yaml file.
# vim  rc.yaml
# kubectl apply -f rc.yaml
replicationcontroller/firstrc configured
 
Delete ReplicationController
# kubectl  delete  -f  rc.yaml


No comments:

Post a Comment