Skip to content

Commit 6036830

Browse files
Update Sunlife_Notes
1 parent 0bea220 commit 6036830

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

Sunlife_Notes

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,3 +1164,120 @@ spec:
11641164

11651165
memory: "200Mi"
11661166
-------------------------------------------------------
1167+
1168+
1169+
----------------Replication Contorller-----------------------------
1170+
By Raman
1171+
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.
1172+
1173+
How a ReplicationController Works
1174+
1175+
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. For example, your pods are re-created on a node after disruptive maintenance such as a kernel upgrade. For this reason, you should use a ReplicationController even if your application requires only a single pod.
1176+
1177+
1178+
1179+
LAB
1180+
1181+
1182+
1183+
1. Replication Controller YAML file
1184+
1185+
1186+
1187+
# nginx-rc.yaml
1188+
1189+
apiVersion: v1
1190+
kind: ReplicationController
1191+
metadata:
1192+
name: nginx-rc
1193+
spec:
1194+
replicas: 3
1195+
template:
1196+
metadata:
1197+
name: nginx-pod
1198+
labels:
1199+
app: nginx-app
1200+
spec:
1201+
containers:
1202+
- name: nginx-container
1203+
image: nginx
1204+
ports:
1205+
- containerPort: 80
1206+
selector:
1207+
app: nginx-app
1208+
1209+
1210+
1211+
1212+
*******************************************************************
1213+
1214+
# 2. Create and display
1215+
1216+
1217+
1218+
kubectl create -f nginx-rc.yaml
1219+
1220+
kubectl get po -o wide
1221+
1222+
kubectl get po -l app=nginx-app
1223+
1224+
kubectl get rc nginx-rc
1225+
1226+
kubectl describe rc nginx-rc
1227+
1228+
1229+
1230+
*******************************************************************
1231+
1232+
# 3. Reschedule
1233+
1234+
1235+
1236+
kubectl get po -o wide --watch
1237+
1238+
kubectl get po -o wide
1239+
1240+
kubectl get nodes
1241+
1242+
1243+
1244+
*******************************************************************
1245+
1246+
# 4. Scaling up cluster
1247+
1248+
1249+
1250+
kubectl scale rc nginx-rc --replicas=5
1251+
1252+
kubectl get rc nginx-rc
1253+
1254+
kubectl get po -o wide
1255+
1256+
1257+
1258+
*******************************************************************
1259+
1260+
# 5. Scalling down
1261+
1262+
1263+
1264+
kubectl scale rc nginx-rc --replicas=3
1265+
1266+
kubectl get rc nginx-rc
1267+
1268+
kubectl get po -o wide
1269+
1270+
1271+
1272+
*******************************************************************
1273+
1274+
# 6. Cleanup
1275+
1276+
1277+
1278+
kubectl delete -f nginx-rc.yaml
1279+
1280+
kubectl get rc
1281+
1282+
kubectl get po -l app=nginx-app
1283+
-------------------------------------------------------------------

0 commit comments

Comments
 (0)