validating-webhook-configuration.yaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. {{- $cert := "Cg==" }}
  2. {{- $certSecret := lookup "v1" "Secret" .Release.Namespace (include "cert-name" .) }}
  3. {{- if $certSecret }}
  4. {{- if (index ($certSecret.data) "tls.crt") }}
  5. {{- $cert = (index $certSecret.data "tls.crt") }}
  6. {{- end }}
  7. {{- end }}
  8. apiVersion: admissionregistration.k8s.io/v1
  9. kind: ValidatingWebhookConfiguration
  10. metadata:
  11. {{- with .Values.clusterOwnerRefereces }}
  12. ownerReferences:
  13. {{- toYaml . | nindent 4 }}
  14. {{- end }}
  15. name: {{ .Release.Name }}
  16. namespace: {{ .Release.Namespace }}
  17. {{- with (.Values.webhooks).annotations }}
  18. annotations:
  19. {{ toYaml . | nindent 4 }}
  20. {{- end }}
  21. webhooks:
  22. - name: sgcluster.validating-webhook.stackgres.io
  23. sideEffects: None
  24. rules:
  25. - operations: ["CREATE", "UPDATE"]
  26. apiGroups: ["stackgres.io"]
  27. apiVersions: ["*"]
  28. resources: ["sgclusters"]
  29. failurePolicy: Fail
  30. clientConfig:
  31. service:
  32. namespace: {{ .Release.Namespace }}
  33. name: {{ .Release.Name }}
  34. path: '/stackgres/validation/sgcluster'
  35. caBundle: {{ $cert }}
  36. admissionReviewVersions: ["v1"]
  37. {{- if .Values.allowedNamespaces }}
  38. namespaceSelector:
  39. matchLabels:
  40. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  41. {{- else if .Values.allowedNamespaceLabelSelector }}
  42. namespaceSelector:
  43. matchLabels:
  44. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  45. {{- end }}
  46. - name: sgpgconfig.validating-webhook.stackgres.io
  47. sideEffects: None
  48. rules:
  49. - operations: ["CREATE", "UPDATE", "DELETE"]
  50. apiGroups: ["stackgres.io"]
  51. apiVersions: ["*"]
  52. resources: ["sgpgconfigs"]
  53. failurePolicy: Fail
  54. clientConfig:
  55. service:
  56. namespace: {{ .Release.Namespace }}
  57. name: {{ .Release.Name }}
  58. path: '/stackgres/validation/sgpgconfig'
  59. caBundle: {{ $cert }}
  60. admissionReviewVersions: ["v1"]
  61. {{- if .Values.allowedNamespaces }}
  62. namespaceSelector:
  63. matchLabels:
  64. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  65. {{- else if .Values.allowedNamespaceLabelSelector }}
  66. namespaceSelector:
  67. matchLabels:
  68. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  69. {{- end }}
  70. - name: sgpoolconfig.validating-webhook.stackgres.io
  71. sideEffects: None
  72. rules:
  73. - operations: ["CREATE", "UPDATE", "DELETE"]
  74. apiGroups: ["stackgres.io"]
  75. apiVersions: ["*"]
  76. resources: ["sgpoolconfigs"]
  77. failurePolicy: Fail
  78. clientConfig:
  79. service:
  80. namespace: {{ .Release.Namespace }}
  81. name: {{ .Release.Name }}
  82. path: '/stackgres/validation/sgpoolconfig'
  83. caBundle: {{ $cert }}
  84. admissionReviewVersions: ["v1"]
  85. {{- if .Values.allowedNamespaces }}
  86. namespaceSelector:
  87. matchLabels:
  88. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  89. {{- else if .Values.allowedNamespaceLabelSelector }}
  90. namespaceSelector:
  91. matchLabels:
  92. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  93. {{- end }}
  94. - name: sginstanceprofile.validating-webhook.stackgres.io
  95. sideEffects: None
  96. rules:
  97. - operations: ["CREATE", "UPDATE", "DELETE"]
  98. apiGroups: ["stackgres.io"]
  99. apiVersions: ["*"]
  100. resources: ["sginstanceprofiles"]
  101. failurePolicy: Fail
  102. clientConfig:
  103. service:
  104. namespace: {{ .Release.Namespace }}
  105. name: {{ .Release.Name }}
  106. path: '/stackgres/validation/sginstanceprofile'
  107. caBundle: {{ $cert }}
  108. admissionReviewVersions: ["v1"]
  109. {{- if .Values.allowedNamespaces }}
  110. namespaceSelector:
  111. matchLabels:
  112. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  113. {{- else if .Values.allowedNamespaceLabelSelector }}
  114. namespaceSelector:
  115. matchLabels:
  116. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  117. {{- end }}
  118. - name: sgbackupconfig.validating-webhook.stackgres.io
  119. sideEffects: None
  120. rules:
  121. - operations: ["CREATE", "UPDATE", "DELETE"]
  122. apiGroups: ["stackgres.io"]
  123. apiVersions: ["*"]
  124. resources: ["sgbackupconfigs"]
  125. failurePolicy: Fail
  126. clientConfig:
  127. service:
  128. namespace: {{ .Release.Namespace }}
  129. name: {{ .Release.Name }}
  130. path: '/stackgres/validation/sgbackupconfig'
  131. caBundle: {{ $cert }}
  132. admissionReviewVersions: ["v1"]
  133. {{- if .Values.allowedNamespaces }}
  134. namespaceSelector:
  135. matchLabels:
  136. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  137. {{- else if .Values.allowedNamespaceLabelSelector }}
  138. namespaceSelector:
  139. matchLabels:
  140. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  141. {{- end }}
  142. - name: sgbackup.validating-webhook.stackgres.io
  143. sideEffects: None
  144. rules:
  145. - operations: ["CREATE", "UPDATE", "DELETE"]
  146. apiGroups: ["stackgres.io"]
  147. apiVersions: ["*"]
  148. resources: ["sgbackups"]
  149. failurePolicy: Fail
  150. clientConfig:
  151. service:
  152. namespace: {{ .Release.Namespace }}
  153. name: {{ .Release.Name }}
  154. path: '/stackgres/validation/sgbackup'
  155. caBundle: {{ $cert }}
  156. admissionReviewVersions: ["v1"]
  157. {{- if .Values.allowedNamespaces }}
  158. namespaceSelector:
  159. matchLabels:
  160. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  161. {{- else if .Values.allowedNamespaceLabelSelector }}
  162. namespaceSelector:
  163. matchLabels:
  164. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  165. {{- end }}
  166. - name: sgdistributedlogs.validating-webhook.stackgres.io
  167. sideEffects: None
  168. rules:
  169. - operations: ["CREATE", "UPDATE", "DELETE"]
  170. apiGroups: ["stackgres.io"]
  171. apiVersions: ["*"]
  172. resources: ["sgdistributedlogs"]
  173. failurePolicy: Fail
  174. clientConfig:
  175. service:
  176. namespace: {{ .Release.Namespace }}
  177. name: {{ .Release.Name }}
  178. path: '/stackgres/validation/sgdistributedlogs'
  179. caBundle: {{ $cert }}
  180. admissionReviewVersions: ["v1"]
  181. {{- if .Values.allowedNamespaces }}
  182. namespaceSelector:
  183. matchLabels:
  184. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  185. {{- else if .Values.allowedNamespaceLabelSelector }}
  186. namespaceSelector:
  187. matchLabels:
  188. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  189. {{- end }}
  190. - name: sgdbops.validating-webhook.stackgres.io
  191. sideEffects: None
  192. rules:
  193. - operations: ["CREATE", "UPDATE", "DELETE"]
  194. apiGroups: ["stackgres.io"]
  195. apiVersions: ["*"]
  196. resources: ["sgdbops"]
  197. failurePolicy: Fail
  198. clientConfig:
  199. service:
  200. namespace: {{ .Release.Namespace }}
  201. name: {{ .Release.Name }}
  202. path: '/stackgres/validation/sgdbops'
  203. caBundle: {{ $cert }}
  204. admissionReviewVersions: ["v1"]
  205. {{- if .Values.allowedNamespaces }}
  206. namespaceSelector:
  207. matchLabels:
  208. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  209. {{- else if .Values.allowedNamespaceLabelSelector }}
  210. namespaceSelector:
  211. matchLabels:
  212. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  213. {{- end }}
  214. - name: sgobjectstorage.validating-webhook.stackgres.io
  215. sideEffects: None
  216. rules:
  217. - operations: ["CREATE", "UPDATE", "DELETE"]
  218. apiGroups: ["stackgres.io"]
  219. apiVersions: ["*"]
  220. resources: ["sgobjectstorages"]
  221. failurePolicy: Fail
  222. clientConfig:
  223. service:
  224. namespace: {{ .Release.Namespace }}
  225. name: {{ .Release.Name }}
  226. path: '/stackgres/validation/sgobjectstorage'
  227. caBundle: {{ $cert }}
  228. admissionReviewVersions: ["v1"]
  229. {{- if .Values.allowedNamespaces }}
  230. namespaceSelector:
  231. matchLabels:
  232. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  233. {{- else if .Values.allowedNamespaceLabelSelector }}
  234. namespaceSelector:
  235. matchLabels:
  236. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  237. {{- end }}
  238. - name: sgscripts.validating-webhook.stackgres.io
  239. sideEffects: None
  240. rules:
  241. - operations: ["CREATE", "UPDATE", "DELETE"]
  242. apiGroups: ["stackgres.io"]
  243. apiVersions: ["*"]
  244. resources: ["sgscripts"]
  245. failurePolicy: Fail
  246. clientConfig:
  247. service:
  248. namespace: {{ .Release.Namespace }}
  249. name: {{ .Release.Name }}
  250. path: '/stackgres/validation/sgscript'
  251. caBundle: {{ $cert }}
  252. admissionReviewVersions: ["v1"]
  253. {{- if .Values.allowedNamespaces }}
  254. namespaceSelector:
  255. matchLabels:
  256. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  257. {{- else if .Values.allowedNamespaceLabelSelector }}
  258. namespaceSelector:
  259. matchLabels:
  260. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  261. {{- end }}
  262. - name: sgshardedclusters.validating-webhook.stackgres.io
  263. sideEffects: None
  264. rules:
  265. - operations: ["CREATE", "UPDATE", "DELETE"]
  266. apiGroups: ["stackgres.io"]
  267. apiVersions: ["*"]
  268. resources: ["sgshardedclusters"]
  269. failurePolicy: Fail
  270. clientConfig:
  271. service:
  272. namespace: {{ .Release.Namespace }}
  273. name: {{ .Release.Name }}
  274. path: '/stackgres/validation/sgshardedcluster'
  275. caBundle: {{ $cert }}
  276. admissionReviewVersions: ["v1"]
  277. {{- if .Values.allowedNamespaces }}
  278. namespaceSelector:
  279. matchLabels:
  280. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  281. {{- else if .Values.allowedNamespaceLabelSelector }}
  282. namespaceSelector:
  283. matchLabels:
  284. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  285. {{- end }}
  286. - name: sgshardedbackups.validating-webhook.stackgres.io
  287. sideEffects: None
  288. rules:
  289. - operations: ["CREATE", "UPDATE", "DELETE"]
  290. apiGroups: ["stackgres.io"]
  291. apiVersions: ["*"]
  292. resources: ["sgshardedbackups"]
  293. failurePolicy: Fail
  294. clientConfig:
  295. service:
  296. namespace: {{ .Release.Namespace }}
  297. name: {{ .Release.Name }}
  298. path: '/stackgres/validation/sgshardedbackup'
  299. caBundle: {{ $cert }}
  300. admissionReviewVersions: ["v1"]
  301. {{- if .Values.allowedNamespaces }}
  302. namespaceSelector:
  303. matchLabels:
  304. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  305. {{- else if .Values.allowedNamespaceLabelSelector }}
  306. namespaceSelector:
  307. matchLabels:
  308. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  309. {{- end }}
  310. - name: sgshardeddbops.validating-webhook.stackgres.io
  311. sideEffects: None
  312. rules:
  313. - operations: ["CREATE", "UPDATE", "DELETE"]
  314. apiGroups: ["stackgres.io"]
  315. apiVersions: ["*"]
  316. resources: ["sgshardeddbops"]
  317. failurePolicy: Fail
  318. clientConfig:
  319. service:
  320. namespace: {{ .Release.Namespace }}
  321. name: {{ .Release.Name }}
  322. path: '/stackgres/validation/sgshardeddbops'
  323. caBundle: {{ $cert }}
  324. admissionReviewVersions: ["v1"]
  325. {{- if .Values.allowedNamespaces }}
  326. namespaceSelector:
  327. matchLabels:
  328. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  329. {{- else if .Values.allowedNamespaceLabelSelector }}
  330. namespaceSelector:
  331. matchLabels:
  332. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  333. {{- end }}
  334. - name: sgstreams.validating-webhook.stackgres.io
  335. sideEffects: None
  336. rules:
  337. - operations: ["CREATE", "UPDATE", "DELETE"]
  338. apiGroups: ["stackgres.io"]
  339. apiVersions: ["*"]
  340. resources: ["sgstreams"]
  341. failurePolicy: Fail
  342. clientConfig:
  343. service:
  344. namespace: {{ .Release.Namespace }}
  345. name: {{ .Release.Name }}
  346. path: '/stackgres/validation/sgstreams'
  347. caBundle: {{ $cert }}
  348. admissionReviewVersions: ["v1"]
  349. {{- if .Values.allowedNamespaces }}
  350. namespaceSelector:
  351. matchLabels:
  352. stackgres.io/scope: {{ .Release.Namespace }}.{{ .Release.Name }}
  353. {{- else if .Values.allowedNamespaceLabelSelector }}
  354. namespaceSelector:
  355. matchLabels:
  356. {{ toYaml .Values.allowedNamespaceLabelSelector | nindent 8 }}
  357. {{- end }}