-
Notifications
You must be signed in to change notification settings - Fork 0
/
Docker&Kubernetes practice (9-Apr-23) (1).txt
292 lines (222 loc) · 5.73 KB
/
Docker&Kubernetes practice (9-Apr-23) (1).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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
****************************
apiVersion: v1
kind: ReplicationController
metadata:
name: ey-rc
spec:
replicas: 10
selector:
org: ey
template:
metadata:
name: ey-pod-rc
labels:
org: ey
spec:
containers:
- name: my-container
image: nginx
ports:
- containerPort: 80
****************************
[10:06] Pankaj (Guest)
YAML for Replication Controller
176 vi replication-controller.yml
177 kubectl create -f replication-controller.yml
178 kubectl get pods
179 od 1/1 Running 0 15m
180 clear
181 kubectl get pods
182 kubectl get rc
183 kubectl describe rc ey-rc
184 clear
185 kubectl get pods
186 kubectl get rc
187 kubectl delete pods --all
188 kuebctl get pods
189 kubectl get pods
190 clear
191 kubectl get pods
192 kubectl get rc
193 kubectl delete pods --all
194 kubectl get rc
195 kubectl get pods
196 clear
197 kubectl get pods
198 kubectl get rc
199 kubectl delete rc ey-rc
200 kubectl get pods
201 kubectl get rc
Five Minutes Hands on
Replication Controller
Replication Controller
**************************************
apiVersion: apps/v1
kind: Deployment
metadata:
name: ey-deployment
labels:
team: devops
spec:
replicas: 5
selector:
matchLabels:
team: devops
template:
metadata:
labels:
team: devops
spec:
containers:
- name: any-container
image: nginx
ports:
- containerPort: 80
************************************************
212 vi ey-deployment.yml
213 kubectl api-resources | less
214 vi ey-deployment.yml
215 clear
216 kubectl get pods
217 clear
218 kubectl get all
219 ls
220 kubectl create -f ey-deployment.yml
221 kubectl get all
222 clear
223 kubectl get all
224 kubectl delete pods --all
225 kubectl get all
226 clear
227 kubectl get all
228 kubectl delete rs ey-deployment-64dcfc4859
229 kuebctl get all
230 kubectl get all
231 clear
232 kubectl get all
233 kubectl delete deploy ey-deployment
234 kuebctl get all
235 clear
236 kubectl get all
237 kubectl create -f ey-deployment.yml
238 kubectl get all
239 kubectl describe deploy ey-deployment
240 clear
241 kubectl get pods -o wide
***********************************************************
255 kubectl scale deployment ey-deployment --replicas=25
256 kubectl get all
257 clear
258 kubectl get all
259 clear
260 kubectl get all
261 clear
262 kubectl scale deployment ey-deployment --replicas=1
263 kubectl get all
264 clear
265 kubectl get all
266 kubectl autoscale deploy ey-deployment --min=5 --max=50 --cpu-percent=80
267 kubectl get all
268 clear
269 kubectl get all
270 clear
271 ls
272 vi my-pod.yml
273 clear
274 kuebctl get pod
275 clear
276 kubectl get all
277 kubectl scale deployment ey-deployment --replicas=1
278 kubectl get all
279 clear
280 kubectl get all
281 clear
282 ls
283 kubectl get deploy
284 kubectl get all
285 clear
286 kubectl get pods -o wide
287 kubectl get nodes
288 kubectl describe node e-y-kubernetes-01
289 clear
290 kubectl get nodes
291 kubectl describe node e-y-kubernetes-02
292 kubectl describe node e-y-kubernetes-03
293 kubectl describe node e-y-kubernetes-01
294 clear
295 ls
296 vi my-pod.yml
297 clear
298 kubectl describe deploy ey-deployment.yml
299 kubectl describe deploy ey-deployment
300 clear
301 ls
302 vi ey-deployment.yml
303 kubectl apply -f ey-deployment.yml
304 kubectl get all
305*
306 kubectl get all
307 kubectl delete horizontalpodautoscaler.autoscaling/ey-deployment
308 clear
309 kubectl get all
310 vi ey-deployment.yml
311 kubectl apply -f ey-deployment.yml
312 kubectl get all
313 clear
314 kubectl get all
315 kubectl edit deploy ey-deployment
316 kubectl get all
317 ls
318 vi ey-deployment.yml
319 clear
320 kubectl edit deploy ey-deployment
321 kubectl get all
************************************
YAMLs for three types of Services
apiVersion: v1
kind: Service
metadata:
name: cip-service
spec:
type: ClusterIP
selector:
team: devops
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
***********************
apiVersion: v1
kind: Service
metadata:
name: nodeport-service
spec:
type: NodePort
selector:
team: devops
ports:
- name: http
protocol: TCP
port: 80
nodePort: 31000
# NodePort Range 30000 to 32767
targetPort: 80
*****************************
apiVersion: v1
kind: Service
metadata:
name: lb-service
spec:
type: LoadBalancer
externalIPs:
- 143.110.253.132
selector:
team: devops
ports:
- name: http
protocol: TCP
port: 80
# NodePort Range 30000 to 32767
targetPort: 80
***********************************