Skip to content

Commit 0a16fdf

Browse files
Update Sunlife_Notes
1 parent 6036830 commit 0a16fdf

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed

Sunlife_Notes

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,3 +1281,148 @@ kubectl get rc
12811281

12821282
kubectl get po -l app=nginx-app
12831283
-------------------------------------------------------------------
1284+
1285+
-------------------------Replicaset----------------------------
1286+
A ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. As such, it is often used to guarantee the availability of a specified number of identical Pods.
1287+
1288+
Replication Controller(Equality based)
1289+
1290+
ReplicaSet (Set Based
1291+
1292+
It uses the operators ( =, ==, !=)
1293+
1294+
Operators ( in, notin,exists)
1295+
1296+
Example env=prod, env!=stag
1297+
1298+
Env in(prod)
1299+
1300+
Command Line
1301+
1302+
kubectl get pods -l env=prod
1303+
1304+
Kubectl get pods ‘env in(prod,qa)’
1305+
1306+
Manifest
1307+
1308+
selector:
1309+
1310+
app: nginx-app
1311+
1312+
1313+
1314+
selector:
1315+
1316+
matchLabels:
1317+
1318+
app: nginx-app
1319+
1320+
matchExpressions:
1321+
1322+
- {key: tier, operator: In, values: [frontend]}
1323+
1324+
1325+
LAB
1326+
1327+
1328+
1329+
# nginx-rs.yaml
1330+
apiVersion: apps/v1
1331+
kind: ReplicaSet
1332+
metadata:
1333+
name: nginx-rs
1334+
spec:
1335+
replicas: 3
1336+
template:
1337+
metadata:
1338+
name: nginx-pod
1339+
labels:
1340+
app: nginx-app
1341+
tier: frontend
1342+
spec:
1343+
containers:
1344+
- name: nginx-container
1345+
image: nginx
1346+
ports:
1347+
- containerPort: 80
1348+
selector:
1349+
matchLabels:
1350+
app: nginx-app
1351+
matchExpressions:
1352+
- {key: tier, operator: In, values: [frontend]}
1353+
1354+
1355+
1356+
1357+
*******************************************************************
1358+
1359+
# 2. Create and display replicaset
1360+
1361+
1362+
1363+
kubectl create -f nginx-rs.yaml
1364+
1365+
kubectl get po -o wide
1366+
1367+
kubectl get po -l app=nginx-app
1368+
1369+
kubectl get rs nginx-rs -o wide
1370+
1371+
kubectl describe rs nginx-rs
1372+
1373+
kubectl get po -l 'tier in (frontend)'
1374+
1375+
*******************************************************************
1376+
1377+
# 3. Automatic Pod Reschedule
1378+
1379+
1380+
1381+
kubectl get po -o wide --watch
1382+
1383+
kubectl get po -o wide
1384+
1385+
kubectl get nodes
1386+
1387+
1388+
1389+
*******************************************************************
1390+
1391+
# 4. Scale up pods
1392+
1393+
1394+
1395+
kubectl scale rs nginx-rs --replicas=5
1396+
1397+
kubectl get rs nginx-rs -o wide
1398+
1399+
kubectl get po -o wide
1400+
1401+
1402+
1403+
*******************************************************************
1404+
1405+
# 5. Scale down pods
1406+
1407+
1408+
1409+
kubectl scale rs nginx-rs --replicas=3
1410+
1411+
kubectl get rs nginx-rs -o wide
1412+
1413+
kubectl get po -o wide
1414+
1415+
1416+
1417+
*******************************************************************
1418+
1419+
# 6. Cleanup
1420+
1421+
1422+
1423+
kubectl delete -f nginx-rs.yaml
1424+
1425+
kubectl get rs
1426+
1427+
kubectl get po -l app=nginx-app
1428+
----------------------------------------------------------------

0 commit comments

Comments
 (0)