|
| 1 | +{{- $certManagerEnabled := .Values.webhook.certManager.enabled -}} |
| 2 | +{{- $caCertPEM := include "webhook.caBundleCertPEM" . -}} |
| 3 | +{{- $tlsCertPEM := include "webhook.certPEM" . -}} |
| 4 | +{{- $tlsKeyPEM := include "webhook.keyPEM" . -}} |
| 5 | + |
| 6 | +apiVersion: admissionregistration.k8s.io/v1 |
| 7 | +kind: ValidatingWebhookConfiguration |
| 8 | +metadata: |
| 9 | + creationTimestamp: null |
| 10 | + name: {{ template "validating-webhook-configuration.name" . }} |
| 11 | + {{- if $certManagerEnabled }} |
| 12 | + annotations: |
| 13 | + cert-manager.io/inject-ca-from: "{{ .Release.Namespace }}/{{ template "certificate.name" . }}" |
| 14 | + {{- end }} |
| 15 | +webhooks: |
| 16 | +- admissionReviewVersions: |
| 17 | + - v1 |
| 18 | + clientConfig: |
| 19 | + {{- if $certManagerEnabled }} |
| 20 | + caBundle: Cg== |
| 21 | + {{- else }} |
| 22 | + caBundle: {{ ternary (b64enc $caCertPEM) (b64enc (trim $tlsCertPEM)) (empty $tlsKeyPEM) }} |
| 23 | + {{- end }} |
| 24 | + service: |
| 25 | + name: {{ template "webhook.name" .}} |
| 26 | + namespace: {{ .Release.Namespace }} |
| 27 | + ## path is generated by controller-runtime. |
| 28 | + ## https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/builder/webhook.go#L206 |
| 29 | + path: /validate-mysql-radondb-com-v1alpha1-mysqlcluster |
| 30 | + failurePolicy: Fail |
| 31 | + name: vmysqlcluster.kb.io |
| 32 | + rules: |
| 33 | + - apiGroups: |
| 34 | + - mysql.radondb.com |
| 35 | + apiVersions: |
| 36 | + - v1alpha1 |
| 37 | + operations: |
| 38 | + - CREATE |
| 39 | + - UPDATE |
| 40 | + resources: |
| 41 | + - mysqlclusters |
| 42 | + sideEffects: None |
| 43 | +--- |
| 44 | + |
| 45 | +apiVersion: v1 |
| 46 | +kind: Service |
| 47 | +metadata: |
| 48 | + name: {{ template "webhook.name" .}} |
| 49 | + namespace: {{ .Release.Namespace }} |
| 50 | +spec: |
| 51 | + ports: |
| 52 | + - port: 443 |
| 53 | + protocol: TCP |
| 54 | + targetPort: 9443 |
| 55 | + selector: |
| 56 | + app: {{ template "mysql-operator.name" . }} |
| 57 | + |
| 58 | +--- |
| 59 | +{{- if not $certManagerEnabled }} |
| 60 | +kind: Secret |
| 61 | +apiVersion: v1 |
| 62 | +metadata: |
| 63 | + name: {{ template "webhook.name" . }}-certs |
| 64 | + namespace: {{ .Release.Namespace | quote }} |
| 65 | + labels: |
| 66 | + {{- include "mysql-operator.labels" . | nindent 4 }} |
| 67 | + app.kubernetes.io/component: webhook-secret |
| 68 | +type: Opaque |
| 69 | +data: |
| 70 | + ca.crt: {{ b64enc $caCertPEM }} |
| 71 | + tls.crt: {{ b64enc $tlsCertPEM }} |
| 72 | + tls.key: {{ b64enc $tlsKeyPEM }} |
| 73 | +{{- end }} |
0 commit comments