apps-review.yml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. ---
  2. # Prepares the environment for the apps-review exercise, and cleans up afterwards.
  3. - name: Prepare the exercise of apps-review.
  4. hosts: localhost
  5. gather_subset: min
  6. become: no
  7. tasks:
  8. - name: Prereqs
  9. include_role:
  10. name: check-env
  11. - name: Ensure the projects are there
  12. kubernetes.core.k8s:
  13. kubeconfig: tmp/kubeconfig-ocp4
  14. validate_certs: no
  15. api_version: v1
  16. kind: namespace
  17. name: "{{ item.name }}"
  18. resource_definition:
  19. metadata:
  20. annotations:
  21. openshift.io/node-selector: "{{ item.nodeselector | default(omit) }}"
  22. loop:
  23. - name: apps-selector-conflict
  24. nodeselector: kubernetes.io/hostname=worker03
  25. - name: apps-selector-impossible
  26. - name: apps-lowquota
  27. - name: apps-taint
  28. - name: apps-antiaffinity
  29. #- name: apps-lowlimit
  30. - name: apps-pdb
  31. - name: Deployment conflicting node selector
  32. kubernetes.core.k8s:
  33. kubeconfig: tmp/kubeconfig-ocp4
  34. validate_certs: no
  35. api_version: apps/v1
  36. kind: deployment
  37. namespace: apps-selector-conflict
  38. name: conflict
  39. resource_definition:
  40. spec:
  41. replicas: 3
  42. selector:
  43. matchLabels:
  44. app: hello
  45. template:
  46. metadata:
  47. labels:
  48. app: hello
  49. spec:
  50. nodeSelector:
  51. kubernetes.io/hostname: worker01
  52. containers:
  53. - name: hello
  54. image: quay.io/redhattraining/hello-world-nginx:latest
  55. ports:
  56. - name: http
  57. containerPort: 8080
  58. - name: Deployment with an impossible node selector
  59. kubernetes.core.k8s:
  60. kubeconfig: tmp/kubeconfig-ocp4
  61. validate_certs: no
  62. api_version: apps/v1
  63. kind: deployment
  64. namespace: apps-selector-impossible
  65. name: select
  66. resource_definition:
  67. spec:
  68. replicas: 3
  69. selector:
  70. matchLabels:
  71. app: hello
  72. template:
  73. metadata:
  74. labels:
  75. app: hello
  76. spec:
  77. nodeSelector:
  78. impossible: nodelabel
  79. containers:
  80. - name: hello
  81. image: quay.io/redhattraining/hello-world-nginx:latest
  82. ports:
  83. - name: http
  84. containerPort: 8080
  85. - name: Ensure low quota on the lowquota project
  86. kubernetes.core.k8s:
  87. kubeconfig: tmp/kubeconfig-ocp4
  88. validate_certs: no
  89. api_version: v1
  90. kind: resourcequota
  91. resource_definition:
  92. metadata:
  93. name: compute-quota
  94. namespace: apps-lowquota
  95. spec:
  96. hard:
  97. requests.cpu: 500m
  98. requests.memory: 512Mi
  99. limits.cpu: 1000m
  100. limits.memory: 1Gi
  101. - name: Deployment exceeding quota
  102. kubernetes.core.k8s:
  103. kubeconfig: tmp/kubeconfig-ocp4
  104. validate_certs: no
  105. api_version: apps/v1
  106. kind: deployment
  107. namespace: apps-lowquota
  108. name: quota
  109. resource_definition:
  110. spec:
  111. replicas: 3
  112. selector:
  113. matchLabels:
  114. app: hello
  115. template:
  116. metadata:
  117. labels:
  118. app: hello
  119. spec:
  120. containers:
  121. - name: hello
  122. image: quay.io/redhattraining/hello-world-nginx:latest
  123. ports:
  124. - name: http
  125. containerPort: 8080
  126. resources:
  127. requests:
  128. memory: 1Gi
  129. cpu: 2
  130. - name: Taint a node
  131. kubernetes.core.k8s:
  132. kubeconfig: tmp/kubeconfig-ocp4
  133. validate_certs: no
  134. api_version: v1
  135. kind: node
  136. name: worker01
  137. state: patched
  138. resource_definition:
  139. spec:
  140. taints:
  141. - effect: NoSchedule
  142. key: foo
  143. value: bar
  144. - name: Deployment targetting tainted node
  145. kubernetes.core.k8s:
  146. kubeconfig: tmp/kubeconfig-ocp4
  147. validate_certs: no
  148. api_version: apps/v1
  149. kind: deployment
  150. namespace: apps-taint
  151. name: tainted
  152. resource_definition:
  153. spec:
  154. replicas: 3
  155. selector:
  156. matchLabels:
  157. app: hello
  158. template:
  159. metadata:
  160. labels:
  161. app: hello
  162. spec:
  163. nodeSelector:
  164. kubernetes.io/hostname: worker01
  165. containers:
  166. - name: hello
  167. image: quay.io/redhattraining/hello-world-nginx:latest
  168. ports:
  169. - name: http
  170. containerPort: 8080
  171. - name: Make nodes unschedulable
  172. kubernetes.core.k8s:
  173. kubeconfig: tmp/kubeconfig-ocp4
  174. validate_certs: no
  175. api_version: v1
  176. kind: node
  177. name: "{{ item }}"
  178. state: patched
  179. resource_definition:
  180. spec:
  181. unschedulable: true
  182. loop:
  183. - worker01
  184. - worker02
  185. - name: Deployment on the only available node, to be preferred
  186. kubernetes.core.k8s:
  187. kubeconfig: tmp/kubeconfig-ocp4
  188. validate_certs: no
  189. api_version: apps/v1
  190. kind: deployment
  191. namespace: apps-antiaffinity
  192. name: dislike
  193. resource_definition:
  194. spec:
  195. replicas: 3
  196. selector:
  197. matchLabels:
  198. app: dislike
  199. template:
  200. metadata:
  201. labels:
  202. app: dislike
  203. spec:
  204. #affinity:
  205. # podAntiAffinity:
  206. # preferredDuringSchedulingIgnoredDuringExecution:
  207. # - weight: 10
  208. # podAffinityTerm:
  209. # labelSelector:
  210. # matchLabels:
  211. # app: dislike
  212. # topologyKey: kubernetes.io/hostname
  213. containers:
  214. - name: hello
  215. image: quay.io/redhattraining/hello-world-nginx:latest
  216. ports:
  217. - name: http
  218. containerPort: 8080
  219. - name: Deployment on the only available node, to be required
  220. kubernetes.core.k8s:
  221. kubeconfig: tmp/kubeconfig-ocp4
  222. validate_certs: no
  223. api_version: apps/v1
  224. kind: deployment
  225. namespace: apps-antiaffinity
  226. name: refuse
  227. resource_definition:
  228. spec:
  229. replicas: 3
  230. selector:
  231. matchLabels:
  232. app: refuse
  233. template:
  234. metadata:
  235. labels:
  236. app: refuse
  237. spec:
  238. #affinity:
  239. # podAntiAffinity:
  240. # requiredDuringSchedulingIgnoredDuringExecution:
  241. # labelSelector:
  242. # matchLabels:
  243. # app: refuse
  244. # topologyKey: kubernetes.io/hostname
  245. containers:
  246. - name: hello
  247. image: quay.io/redhattraining/hello-world-nginx:latest
  248. ports:
  249. - name: http
  250. containerPort: 8080
  251. - name: Make nodes schedulable again
  252. kubernetes.core.k8s:
  253. kubeconfig: tmp/kubeconfig-ocp4
  254. validate_certs: no
  255. api_version: v1
  256. kind: node
  257. name: "{{ item }}"
  258. state: patched
  259. resource_definition:
  260. spec:
  261. unschedulable: false
  262. loop:
  263. - worker01
  264. - worker02
  265. - name: Deployment on the same node for PDB
  266. kubernetes.core.k8s:
  267. kubeconfig: tmp/kubeconfig-ocp4
  268. validate_certs: no
  269. api_version: apps/v1
  270. kind: deployment
  271. namespace: apps-pdb
  272. name: budget
  273. resource_definition:
  274. spec:
  275. replicas: 2
  276. selector:
  277. matchLabels:
  278. app: hello
  279. template:
  280. metadata:
  281. labels:
  282. app: hello
  283. spec:
  284. affinity:
  285. nodeAffinity:
  286. preferredDuringSchedulingIgnoredDuringExecution:
  287. - preference:
  288. matchExpressions:
  289. - key: kubernetes.io/hostname
  290. operator: In
  291. values:
  292. - worker02
  293. weight: 50
  294. containers:
  295. - name: hello
  296. image: quay.io/redhattraining/hello-world-nginx:latest
  297. ports:
  298. - name: http
  299. containerPort: 8080
  300. ...