webhook_test.yaml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. suite: test webhook deployment
  2. templates:
  3. - webhook-deployment.yaml
  4. - webhook-secret.yaml
  5. - webhook-certificate.yaml
  6. - validatingwebhook.yaml
  7. - crds/externalsecret.yaml
  8. tests:
  9. - it: should match snapshot of default values
  10. asserts:
  11. - matchSnapshot: {}
  12. templates:
  13. - webhook-deployment.yaml
  14. - webhook-secret.yaml
  15. # webhook-certificate.yaml is not rendered by default
  16. - it: should set imagePullPolicy to Always
  17. set:
  18. webhook.image.pullPolicy: Always
  19. asserts:
  20. - equal:
  21. path: spec.template.spec.containers[0].imagePullPolicy
  22. value: Always
  23. template: webhook-deployment.yaml
  24. - it: should imagePullPolicy to be default value IfNotPresent
  25. asserts:
  26. - equal:
  27. path: spec.template.spec.containers[0].imagePullPolicy
  28. value: IfNotPresent
  29. template: webhook-deployment.yaml
  30. - it: should override securityContext
  31. set:
  32. webhook.podSecurityContext:
  33. runAsUser: 2000
  34. webhook.securityContext:
  35. runAsUser: 3000
  36. asserts:
  37. - equal:
  38. path: spec.template.spec.securityContext
  39. value:
  40. runAsUser: 2000
  41. - equal:
  42. path: spec.template.spec.containers[0].securityContext
  43. value:
  44. allowPrivilegeEscalation: false
  45. capabilities:
  46. drop:
  47. - ALL
  48. readOnlyRootFilesystem: true
  49. runAsNonRoot: true
  50. runAsUser: 3000
  51. seccompProfile:
  52. type: RuntimeDefault
  53. template: webhook-deployment.yaml
  54. - it: should override hostNetwork
  55. set:
  56. webhook.hostNetwork: true
  57. asserts:
  58. - equal:
  59. path: spec.template.spec.hostNetwork
  60. value: true
  61. template: webhook-deployment.yaml
  62. - it: should create a certificate CRD
  63. set:
  64. webhook.certManager.enabled: true
  65. webhook.certManager.cert.duration: "10d"
  66. webhook.certManager.cert.renewBefore: "5d"
  67. asserts:
  68. - equal:
  69. path: metadata.name
  70. value: "RELEASE-NAME-external-secrets-webhook"
  71. - equal:
  72. path: spec.secretName
  73. value: "RELEASE-NAME-external-secrets-webhook"
  74. - equal:
  75. path: spec.commonName
  76. value: "RELEASE-NAME-external-secrets-webhook"
  77. - equal:
  78. path: spec.dnsNames[0]
  79. value: "RELEASE-NAME-external-secrets-webhook"
  80. - equal:
  81. path: spec.issuerRef.group
  82. value: "cert-manager.io"
  83. - equal:
  84. path: spec.issuerRef.kind
  85. value: "Issuer"
  86. - equal:
  87. path: spec.issuerRef.name
  88. value: "my-issuer"
  89. - equal:
  90. path: spec.duration
  91. value: "10d"
  92. - equal:
  93. path: spec.renewBefore
  94. value: "5d"
  95. - hasDocuments:
  96. count: 1
  97. templates:
  98. - webhook-certificate.yaml
  99. - it: should not create the webhook secret
  100. set:
  101. webhook.certManager.enabled: true
  102. asserts:
  103. - hasDocuments:
  104. count: 0
  105. template: webhook-secret.yaml
  106. - it: should not create the secret nor the certificate
  107. set:
  108. webhook.certManager.enabled: true
  109. webhook.certManager.cert.create: false
  110. asserts:
  111. - hasDocuments:
  112. count: 0
  113. templates:
  114. - webhook-secret.yaml
  115. - webhook-certificate.yaml
  116. - it: should
  117. set:
  118. webhook.certManager.enabled: true
  119. asserts:
  120. - equal:
  121. path: metadata.name
  122. value: "RELEASE-NAME-external-secrets-webhook"
  123. - hasDocuments:
  124. count: 1
  125. template: webhook-certificate.yaml
  126. - it: should allow using a cluster issuer
  127. set:
  128. webhook.certManager.enabled: true
  129. webhook.certManager.cert.issuerRef.kind: ClusterIssuer
  130. webhook.certManager.cert.issuerRef.name: my-other-issuer
  131. asserts:
  132. - equal:
  133. path: spec.issuerRef.kind
  134. value: "ClusterIssuer"
  135. - equal:
  136. path: spec.issuerRef.name
  137. value: "my-other-issuer"
  138. templates:
  139. - webhook-certificate.yaml
  140. - it: should add annotations to the webhook
  141. set:
  142. webhook.create: true
  143. webhook.certManager.enabled: true
  144. webhook.certManager.addInjectorAnnotations: true
  145. asserts:
  146. - equal:
  147. path: metadata.annotations["cert-manager.io/inject-ca-from"]
  148. value: "NAMESPACE/RELEASE-NAME-external-secrets-webhook"
  149. templates:
  150. - validatingwebhook.yaml
  151. - crds/externalsecret.yaml
  152. - it: should not add annotations to the webhook
  153. set:
  154. webhook.create: true
  155. webhook.certManager.enabled: true
  156. webhook.certManager.addInjectorAnnotations: false
  157. asserts:
  158. - isNull:
  159. path: metadata.annotations["cert-manager.io/inject-ca-from"]
  160. # value: "NAMESPACE/RELEASE-NAME-external-secrets-webhook"
  161. templates:
  162. - validatingwebhook.yaml
  163. - crds/externalsecret.yaml
  164. - it: should override metrics port
  165. set:
  166. webhook.metrics.listen.port: 8888
  167. templates:
  168. - webhook-deployment.yaml
  169. asserts:
  170. - equal:
  171. path: spec.template.spec.containers[0].args[5]
  172. value: "--metrics-addr=:8888"
  173. - it: should override image flavour
  174. set:
  175. webhook.image.repository: ghcr.io/external-secrets/external-secrets
  176. webhook.image.tag: v0.9.8
  177. webhook.image.flavour: ubi-boringssl
  178. templates:
  179. - webhook-deployment.yaml
  180. asserts:
  181. - equal:
  182. path: spec.template.spec.containers[0].image
  183. value: ghcr.io/external-secrets/external-secrets:v0.9.8-ubi-boringssl
  184. - it: should override image flavour
  185. set:
  186. webhook.image.repository: example.com/external-secrets/external-secrets
  187. webhook.image.tag: v0.9.9-ubi
  188. templates:
  189. - webhook-deployment.yaml
  190. asserts:
  191. - equal:
  192. path: spec.template.spec.containers[0].image
  193. value: example.com/external-secrets/external-secrets:v0.9.9-ubi