cert_controller_test.yaml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. - it: should override metrics port
  104. set:
  105. certController.metrics.listen.port: 8888
  106. templates:
  107. - cert-controller-deployment.yaml
  108. asserts:
  109. - equal:
  110. path: spec.template.spec.containers[0].args[6]
  111. value: "--metrics-addr=:8888"
  112. - it: should override image flavour
  113. set:
  114. certController.image.repository: ghcr.io/external-secrets/external-secrets
  115. certController.image.tag: v0.9.8
  116. certController.image.flavour: ubi-boringssl
  117. templates:
  118. - cert-controller-deployment.yaml
  119. asserts:
  120. - equal:
  121. path: spec.template.spec.containers[0].image
  122. value: ghcr.io/external-secrets/external-secrets:v0.9.8-ubi-boringssl
  123. - it: should override image flavour
  124. set:
  125. certController.image.repository: example.com/external-secrets/external-secrets
  126. certController.image.tag: v0.9.9-ubi
  127. templates:
  128. - cert-controller-deployment.yaml
  129. asserts:
  130. - equal:
  131. path: spec.template.spec.containers[0].image
  132. value: example.com/external-secrets/external-secrets:v0.9.9-ubi
  133. - it: should render service without metrics label when metrics is enabled
  134. set:
  135. certController.metrics.service.enabled: true
  136. templates:
  137. - cert-controller-service.yaml
  138. asserts:
  139. - hasDocuments:
  140. count: 1
  141. - isNull:
  142. path: metadata.labels["app.kubernetes.io/metrics"]
  143. - it: should render service with metrics label when APIVersions are present and serviceMonitor is enabled
  144. set:
  145. serviceMonitor.enabled: true
  146. capabilities:
  147. apiVersions:
  148. - "monitoring.coreos.com/v1/ServiceMonitor"
  149. templates:
  150. - cert-controller-service.yaml
  151. asserts:
  152. - hasDocuments:
  153. count: 1
  154. - equal:
  155. path: metadata.labels["app.kubernetes.io/metrics"]
  156. value: "cert-controller"
  157. - it: should render service with metrics label when APIVersions are not present, serviceMonitor is enabled, and serviceMonitor.renderMode is alwaysRender
  158. set:
  159. serviceMonitor.enabled: true
  160. serviceMonitor.renderMode: alwaysRender
  161. templates:
  162. - cert-controller-service.yaml
  163. asserts:
  164. - hasDocuments:
  165. count: 1
  166. - equal:
  167. path: metadata.labels["app.kubernetes.io/metrics"]
  168. value: "cert-controller"
  169. - it: should fail if APIVersions is missing, serviceMonitor is enabled, and serviceMonitor.renderMode is failIfMissing
  170. set:
  171. serviceMonitor.enabled: true
  172. serviceMonitor.renderMode: failIfMissing
  173. templates:
  174. - cert-controller-service.yaml
  175. asserts:
  176. - failedTemplate: {}
  177. - it: should not render service when APIVersions is not present, serviceMonitor is enabled, and and serviceMonitor.renderMode is skipIfMissing
  178. set:
  179. serviceMonitor.enabled: true
  180. serviceMonitor.renderMode: skipIfMissing
  181. templates:
  182. - cert-controller-service.yaml
  183. asserts:
  184. - hasDocuments:
  185. count: 0
  186. - it: should not render service when APIVersions is not present but serviceMonitor is enabled
  187. set:
  188. serviceMonitor.enabled: true
  189. templates:
  190. - cert-controller-service.yaml
  191. asserts:
  192. - hasDocuments:
  193. count: 0
  194. - it: should not render service when APIVersions is present and serviceMonitor is disabled
  195. set:
  196. serviceMonitor.enabled: false
  197. capabilities:
  198. apiVersions:
  199. - "monitoring.coreos.com/v1/ServiceMonitor"
  200. templates:
  201. - cert-controller-service.yaml
  202. asserts:
  203. - hasDocuments:
  204. count: 0
  205. - it: should not render service when APIVersions is not present and serviceMonitor is disabled
  206. set:
  207. serviceMonitor.enabled: false
  208. templates:
  209. - cert-controller-service.yaml
  210. asserts:
  211. - hasDocuments:
  212. count: 0
  213. - it: should not have enableHTTP2 flag by default
  214. templates:
  215. - cert-controller-deployment.yaml
  216. asserts:
  217. - notContains:
  218. path: spec.template.spec.containers[0].args
  219. content: "--enable-http2"
  220. - it: should have startup Probe if enabled
  221. set:
  222. certController.startupProbe.enabled: true
  223. templates:
  224. - cert-controller-deployment.yaml
  225. asserts:
  226. - equal:
  227. path: spec.template.spec.containers[0].startupProbe
  228. value:
  229. httpGet:
  230. path: /readyz
  231. port: 8081
  232. initialDelaySeconds: 20
  233. periodSeconds: 5
  234. - it: should override the startup Probe port
  235. set:
  236. certController.startupProbe.enabled: true
  237. certController.startupProbe.useReadinessProbePort: false
  238. certController.startupProbe.port: "8083"
  239. templates:
  240. - cert-controller-deployment.yaml
  241. asserts:
  242. - equal:
  243. path: spec.template.spec.containers[0].startupProbe
  244. value:
  245. httpGet:
  246. port: 8083
  247. path: /readyz
  248. initialDelaySeconds: 20
  249. periodSeconds: 5