forked from rskTech/k8s_material
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpracticeset
475 lines (190 loc) · 15.5 KB
/
practiceset
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
=================================================================
BASIC CORE CONCEPT Questions
=================================================================
1. List all the namespaces in the cluster
2. List all the pods in all namespaces
3. List all the pods in the particular namespace
4. List all the services in the particular namespace
5. List all the pods showing name and namespace with a json path expression
6. Create an nginx pod in a default namespace and verify the pod running
7. Create the same nginx pod with a yaml file
8. Output the yaml file of the pod you just created
9. Output the yaml file of the pod you just created without the cluster-specific information
10. Get the complete details of the pod you just created
11. Delete the pod you just created
12. Delete the pod you just created without any delay (force delete)
13. Create the nginx pod with version 1.17.4 and expose it on port 80
14. Change the Image version to 1.15-alpine for the pod you just created and verify the image version is updated
15. Change the Image version back to 1.17.1 for the pod you just updated and observe the changes
16. Check the Image version without the describe command
17. Create the nginx pod and execute the simple shell on the pod
18. Get the IP Address of the pod you just created
19. Create a busybox pod and run command ls while creating it and check the logs
20. If pod crashed check the previous logs of the pod
21. Create a busybox pod with command sleep 3600
22. Check the connection of the nginx pod from the busybox pod
23. Create a busybox pod and echo message ‘How are you’ and delete it manually
24. Create a busybox pod and echo message ‘How are you’ and have it deleted immediately
25. Create an nginx pod and list the pod with different levels of verbosity
26. List the nginx pod with custom columns POD_NAME and POD_STATUS
27. List all the pods sorted by name
28. List all the pods sorted by created timestamp
===================================================================
Multi-Container Pods
====================================================================
Practice questions based on these concepts
Understand multi-container pod design patterns (eg: ambassador, adaptor, sidecar)
29. Create a Pod with three busy box containers with commands “ls; sleep 3600;”, “echo Hello World; sleep 3600;” and “echo this is the third container; sleep 3600” respectively and check the status
30. Check the logs of each container that you just created
31. Check the previous logs of the second container busybox2 if any
32. Run command ls in the third container busybox3 of the above pod
33. Show metrics of the above pod containers and puts them into the file.log and verify
34. Create a Pod with main container busybox and which executes this “while true; do echo ‘Hi I am from Main container’ >> /var/log/index.html; sleep 5; done” and with sidecar container with nginx image which exposes on port 80. Use emptyDir Volume and mount this volume on path /var/log for busybox and on path /usr/share/nginx/html for nginx container. Verify both containers are running.
35. Exec into both containers and verify that main.txt exist and query the main.txt from sidecar container with curl localhost
===========================================================
Pod Design
============================================================
Practice questions based on these concepts
Understand how to use Labels, Selectors and Annotations
Understand Deployments and how to perform rolling updates
Understand Deployments and how to perform rollbacks
Understand Jobs and CronJobs
36. Get the pods with label information
37. Create 5 nginx pods in which two of them is labeled env=prod and three of them is labeled env=dev
38. Verify all the pods are created with correct labels
39. Get the pods with label env=dev
40. Get the pods with label env=dev and also output the labels
41. Get the pods with label env=prod
42. Get the pods with label env=prod and also output the labels
43. Get the pods with label env
44. Get the pods with labels env=dev and env=prod
45. Get the pods with labels env=dev and env=prod and output the labels as well
46. Change the label for one of the pod to env=uat and list all the pods to verify
47. Remove the labels for the pods that we created now and verify all the labels are removed
48. Let’s add the label app=nginx for all the pods and verify
49. Get all the nodes with labels (if using minikube you would get only master node)
50. Label the node (minikube if you are using) nodeName=nginxnode
51. Create a Pod that will be deployed on this node with the label nodeName=nginxnode
52. Verify the pod that it is scheduled with the node selector
53. Verify the pod nginx that we just created has this label
54. Annotate the pods with name=webapp
55. Verify the pods that have been annotated correctly
56. Remove the annotations on the pods and verify
57. Remove all the pods that we created so far
58. Create a deployment called webapp with image nginx with 5 replicas
59. Get the deployment you just created with labels
60. Output the yaml file of the deployment you just created
61. Get the pods of this deployment
62. Scale the deployment from 5 replicas to 20 replicas and verify
63. Get the deployment rollout status
64. Get the replicaset that created with this deployment
65. Get the yaml of the replicaset and pods of this deployment
66. Delete the deployment you just created and watch all the pods are also being deleted
67. Create a deployment of webapp with image nginx:1.17.1 with container port 80 and verify the image version
68. Update the deployment with the image version 1.17.4 and verify
69. Check the rollout history and make sure everything is ok after the update
70. Undo the deployment to the previous version 1.17.1 and verify Image has the previous version
71. Update the deployment with the image version 1.16.1 and verify the image and also check the rollout history
72. Update the deployment to the Image 1.17.1 and verify everything is ok
73. Update the deployment with the wrong image version 1.100 and verify something is wrong with the deployment
74. Undo the deployment with the previous version and verify everything is Ok
75. Check the history of the specific revision of that deployment
76. Pause the rollout of the deployment
77. Update the deployment with the image version latest and check the history and verify nothing is going on
78. Resume the rollout of the deployment
79. Check the rollout history and verify it has the new version
80. Apply the autoscaling to this deployment with minimum 10 and maximum 20 replicas and target CPU of 85% and verify hpa is created and replicas are increased to 10 from 1
81. Clean the cluster by deleting deployment and hpa you just created
82. Create a Job with an image node which prints node version and also verifies there is a pod created for this job
83. Get the logs of the job just created
84.Output the yaml file for the Job with the image busybox which echos “Hello I am from job”
85. Copy the above YAML file to hello-job.yaml file and create the job
86. Verify the job and the associated pod is created and check the logs as well
87. Delete the job we just created
88. Create the same job and make it run 10 times one after one
89. Watch the job that runs 10 times one by one and verify 10 pods are created and delete those after it’s completed
90. Create the same job and make it run 10 times parallel
91. Watch the job that runs 10 times parallelly and verify 10 pods are created and delete those after it’s completed
92. Create a Cronjob with busybox image that prints date and hello from kubernetes cluster message for every minute
93. Output the YAML file of the above cronjob
94. Verify that CronJob creating a separate job and pods for every minute to run and verify the logs of the pod
95. Delete the CronJob and verify all the associated jobs and pods are also deleted.
============================================
State Persistence
==========================================================
96. List Persistent Volumes in the cluster
97. Create a hostPath PersistentVolume named task-pv-volume with storage 10Gi, access modes ReadWriteOnce, storageClassName manual, and volume at /mnt/data and verify
98. Create a PersistentVolumeClaim of at least 3Gi storage and access mode ReadWriteOnce and verify status is Bound
99. Delete persistent volume and PersistentVolumeClaim we just created
100. Create a Pod with an image Redis and configure a volume that lasts for the lifetime of the Pod
// emptyDir is the volume that lasts for the life of the podkubectl create -f redis-storage.yaml
101. Exec into the above pod and create a file named file.txt with the text ‘This is called the file’ in the path /data/redis and open another tab and exec again with the same pod and verifies file exist in the same path.
102. Delete the above pod and create again from the same yaml file and verifies there is no file.txt in the path /data/redis
103. Create PersistentVolume named task-pv-volume with storage 10Gi, access modes ReadWriteOnce, storageClassName manual, and volume at /mnt/data and Create a PersistentVolumeClaim of at least 3Gi storage and access mode ReadWriteOnce and verify status is Bound
104. Create an nginx pod with containerPort 80 and with a PersistentVolumeClaim task-pv-claim and has a mouth path "/usr/share/nginx/html"
==============================================================
Configuration
============================================================
Understand ConfigMaps
Understand SecurityContexts
Define an application’s resource requirements
Create & Consume Secrets
Understand ServiceAccounts
105. List all the configmaps in the cluster
106. Create a configmap called myconfigmap with literal value appname=myapp
107. Verify the configmap we just created has this data
108. delete the configmap myconfigmap we just created
109. Create a file called config.txt with two values key1=value1 and key2=value2 and verify the file
110. Create a configmap named keyvalcfgmap and read data from the file config.txt and verify that configmap is created correctly
111. Create an nginx pod and load environment values from the above configmap keyvalcfgmap and exec into the pod and verify the environment variables and delete the pod
112. Create an env file file.env with var1=val1 and create a configmap envcfgmap from this env file and verify the configmap
113. Create an nginx pod and load environment values from the above configmap envcfgmap and exec into the pod and verify the environment variables and delete the pod
114. Create a configmap called cfgvolume with values var1=val1, var2=val2 and create an nginx pod with volume nginx-volume which reads data from this configmap cfgvolume and put it on the path /etc/cfg
115. Create a pod called secbusybox with the image busybox which executes command sleep 3600 and makes sure any Containers in the Pod, all processes run with user ID 1000 and with group id 2000 and verify.
116. Create the same pod as above this time set the securityContext for the container as well and verify that the securityContext of container overrides the Pod level securityContext.
117. Create pod with an nginx image and configure the pod with capabilities NET_ADMIN and SYS_TIME verify the capabilities
118. Create a Pod nginx and specify a memory request and a memory limit of 100Mi and 200Mi respectively.
119. Create a Pod nginx and specify a CPU request and a CPU limit of 0.5 and 1 respectively.
120. Create a Pod nginx and specify both CPU, memory requests and limits together and verify.
121. Create a Pod nginx and specify a memory request and a memory limit of 100Gi and 200Gi respectively which is too big for the nodes and verify pod fails to start because of insufficient memory
122. Create a secret mysecret with values user=myuser and password=mypassword
123. List the secrets in all namespaces
124. Output the yaml of the secret created above
125. Create an nginx pod which reads username as the environment variable
126. Create an nginx pod which loads the secret as environment variables
127. List all the service accounts in the default namespace
128. List all the service accounts in all namespaces
129. Create a service account called admin
130. Output the YAML file for the service account we just created
131. Create a busybox pod which executes this command sleep 3600 with the service account admin and verify
===================================================================
Observability
==================================================================
Understand LivenessProbes and ReadinessProbes
Understand Container Logging
Understand how to monitor applications in kubernetes
Understand Debugging in Kubernetes
132. Create an nginx pod with containerPort 80 and it should only receive traffic only it checks the endpoint / on port 80 and verify and delete the pod.
133. Create an nginx pod with containerPort 80 and it should check the pod running at endpoint / healthz on port 80 and verify and delete the pod.
134. Create an nginx pod with containerPort 80 and it should check the pod running at endpoint /healthz on port 80 and it should only receive traffic only it checks the endpoint / on port 80. verify the pod.
135. Check what all are the options that we can configure with readiness and liveness probes
136. Create the pod nginx with the above liveness and readiness probes so that it should wait for 20 seconds before it checks liveness and readiness probes and it should check every 25 seconds.
137. Create a busybox pod with this command “echo I am from busybox pod; sleep 3600;” and verify the logs.
138. copy the logs of the above pod to the busybox-logs.txt and verify
139. List all the events sorted by timestamp and put them into file.log and verify
140. Create a pod with an image alpine which executes this command ”while true; do echo ‘Hi I am from alpine’; sleep 5; done” and verify and follow the logs of the pod.
141. Create the pod with this kubectl create -f https://gist.githubusercontent.com/bbachi/212168375b39e36e2e2984c097167b00/raw/1fd63509c3ae3a3d3da844640fb4cca744543c1c/not-running.yml. The pod is not in the running state. Debug it.
142. This following yaml creates 4 namespaces and 4 pods. One of the pod in one of the namespaces are not in the running state. Debug and fix it. https://gist.githubusercontent.com/bbachi/1f001f10337234d46806929d12245397/raw/84b7295fb077f15de979fec5b3f7a13fc69c6d83/problem-pod.yaml.
143. Get the memory and CPU usage of all the pods and find out top 3 pods which have the highest usage and put them into the cpu-usage.txt file
==========================================
Services and Networking
==============================================================
Understand Services
Demonstrate a basic understanding of NetworkPolicies
144. Create an nginx pod with a yaml file with label my-nginx and expose the port 80
145. Create the service for this nginx pod with the pod selector app: my-nginx
146. Find out the label of the pod and verify the service has the same label
147. Delete the service and create the service with kubectl expose command and verify the label
148. Delete the service and create the service again with type NodePort
149. Create the temporary busybox pod and hit the service. Verify the service that it should return the nginx page index.html.
150. Create a NetworkPolicy which denies all ingress traffic