controller_test.yaml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. suite: test controller deployment
  2. templates:
  3. - deployment.yaml
  4. tests:
  5. - it: should match snapshot of default values
  6. asserts:
  7. - matchSnapshot: {}
  8. - it: should set imagePullPolicy to Always
  9. set:
  10. image.pullPolicy: Always
  11. asserts:
  12. - equal:
  13. path: spec.template.spec.containers[0].imagePullPolicy
  14. value: Always
  15. - it: should imagePullPolicy to be default value IfNotPresent
  16. asserts:
  17. - equal:
  18. path: spec.template.spec.containers[0].imagePullPolicy
  19. value: IfNotPresent
  20. - it: should override securityContext
  21. set:
  22. podSecurityContext:
  23. runAsUser: 2000
  24. securityContext:
  25. runAsUser: 3000
  26. asserts:
  27. - equal:
  28. path: spec.template.spec.securityContext
  29. value:
  30. runAsUser: 2000
  31. - equal:
  32. path: spec.template.spec.containers[0].securityContext
  33. value:
  34. allowPrivilegeEscalation: false
  35. capabilities:
  36. drop:
  37. - ALL
  38. readOnlyRootFilesystem: true
  39. runAsNonRoot: true
  40. runAsUser: 3000
  41. seccompProfile:
  42. type: RuntimeDefault
  43. - it: should override hostNetwork
  44. set:
  45. hostNetwork: true
  46. asserts:
  47. - equal:
  48. path: spec.template.spec.hostNetwork
  49. value: true
  50. - it: should override metrics port
  51. set:
  52. metrics.listen.port: 8888
  53. asserts:
  54. - contains:
  55. path: spec.template.spec.containers[0].args
  56. content: "--metrics-addr=:8888"
  57. - it: should override image flavour
  58. set:
  59. image.repository: ghcr.io/external-secrets/external-secrets
  60. image.tag: v0.9.8
  61. image.flavour: ubi-boringssl
  62. asserts:
  63. - equal:
  64. path: spec.template.spec.containers[0].image
  65. value: ghcr.io/external-secrets/external-secrets:v0.9.8-ubi-boringssl
  66. - it: should override image flavour
  67. set:
  68. image.repository: example.com/external-secrets/external-secrets
  69. image.tag: v0.9.9-ubi
  70. asserts:
  71. - equal:
  72. path: spec.template.spec.containers[0].image
  73. value: example.com/external-secrets/external-secrets:v0.9.9-ubi
  74. - it: should add a init container
  75. set:
  76. extraInitContainers:
  77. - name: foo
  78. image: example.com/external-secrets/init-image:{{ .Chart.Version }}
  79. restartPolicy: Always
  80. asserts:
  81. - equal:
  82. path: spec.template.spec.initContainers[0].name
  83. value: foo
  84. - matchRegex:
  85. path: spec.template.spec.initContainers[0].image
  86. pattern: ^example\.com/external-secrets/init-image:[0-9]+\.[0-9]+\.[0-9]+$
  87. - equal:
  88. path: spec.template.spec.initContainers[0].restartPolicy
  89. value: Always
  90. - it: should override the deployment strategy
  91. set:
  92. strategy:
  93. rollingUpdate:
  94. maxSurge: 1
  95. maxUnavailable: 0
  96. asserts:
  97. - equal:
  98. path: spec.strategy.rollingUpdate.maxSurge
  99. value: 1
  100. - equal:
  101. path: spec.strategy.rollingUpdate.maxUnavailable
  102. value: 0
  103. - it: should add livenessProbe if defined
  104. set:
  105. livenessProbe:
  106. enabled: true
  107. asserts:
  108. - equal:
  109. path: spec.template.spec.containers[0].livenessProbe
  110. value:
  111. timeoutSeconds: 5
  112. failureThreshold: 5
  113. periodSeconds: 10
  114. successThreshold: 1
  115. initialDelaySeconds: 10
  116. httpGet:
  117. port: live
  118. path: /healthz
  119. - equal:
  120. path: spec.template.spec.containers[0].ports[1]
  121. value:
  122. containerPort: 8082
  123. protocol: TCP
  124. name: live
  125. - it: should customize livenessProbe port under spec.port
  126. set:
  127. livenessProbe:
  128. enabled: true
  129. spec:
  130. port: 8888
  131. asserts:
  132. - equal:
  133. path: spec.template.spec.containers[0].livenessProbe
  134. value:
  135. timeoutSeconds: 5
  136. failureThreshold: 5
  137. periodSeconds: 10
  138. successThreshold: 1
  139. initialDelaySeconds: 10
  140. httpGet:
  141. port: live
  142. path: /healthz
  143. - equal:
  144. path: spec.template.spec.containers[0].ports[1]
  145. value:
  146. containerPort: 8888
  147. protocol: TCP
  148. name: live
  149. - it: should customize livenessProbe port under spec.httpGet
  150. set:
  151. livenessProbe:
  152. enabled: true
  153. spec:
  154. initialDelaySeconds: 10
  155. periodSeconds: 10
  156. timeoutSeconds: 10
  157. failureThreshold: 10
  158. successThreshold: 10
  159. httpGet:
  160. path: /healthz
  161. port: 8080
  162. scheme: HTTP
  163. asserts:
  164. - equal:
  165. path: spec.template.spec.containers[0].livenessProbe
  166. value:
  167. initialDelaySeconds: 10
  168. periodSeconds: 10
  169. timeoutSeconds: 10
  170. failureThreshold: 10
  171. successThreshold: 10
  172. httpGet:
  173. port: 8080
  174. path: /healthz
  175. scheme: HTTP
  176. - equal:
  177. path: spec.template.spec.containers[0].ports[1]
  178. value:
  179. containerPort: 8080
  180. protocol: TCP
  181. name: live
  182. - it: should use httpGet.port over spec.port when httpGet.port is numeric
  183. set:
  184. livenessProbe:
  185. enabled: true
  186. spec:
  187. port: 3030
  188. initialDelaySeconds: 10
  189. periodSeconds: 10
  190. timeoutSeconds: 10
  191. failureThreshold: 10
  192. successThreshold: 10
  193. httpGet:
  194. path: /healthz
  195. port: 8080
  196. scheme: HTTP
  197. asserts:
  198. - equal:
  199. path: spec.template.spec.containers[0].livenessProbe
  200. value:
  201. initialDelaySeconds: 10
  202. periodSeconds: 10
  203. timeoutSeconds: 10
  204. failureThreshold: 10
  205. successThreshold: 10
  206. httpGet:
  207. port: 8080
  208. path: /healthz
  209. scheme: HTTP
  210. - equal:
  211. path: spec.template.spec.containers[0].ports[1]
  212. value:
  213. containerPort: 8080
  214. protocol: TCP
  215. name: live
  216. - it: should update args with enableHTTP2=true
  217. set:
  218. enableHTTP2: true
  219. asserts:
  220. - contains:
  221. path: spec.template.spec.containers[0].args
  222. content: "--enable-http2=true"
  223. - it: should not have enableHTTP2 flag by default
  224. asserts:
  225. - notContains:
  226. path: spec.template.spec.containers[0].args
  227. content: "--enable-http2"
  228. - it: should default to hostUsers absent
  229. capabilities:
  230. majorVersion: '1'
  231. minorVersion: '33'
  232. asserts:
  233. - notExists:
  234. path: spec.template.spec.hostUsers
  235. - it: should permit override of hostUsers
  236. capabilities:
  237. majorVersion: '1'
  238. minorVersion: '33'
  239. set:
  240. hostUsers: false
  241. asserts:
  242. - equal:
  243. path: spec.template.spec.hostUsers
  244. value: false
  245. - it: should ignore hostUsers on older k8s
  246. capabilities:
  247. majorVersion: '1'
  248. minorVersion: '32'
  249. set:
  250. hostUsers: false
  251. asserts:
  252. - notExists:
  253. path: spec.template.spec.hostUsers
  254. - it: should not have hostAliases by default
  255. asserts:
  256. - notExists:
  257. path: spec.template.spec.hostAliases
  258. - it: should add hostAliases when configured
  259. set:
  260. hostAliases:
  261. - ip: "192.168.1.100"
  262. hostnames:
  263. - "example.local"
  264. - "example"
  265. - ip: "10.0.0.1"
  266. hostnames:
  267. - "internal.example.com"
  268. asserts:
  269. - equal:
  270. path: spec.template.spec.hostAliases
  271. value:
  272. - ip: "192.168.1.100"
  273. hostnames:
  274. - "example.local"
  275. - "example"
  276. - ip: "10.0.0.1"
  277. hostnames:
  278. - "internal.example.com"
  279. - it: should use global hostAliases when root level not set
  280. set:
  281. global:
  282. hostAliases:
  283. - ip: "192.168.1.200"
  284. hostnames:
  285. - "global.example.com"
  286. asserts:
  287. - equal:
  288. path: spec.template.spec.hostAliases
  289. value:
  290. - ip: "192.168.1.200"
  291. hostnames:
  292. - "global.example.com"
  293. - it: should prefer root level hostAliases over global
  294. set:
  295. hostAliases:
  296. - ip: "192.168.1.100"
  297. hostnames:
  298. - "root.example.com"
  299. global:
  300. hostAliases:
  301. - ip: "192.168.1.200"
  302. hostnames:
  303. - "global.example.com"
  304. asserts:
  305. - equal:
  306. path: spec.template.spec.hostAliases
  307. value:
  308. - ip: "192.168.1.100"
  309. hostnames:
  310. - "root.example.com"