Working with kubernetes Replication Controller
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
I want to create 1000s of SIMILAR PODS?
ReplicationController – ReplicasSets – Deployment
Statefulsets – Deamonsets
ReplicationController
A ReplicationController ensures that a specified number of pod replicas are running at any one time. In other words, a ReplicationController makes sure that a pod or a homogeneous set of pods is always up and available.
Replication
– ONE PODs would replicate(SCALE) to X number of PODS
Controller
– This controller would control #of ACTUAL PODS === #of Desire PODS
– If mis-matched – report back to API Server
apiVersion: v1
kind: ReplicationController
metadata:
# Unique key of the ReplicationController instance
name: replicationcontroller-example
spec:
# 3 Pods should exist at all times.
replicas: 3
template:
metadata:
labels:
app: nginx
spec:
containers:
# Run the nginx image
- name: nginx
image: scmgalaxy/nginx-devopsschoolv1
replicationcontroller/replicationcontroller-example created
[root@rajesh rajesh]# kubectl get rc
NAME DESIRED CURRENT READY AGE
replicationcontroller-example 3 3 0 3s
[root@rajesh rajesh]# kubectl get rc
NAME DESIRED CURRENT READY AGE
replicationcontroller-example 3 3 3 13s
[root@rajesh rajesh]# kubectl get pods
NAME READY STATUS RESTARTS AGE
replicationcontroller-example-8glnd 1/1 Running 0 21s
replicationcontroller-example-b86xm 1/1 Running 0 21s
replicationcontroller-example-fk4fg 1/1 Running 0 21s
[root@rajesh rajesh]# kubectl get pods
NAME READY STATUS RESTARTS AGE
replicationcontroller-example-26fmw 1/1 Running 0 2m5s
replicationcontroller-example-8glnd 1/1 Running 0 5m54s
replicationcontroller-example-df5zh 1/1 Running 0 2m5s
replicationcontroller-example-fk4fg 1/1 Running 0 5m54s
replicationcontroller-example-ps4nk 1/1 Running 0 2m5s
[root@rajesh rajesh]# kubectl delete pod replicationcontroller-example-26fmw replicationcontroller-example-8glnd replicationcontroller-example-df5zh replicationcontroller-example-fk4fg
pod "replicationcontroller-example-26fmw" deleted
pod "replicationcontroller-example-8glnd" deleted
pod "replicationcontroller-example-df5zh" deleted
pod "replicationcontroller-example-fk4fg" deleted
[root@rajesh rajesh]# kubectl get pods
NAME READY STATUS RESTARTS AGE
replicationcontroller-example-5bqxv 0/1 ContainerCreating 0 11s
replicationcontroller-example-dptd7 0/1 ContainerCreating 0 11s
replicationcontroller-example-j5xx9 1/1 Running 0 11s
replicationcontroller-example-prv9r 1/1 Running 0 11s
replicationcontroller-example-ps4nk 1/1 Running 0 3m11s
254 kubectl -h
255 clear
256 kubectl create -h
257 clear
258 kubectl create -h
259 clear
260 vi rc.yaml
261 kubectl get rc
262 kubectl create -f rc.yaml
263 kubectl get rc
264 kubectl get pods
265 kubectl edit rc replicationcontroller-example
266 kubectl get pods
267 clear
268 kubectl get pods
269 clear
270 kubectl edit rc replicationcontroller-example
271 kubectl get pods
272 clear
273 kubectl get pods
274 vi rc.yaml
275 kubectl apply -f rc.yaml
276 kubectl get pods
277 kubectl scale -h
278 clear
279 kubectl scale --replicas=10 -f rc.yaml
280 kubectl get pods
281 kubectl scale --replicas=5 rs/replicationcontroller-example
282 kubectl scale --replicas=5 rc/replicationcontroller-example
283 kubectl get pod
284 clear
285 kubectl get pods
286 kubectl delete pod replicationcontroller-example-26fmw replicationcontroller-example-8glnd replicationcontroller-example-df5zh replicationcontroller-example-fk4fg
287 kubectl get pods