controller_test.yaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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 render leader election timing args when set
  229. set:
  230. leaderElectionLeaseDuration: 60s
  231. leaderElectionRenewDeadline: 40s
  232. leaderElectionRetryPeriod: 5s
  233. asserts:
  234. - contains:
  235. path: spec.template.spec.containers[0].args
  236. content: "--leader-election-lease-duration=60s"
  237. - contains:
  238. path: spec.template.spec.containers[0].args
  239. content: "--leader-election-renew-deadline=40s"
  240. - contains:
  241. path: spec.template.spec.containers[0].args
  242. content: "--leader-election-retry-period=5s"
  243. - it: should not render leader election timing args by default
  244. asserts:
  245. - notContains:
  246. path: spec.template.spec.containers[0].args
  247. content: "--leader-election-lease-duration=15s"
  248. - notContains:
  249. path: spec.template.spec.containers[0].args
  250. content: "--leader-election-renew-deadline=10s"
  251. - notContains:
  252. path: spec.template.spec.containers[0].args
  253. content: "--leader-election-retry-period=2s"
  254. - it: should default to hostUsers absent
  255. capabilities:
  256. majorVersion: '1'
  257. minorVersion: '33'
  258. asserts:
  259. - notExists:
  260. path: spec.template.spec.hostUsers
  261. - it: should permit override of hostUsers
  262. capabilities:
  263. majorVersion: '1'
  264. minorVersion: '33'
  265. set:
  266. hostUsers: false
  267. asserts:
  268. - equal:
  269. path: spec.template.spec.hostUsers
  270. value: false
  271. - it: should ignore hostUsers on older k8s
  272. capabilities:
  273. majorVersion: '1'
  274. minorVersion: '32'
  275. set:
  276. hostUsers: false
  277. asserts:
  278. - notExists:
  279. path: spec.template.spec.hostUsers
  280. - it: should not have hostAliases by default
  281. asserts:
  282. - notExists:
  283. path: spec.template.spec.hostAliases
  284. - it: should add hostAliases when configured
  285. set:
  286. hostAliases:
  287. - ip: "192.168.1.100"
  288. hostnames:
  289. - "example.local"
  290. - "example"
  291. - ip: "10.0.0.1"
  292. hostnames:
  293. - "internal.example.com"
  294. asserts:
  295. - equal:
  296. path: spec.template.spec.hostAliases
  297. value:
  298. - ip: "192.168.1.100"
  299. hostnames:
  300. - "example.local"
  301. - "example"
  302. - ip: "10.0.0.1"
  303. hostnames:
  304. - "internal.example.com"
  305. - it: should use global hostAliases when root level not set
  306. set:
  307. global:
  308. hostAliases:
  309. - ip: "192.168.1.200"
  310. hostnames:
  311. - "global.example.com"
  312. asserts:
  313. - equal:
  314. path: spec.template.spec.hostAliases
  315. value:
  316. - ip: "192.168.1.200"
  317. hostnames:
  318. - "global.example.com"
  319. - it: should prefer root level hostAliases over global
  320. set:
  321. hostAliases:
  322. - ip: "192.168.1.100"
  323. hostnames:
  324. - "root.example.com"
  325. global:
  326. hostAliases:
  327. - ip: "192.168.1.200"
  328. hostnames:
  329. - "global.example.com"
  330. asserts:
  331. - equal:
  332. path: spec.template.spec.hostAliases
  333. value:
  334. - ip: "192.168.1.100"
  335. hostnames:
  336. - "root.example.com"
  337. - it: should add readinessProbe with defaults when enabled
  338. set:
  339. readinessProbe:
  340. enabled: true
  341. asserts:
  342. - equal:
  343. path: spec.template.spec.containers[0].readinessProbe
  344. value:
  345. timeoutSeconds: 5
  346. failureThreshold: 3
  347. periodSeconds: 10
  348. successThreshold: 1
  349. initialDelaySeconds: 10
  350. httpGet:
  351. port: live
  352. path: /readyz
  353. - equal:
  354. path: spec.template.spec.containers[0].ports[1]
  355. value:
  356. containerPort: 8082
  357. protocol: TCP
  358. name: live
  359. - contains:
  360. path: spec.template.spec.containers[0].args
  361. content: "--live-addr=:8082"
  362. - notExists:
  363. path: spec.template.spec.containers[0].livenessProbe
  364. - it: should not render probes or health server when both probes are disabled
  365. asserts:
  366. - notExists:
  367. path: spec.template.spec.containers[0].livenessProbe
  368. - notExists:
  369. path: spec.template.spec.containers[0].readinessProbe
  370. - notContains:
  371. path: spec.template.spec.containers[0].args
  372. content: "--live-addr=:8082"
  373. - it: should render both probes when both are enabled
  374. set:
  375. livenessProbe:
  376. enabled: true
  377. readinessProbe:
  378. enabled: true
  379. asserts:
  380. - equal:
  381. path: spec.template.spec.containers[0].livenessProbe
  382. value:
  383. timeoutSeconds: 5
  384. failureThreshold: 5
  385. periodSeconds: 10
  386. successThreshold: 1
  387. initialDelaySeconds: 10
  388. httpGet:
  389. port: live
  390. path: /healthz
  391. - equal:
  392. path: spec.template.spec.containers[0].readinessProbe
  393. value:
  394. timeoutSeconds: 5
  395. failureThreshold: 3
  396. periodSeconds: 10
  397. successThreshold: 1
  398. initialDelaySeconds: 10
  399. httpGet:
  400. port: live
  401. path: /readyz
  402. - contains:
  403. path: spec.template.spec.containers[0].args
  404. content: "--live-addr=:8082"
  405. - it: should use livenessProbe.spec.port for health server even when only readiness is enabled
  406. set:
  407. livenessProbe:
  408. spec:
  409. port: 9090
  410. readinessProbe:
  411. enabled: true
  412. asserts:
  413. - contains:
  414. path: spec.template.spec.containers[0].args
  415. content: "--live-addr=:9090"
  416. - equal:
  417. path: spec.template.spec.containers[0].ports[1]
  418. value:
  419. containerPort: 9090
  420. protocol: TCP
  421. name: live
  422. - notExists:
  423. path: spec.template.spec.containers[0].livenessProbe
  424. - it: should use numeric httpGet.port for health server when liveness httpGet.port is numeric
  425. set:
  426. livenessProbe:
  427. enabled: true
  428. spec:
  429. httpGet:
  430. port: 8080
  431. path: /healthz
  432. readinessProbe:
  433. enabled: true
  434. asserts:
  435. - contains:
  436. path: spec.template.spec.containers[0].args
  437. content: "--live-addr=:8080"
  438. - equal:
  439. path: spec.template.spec.containers[0].ports[1]
  440. value:
  441. containerPort: 8080
  442. protocol: TCP
  443. name: live
  444. - it: should use custom address for health server
  445. set:
  446. livenessProbe:
  447. enabled: true
  448. spec:
  449. address: "127.0.0.1"
  450. asserts:
  451. - contains:
  452. path: spec.template.spec.containers[0].args
  453. content: "--live-addr=127.0.0.1:8082"
  454. - it: should customize readinessProbe spec independently
  455. set:
  456. readinessProbe:
  457. enabled: true
  458. spec:
  459. timeoutSeconds: 3
  460. failureThreshold: 5
  461. periodSeconds: 15
  462. successThreshold: 2
  463. initialDelaySeconds: 20
  464. httpGet:
  465. port: live
  466. path: /readyz
  467. asserts:
  468. - equal:
  469. path: spec.template.spec.containers[0].readinessProbe
  470. value:
  471. timeoutSeconds: 3
  472. failureThreshold: 5
  473. periodSeconds: 15
  474. successThreshold: 2
  475. initialDelaySeconds: 20
  476. httpGet:
  477. port: live
  478. path: /readyz
  479. - it: should always render args with unconditional entries
  480. set:
  481. leaderElect: false
  482. scopedNamespace: ""
  483. scopedRBAC: false
  484. processClusterStore: false
  485. processClusterExternalSecret: false
  486. processClusterPushSecret: false
  487. concurrent: 0
  488. extraArgs: {}
  489. asserts:
  490. - exists:
  491. path: spec.template.spec.containers[0].args
  492. - contains:
  493. path: spec.template.spec.containers[0].args
  494. content: "--metrics-addr=:8080"
  495. - contains:
  496. path: spec.template.spec.containers[0].args
  497. content: "--loglevel=info"
  498. - contains:
  499. path: spec.template.spec.containers[0].args
  500. content: "--zap-time-encoding=epoch"
  501. - it: should omit store-requeue-interval flag by default
  502. asserts:
  503. - notContains:
  504. path: spec.template.spec.containers[0].args
  505. content: "--store-requeue-interval"
  506. - it: should render store-requeue-interval flag when set
  507. set:
  508. storeRequeueInterval: "30s"
  509. asserts:
  510. - contains:
  511. path: spec.template.spec.containers[0].args
  512. content: "--store-requeue-interval=30s"