cert_controller_test.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. suite: test cert controller deployment
  2. templates:
  3. - cert-controller-deployment.yaml
  4. - cert-controller-service.yaml
  5. tests:
  6. - it: should match snapshot of default values
  7. templates:
  8. - cert-controller-deployment.yaml
  9. asserts:
  10. - matchSnapshot: {}
  11. - it: should set imagePullPolicy to Always
  12. set:
  13. certController.image.pullPolicy: Always
  14. templates:
  15. - cert-controller-deployment.yaml
  16. asserts:
  17. - equal:
  18. path: spec.template.spec.containers[0].imagePullPolicy
  19. value: Always
  20. - it: should imagePullPolicy to be default value IfNotPresent
  21. templates:
  22. - cert-controller-deployment.yaml
  23. asserts:
  24. - equal:
  25. path: spec.template.spec.containers[0].imagePullPolicy
  26. value: IfNotPresent
  27. - it: should add a init container
  28. templates:
  29. - cert-controller-deployment.yaml
  30. set:
  31. certController.extraInitContainers:
  32. - name: foo
  33. image: example.com/external-secrets/init-image:{{ .Chart.Version }}
  34. restartPolicy: Always
  35. asserts:
  36. - equal:
  37. path: spec.template.spec.initContainers[0].name
  38. value: foo
  39. - matchRegex:
  40. path: spec.template.spec.initContainers[0].image
  41. pattern: ^example\.com/external-secrets/init-image:[0-9]+\.[0-9]+\.[0-9]+$
  42. - equal:
  43. path: spec.template.spec.initContainers[0].restartPolicy
  44. value: Always
  45. - it: should override the deployment strategy
  46. templates:
  47. - cert-controller-deployment.yaml
  48. set:
  49. certController.strategy:
  50. rollingUpdate:
  51. maxSurge: 1
  52. maxUnavailable: 0
  53. asserts:
  54. - equal:
  55. path: spec.strategy.rollingUpdate.maxSurge
  56. value: 1
  57. - equal:
  58. path: spec.strategy.rollingUpdate.maxUnavailable
  59. value: 0
  60. - it: should override securityContext
  61. set:
  62. certController.podSecurityContext:
  63. runAsUser: 2000
  64. certController.securityContext:
  65. runAsUser: 3000
  66. templates:
  67. - cert-controller-deployment.yaml
  68. asserts:
  69. - equal:
  70. path: spec.template.spec.securityContext
  71. value:
  72. runAsUser: 2000
  73. - equal:
  74. path: spec.template.spec.containers[0].securityContext
  75. value:
  76. allowPrivilegeEscalation: false
  77. capabilities:
  78. drop:
  79. - ALL
  80. readOnlyRootFilesystem: true
  81. runAsNonRoot: true
  82. runAsUser: 3000
  83. seccompProfile:
  84. type: RuntimeDefault
  85. - it: should override hostNetwork
  86. set:
  87. certController.hostNetwork: true
  88. templates:
  89. - cert-controller-deployment.yaml
  90. asserts:
  91. - equal:
  92. path: spec.template.spec.hostNetwork
  93. value: true
  94. - it: should override readinessProbe port
  95. set:
  96. certController.readinessProbe.port: 8082
  97. templates:
  98. - cert-controller-deployment.yaml
  99. asserts:
  100. - equal:
  101. path: spec.template.spec.containers[0].args[7]
  102. value: "--healthz-addr=:8082"
  103. - equal:
  104. path: spec.template.spec.containers[0].ports[1].name
  105. value: ready
  106. - equal:
  107. path: spec.template.spec.containers[0].ports[1].protocol
  108. value: TCP
  109. - equal:
  110. path: spec.template.spec.containers[0].ports[1].containerPort
  111. value: 8082
  112. - notExists:
  113. path: spec.template.spec.containers[0].ports[2]
  114. - it: should override metrics port
  115. set:
  116. certController.metrics.listen.port: 8888
  117. templates:
  118. - cert-controller-deployment.yaml
  119. asserts:
  120. - equal:
  121. path: spec.template.spec.containers[0].args[6]
  122. value: "--metrics-addr=:8888"
  123. - it: should override image flavour
  124. set:
  125. certController.image.repository: ghcr.io/external-secrets/external-secrets
  126. certController.image.tag: v0.9.8
  127. certController.image.flavour: ubi-boringssl
  128. templates:
  129. - cert-controller-deployment.yaml
  130. asserts:
  131. - equal:
  132. path: spec.template.spec.containers[0].image
  133. value: ghcr.io/external-secrets/external-secrets:v0.9.8-ubi-boringssl
  134. - it: should override image flavour
  135. set:
  136. certController.image.repository: example.com/external-secrets/external-secrets
  137. certController.image.tag: v0.9.9-ubi
  138. templates:
  139. - cert-controller-deployment.yaml
  140. asserts:
  141. - equal:
  142. path: spec.template.spec.containers[0].image
  143. value: example.com/external-secrets/external-secrets:v0.9.9-ubi
  144. - it: should render service without metrics label when metrics is enabled
  145. set:
  146. certController.metrics.service.enabled: true
  147. templates:
  148. - cert-controller-service.yaml
  149. asserts:
  150. - hasDocuments:
  151. count: 1
  152. - isNull:
  153. path: metadata.labels["app.kubernetes.io/metrics"]
  154. - it: should render service with metrics label when APIVersions are present and serviceMonitor is enabled
  155. set:
  156. serviceMonitor.enabled: true
  157. capabilities:
  158. apiVersions:
  159. - "monitoring.coreos.com/v1/ServiceMonitor"
  160. templates:
  161. - cert-controller-service.yaml
  162. asserts:
  163. - hasDocuments:
  164. count: 1
  165. - equal:
  166. path: metadata.labels["app.kubernetes.io/metrics"]
  167. value: "cert-controller"
  168. - it: should render service with metrics label when APIVersions are not present, serviceMonitor is enabled, and serviceMonitor.renderMode is alwaysRender
  169. set:
  170. serviceMonitor.enabled: true
  171. serviceMonitor.renderMode: alwaysRender
  172. templates:
  173. - cert-controller-service.yaml
  174. asserts:
  175. - hasDocuments:
  176. count: 1
  177. - equal:
  178. path: metadata.labels["app.kubernetes.io/metrics"]
  179. value: "cert-controller"
  180. - it: should fail if APIVersions is missing, serviceMonitor is enabled, and serviceMonitor.renderMode is failIfMissing
  181. set:
  182. serviceMonitor.enabled: true
  183. serviceMonitor.renderMode: failIfMissing
  184. templates:
  185. - cert-controller-service.yaml
  186. asserts:
  187. - failedTemplate: {}
  188. - it: should not render service when APIVersions is not present, serviceMonitor is enabled, and and serviceMonitor.renderMode is skipIfMissing
  189. set:
  190. serviceMonitor.enabled: true
  191. serviceMonitor.renderMode: skipIfMissing
  192. templates:
  193. - cert-controller-service.yaml
  194. asserts:
  195. - hasDocuments:
  196. count: 0
  197. - it: should not render service when APIVersions is not present but serviceMonitor is enabled
  198. set:
  199. serviceMonitor.enabled: true
  200. templates:
  201. - cert-controller-service.yaml
  202. asserts:
  203. - hasDocuments:
  204. count: 0
  205. - it: should not render service when APIVersions is present and serviceMonitor is disabled
  206. set:
  207. serviceMonitor.enabled: false
  208. capabilities:
  209. apiVersions:
  210. - "monitoring.coreos.com/v1/ServiceMonitor"
  211. templates:
  212. - cert-controller-service.yaml
  213. asserts:
  214. - hasDocuments:
  215. count: 0
  216. - it: should not render service when APIVersions is not present and serviceMonitor is disabled
  217. set:
  218. serviceMonitor.enabled: false
  219. templates:
  220. - cert-controller-service.yaml
  221. asserts:
  222. - hasDocuments:
  223. count: 0
  224. - it: should not have enableHTTP2 flag by default
  225. templates:
  226. - cert-controller-deployment.yaml
  227. asserts:
  228. - notContains:
  229. path: spec.template.spec.containers[0].args
  230. content: "--enable-http2"
  231. - it: should have startup Probe if enabled
  232. set:
  233. certController.startupProbe.enabled: true
  234. templates:
  235. - cert-controller-deployment.yaml
  236. asserts:
  237. - equal:
  238. path: spec.template.spec.containers[0].startupProbe
  239. value:
  240. httpGet:
  241. path: /readyz
  242. port: ready
  243. initialDelaySeconds: 20
  244. periodSeconds: 5
  245. - equal:
  246. path: spec.template.spec.containers[0].ports[1].name
  247. value: ready
  248. - notExists:
  249. path: spec.template.spec.containers[0].ports[2]
  250. - it: should override the startup Probe port
  251. set:
  252. certController.startupProbe.enabled: true
  253. certController.startupProbe.useReadinessProbePort: false
  254. certController.startupProbe.port: "8083"
  255. templates:
  256. - cert-controller-deployment.yaml
  257. asserts:
  258. - equal:
  259. path: spec.template.spec.containers[0].ports[2]
  260. value:
  261. containerPort: 8083
  262. protocol: TCP
  263. name: startup
  264. - equal:
  265. path: spec.template.spec.containers[0].startupProbe
  266. value:
  267. httpGet:
  268. port: startup
  269. path: /readyz
  270. initialDelaySeconds: 20
  271. periodSeconds: 5
  272. - equal:
  273. path: spec.template.spec.containers[0].ports[2].name
  274. value: startup
  275. - equal:
  276. path: spec.template.spec.containers[0].ports[2].protocol
  277. value: TCP
  278. - equal:
  279. path: spec.template.spec.containers[0].ports[2].containerPort
  280. value: 8083
  281. - it: should default to hostUsers absent
  282. set:
  283. certController.create: true
  284. capabilities:
  285. majorVersion: '1'
  286. minorVersion: '33'
  287. templates:
  288. - cert-controller-deployment.yaml
  289. asserts:
  290. - notExists:
  291. path: spec.template.spec.hostUsers
  292. - it: should permit override of hostUsers
  293. set:
  294. certController.create: true
  295. certController.hostUsers: false
  296. capabilities:
  297. majorVersion: '1'
  298. minorVersion: '33'
  299. templates:
  300. - cert-controller-deployment.yaml
  301. asserts:
  302. - equal:
  303. path: spec.template.spec.hostUsers
  304. value: false
  305. - it: should ignore hostUsers on older k8s
  306. set:
  307. certController.create: true
  308. certController.hostUsers: false
  309. capabilities:
  310. majorVersion: '1'
  311. minorVersion: '32'
  312. templates:
  313. - cert-controller-deployment.yaml
  314. asserts:
  315. - notExists:
  316. path: spec.template.spec.hostUsers
  317. - it: should not have hostAliases by default
  318. templates:
  319. - cert-controller-deployment.yaml
  320. asserts:
  321. - notExists:
  322. path: spec.template.spec.hostAliases
  323. - it: should add hostAliases when configured
  324. set:
  325. certController.hostAliases:
  326. - ip: "192.168.1.100"
  327. hostnames:
  328. - "cert.example.local"
  329. - "cert"
  330. templates:
  331. - cert-controller-deployment.yaml
  332. asserts:
  333. - equal:
  334. path: spec.template.spec.hostAliases
  335. value:
  336. - ip: "192.168.1.100"
  337. hostnames:
  338. - "cert.example.local"
  339. - "cert"
  340. - it: should use global hostAliases when certController level not set
  341. set:
  342. global:
  343. hostAliases:
  344. - ip: "192.168.1.200"
  345. hostnames:
  346. - "global.example.com"
  347. templates:
  348. - cert-controller-deployment.yaml
  349. asserts:
  350. - equal:
  351. path: spec.template.spec.hostAliases
  352. value:
  353. - ip: "192.168.1.200"
  354. hostnames:
  355. - "global.example.com"
  356. - it: should prefer certController hostAliases over global
  357. set:
  358. certController.hostAliases:
  359. - ip: "192.168.1.100"
  360. hostnames:
  361. - "cert.example.com"
  362. global:
  363. hostAliases:
  364. - ip: "192.168.1.200"
  365. hostnames:
  366. - "global.example.com"
  367. templates:
  368. - cert-controller-deployment.yaml
  369. asserts:
  370. - equal:
  371. path: spec.template.spec.hostAliases
  372. value:
  373. - ip: "192.168.1.100"
  374. hostnames:
  375. - "cert.example.com"