-
Notifications
You must be signed in to change notification settings - Fork 26
/
Day-5-Replica-set.txt
79 lines (58 loc) · 1.66 KB
/
Day-5-Replica-set.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
*******************************************************************
.
. Demo: ReplicaSet | youtube.com/SrinathChalla
.
*******************************************************************
ReplicaSet YAML file
# nginx-rs.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: nginx-rs
spec:
replicas: 3
template:
metadata:
name: nginx-pod
labels:
app: nginx-app
tier: frontend
spec:
containers:
- name: nginx-container
image: nginx
ports:
- containerPort: 80
selector:
matchLabels:
app: nginx-app
matchExpressions:
- {key: tier, operator: In, values: [frontend]}
*******************************************************************
# 2. Create and display replicaset
kubectl create -f nginx-rs.yaml
kubectl get po -o wide
kubectl get po -l app=nginx-app
kubectl get rs nginx-rs -o wide
kubectl describe rs nginx-rs
*******************************************************************
# 3. Automatic Pod Reschedule
kubectl get po -o wide --watch
kubectl get po -o wide
kubectl get nodes
*******************************************************************
# 4. Scale up pods
kubectl scale rs nginx-rs --replicas=5
kubectl get rs nginx-rs -o wide
kubectl get po -o wide
*******************************************************************
# 5. Scale down pods
kubectl scale rs nginx-rs --replicas=3
kubectl get rs nginx-rs -o wide
kubectl get po -o wide
*******************************************************************
# 6. Cleanup
kubectl delete -f nginx-rs.yaml
kubectl get rs
kubectl get po -l app=nginx-app
*******************************************************************