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.
replicas: 4 # 4 replica pods
template:
metadata:
name: firstpod
labels:
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 .
replicas: 4 # 4 replica pods
selector:
template:
metadata:
name: firstpod
labels:
Check rc label and selector.
# kubectl get rc -o wide --show-labels
Check the pods label.
Check rc.yaml file
# kubectl apply -f rc.yaml --dry-run=client
# 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
# kubectl scale rc firstrc --replicas=5
# kubectl scale rc firstrc --replicas=4
# kubectl edit <rc_nmae>
# vim rc.yaml
# kubectl apply -f rc.yaml
replicationcontroller/firstrc configured
# kubectl delete -f rc.yaml
No comments:
Post a Comment