|
| 1 | +{{- if .Values.webhook.enabled }} |
| 2 | +{{- $certCert := "" -}} |
| 3 | +{{- $certKey := "" -}} |
| 4 | +{{- $caCert := "" -}} |
| 5 | +{{- if not .Values.webhook.certificate.provided }} |
| 6 | +{{- $cn := printf "%s.%s.svc" (include "api7-ingress-controller-manager.webhook.serviceName" .) .Release.Namespace -}} |
| 7 | +{{- $ca := genCA "api7-ingress-webhook-ca" 3650 -}} |
| 8 | +{{- $cert := genSignedCert $cn nil (list $cn) 3650 $ca -}} |
| 9 | +{{- $certCert = $cert.Cert -}} |
| 10 | +{{- $certKey = $cert.Key -}} |
| 11 | +{{- $caCert = $ca.Cert -}} |
| 12 | + |
| 13 | +{{- $certSecret := (lookup "v1" "Secret" .Release.Namespace (include "api7-ingress-controller-manager.webhook.secretName" .)) -}} |
| 14 | +{{- if $certSecret }} |
| 15 | +{{- $certCert = (b64dec (get $certSecret.data "tls.crt")) -}} |
| 16 | +{{- $certKey = (b64dec (get $certSecret.data "tls.key")) -}} |
| 17 | +{{- $caCert = (b64dec (get $certSecret.data "ca.crt")) -}} |
| 18 | +{{- end }} |
| 19 | +{{- end }} |
| 20 | + |
| 21 | +--- |
| 22 | +apiVersion: admissionregistration.k8s.io/v1 |
| 23 | +kind: ValidatingWebhookConfiguration |
| 24 | +metadata: |
| 25 | + name: {{ include "api7-ingress-controller-manager.name.fullname" . }}-webhook |
| 26 | + labels: |
| 27 | + {{- include "api7-ingress-controller-manager.labels" . | nindent 4 }} |
| 28 | +webhooks: |
| 29 | +- name: vapisixroute-v2.kb.io |
| 30 | + admissionReviewVersions: ["v1"] |
| 31 | + clientConfig: |
| 32 | + {{- if not .Values.webhook.certificate.provided }} |
| 33 | + caBundle: {{ b64enc $caCert }} |
| 34 | + {{- else }} |
| 35 | + caBundle: {{ .Values.webhook.certificate.caBundle }} |
| 36 | + {{- end }} |
| 37 | + service: |
| 38 | + name: {{ include "api7-ingress-controller-manager.webhook.serviceName" . }} |
| 39 | + namespace: {{ .Release.Namespace }} |
| 40 | + path: /validate-apisix-apache-org-v2-apisixroute |
| 41 | + failurePolicy: {{ .Values.webhook.failurePolicy }} |
| 42 | + {{- with .Values.webhook.timeoutSeconds }} |
| 43 | + timeoutSeconds: {{ . }} |
| 44 | + {{- end }} |
| 45 | + sideEffects: None |
| 46 | + rules: |
| 47 | + - operations: ["CREATE", "UPDATE"] |
| 48 | + apiGroups: ["apisix.apache.org"] |
| 49 | + apiVersions: ["v2"] |
| 50 | + resources: ["apisixroutes"] |
| 51 | +- name: vapisixconsumer-v2.kb.io |
| 52 | + admissionReviewVersions: ["v1"] |
| 53 | + clientConfig: |
| 54 | + {{- if not .Values.webhook.certificate.provided }} |
| 55 | + caBundle: {{ b64enc $caCert }} |
| 56 | + {{- else }} |
| 57 | + caBundle: {{ .Values.webhook.certificate.caBundle }} |
| 58 | + {{- end }} |
| 59 | + service: |
| 60 | + name: {{ include "api7-ingress-controller-manager.webhook.serviceName" . }} |
| 61 | + namespace: {{ .Release.Namespace }} |
| 62 | + path: /validate-apisix-apache-org-v2-apisixconsumer |
| 63 | + failurePolicy: {{ .Values.webhook.failurePolicy }} |
| 64 | + {{- with .Values.webhook.timeoutSeconds }} |
| 65 | + timeoutSeconds: {{ . }} |
| 66 | + {{- end }} |
| 67 | + sideEffects: None |
| 68 | + rules: |
| 69 | + - operations: ["CREATE", "UPDATE"] |
| 70 | + apiGroups: ["apisix.apache.org"] |
| 71 | + apiVersions: ["v2"] |
| 72 | + resources: ["apisixconsumers"] |
| 73 | +- name: vapisixtls-v2.kb.io |
| 74 | + admissionReviewVersions: ["v1"] |
| 75 | + clientConfig: |
| 76 | + {{- if not .Values.webhook.certificate.provided }} |
| 77 | + caBundle: {{ b64enc $caCert }} |
| 78 | + {{- else }} |
| 79 | + caBundle: {{ .Values.webhook.certificate.caBundle }} |
| 80 | + {{- end }} |
| 81 | + service: |
| 82 | + name: {{ include "api7-ingress-controller-manager.webhook.serviceName" . }} |
| 83 | + namespace: {{ .Release.Namespace }} |
| 84 | + path: /validate-apisix-apache-org-v2-apisixtls |
| 85 | + failurePolicy: {{ .Values.webhook.failurePolicy }} |
| 86 | + {{- with .Values.webhook.timeoutSeconds }} |
| 87 | + timeoutSeconds: {{ . }} |
| 88 | + {{- end }} |
| 89 | + sideEffects: None |
| 90 | + rules: |
| 91 | + - operations: ["CREATE", "UPDATE"] |
| 92 | + apiGroups: ["apisix.apache.org"] |
| 93 | + apiVersions: ["v2"] |
| 94 | + resources: ["apisixtlses"] |
| 95 | +- name: vconsumer-v1alpha1.kb.io |
| 96 | + admissionReviewVersions: ["v1"] |
| 97 | + clientConfig: |
| 98 | + {{- if not .Values.webhook.certificate.provided }} |
| 99 | + caBundle: {{ b64enc $caCert }} |
| 100 | + {{- else }} |
| 101 | + caBundle: {{ .Values.webhook.certificate.caBundle }} |
| 102 | + {{- end }} |
| 103 | + service: |
| 104 | + name: {{ include "api7-ingress-controller-manager.webhook.serviceName" . }} |
| 105 | + namespace: {{ .Release.Namespace }} |
| 106 | + path: /validate-apisix-apache-org-v1alpha1-consumer |
| 107 | + failurePolicy: {{ .Values.webhook.failurePolicy }} |
| 108 | + {{- with .Values.webhook.timeoutSeconds }} |
| 109 | + timeoutSeconds: {{ . }} |
| 110 | + {{- end }} |
| 111 | + sideEffects: None |
| 112 | + rules: |
| 113 | + - operations: ["CREATE", "UPDATE"] |
| 114 | + apiGroups: ["apisix.apache.org"] |
| 115 | + apiVersions: ["v1alpha1"] |
| 116 | + resources: ["consumers"] |
| 117 | +- name: vgatewayproxy-v1alpha1.kb.io |
| 118 | + admissionReviewVersions: ["v1"] |
| 119 | + clientConfig: |
| 120 | + {{- if not .Values.webhook.certificate.provided }} |
| 121 | + caBundle: {{ b64enc $caCert }} |
| 122 | + {{- else }} |
| 123 | + caBundle: {{ .Values.webhook.certificate.caBundle }} |
| 124 | + {{- end }} |
| 125 | + service: |
| 126 | + name: {{ include "api7-ingress-controller-manager.webhook.serviceName" . }} |
| 127 | + namespace: {{ .Release.Namespace }} |
| 128 | + path: /validate-apisix-apache-org-v1alpha1-gatewayproxy |
| 129 | + failurePolicy: {{ .Values.webhook.failurePolicy }} |
| 130 | + {{- with .Values.webhook.timeoutSeconds }} |
| 131 | + timeoutSeconds: {{ . }} |
| 132 | + {{- end }} |
| 133 | + sideEffects: None |
| 134 | + rules: |
| 135 | + - operations: ["CREATE", "UPDATE"] |
| 136 | + apiGroups: ["apisix.apache.org"] |
| 137 | + apiVersions: ["v1alpha1"] |
| 138 | + resources: ["gatewayproxies"] |
| 139 | +- name: vingress-v1.kb.io |
| 140 | + admissionReviewVersions: ["v1"] |
| 141 | + clientConfig: |
| 142 | + {{- if not .Values.webhook.certificate.provided }} |
| 143 | + caBundle: {{ b64enc $caCert }} |
| 144 | + {{- else }} |
| 145 | + caBundle: {{ .Values.webhook.certificate.caBundle }} |
| 146 | + {{- end }} |
| 147 | + service: |
| 148 | + name: {{ include "api7-ingress-controller-manager.webhook.serviceName" . }} |
| 149 | + namespace: {{ .Release.Namespace }} |
| 150 | + path: /validate-networking-k8s-io-v1-ingress |
| 151 | + failurePolicy: {{ .Values.webhook.failurePolicy }} |
| 152 | + {{- with .Values.webhook.timeoutSeconds }} |
| 153 | + timeoutSeconds: {{ . }} |
| 154 | + {{- end }} |
| 155 | + sideEffects: None |
| 156 | + rules: |
| 157 | + - operations: ["CREATE", "UPDATE"] |
| 158 | + apiGroups: ["networking.k8s.io"] |
| 159 | + apiVersions: ["v1"] |
| 160 | + resources: ["ingresses"] |
| 161 | +- name: vingressclass-v1.kb.io |
| 162 | + admissionReviewVersions: ["v1"] |
| 163 | + clientConfig: |
| 164 | + {{- if not .Values.webhook.certificate.provided }} |
| 165 | + caBundle: {{ b64enc $caCert }} |
| 166 | + {{- else }} |
| 167 | + caBundle: {{ .Values.webhook.certificate.caBundle }} |
| 168 | + {{- end }} |
| 169 | + service: |
| 170 | + name: {{ include "api7-ingress-controller-manager.webhook.serviceName" . }} |
| 171 | + namespace: {{ .Release.Namespace }} |
| 172 | + path: /validate-networking-k8s-io-v1-ingressclass |
| 173 | + failurePolicy: {{ .Values.webhook.failurePolicy }} |
| 174 | + {{- with .Values.webhook.timeoutSeconds }} |
| 175 | + timeoutSeconds: {{ . }} |
| 176 | + {{- end }} |
| 177 | + sideEffects: None |
| 178 | + rules: |
| 179 | + - operations: ["CREATE", "UPDATE"] |
| 180 | + apiGroups: ["networking.k8s.io"] |
| 181 | + apiVersions: ["v1"] |
| 182 | + resources: ["ingressclasses"] |
| 183 | +- name: vgateway-v1.kb.io |
| 184 | + admissionReviewVersions: ["v1"] |
| 185 | + clientConfig: |
| 186 | + {{- if not .Values.webhook.certificate.provided }} |
| 187 | + caBundle: {{ b64enc $caCert }} |
| 188 | + {{- else }} |
| 189 | + caBundle: {{ .Values.webhook.certificate.caBundle }} |
| 190 | + {{- end }} |
| 191 | + service: |
| 192 | + name: {{ include "api7-ingress-controller-manager.webhook.serviceName" . }} |
| 193 | + namespace: {{ .Release.Namespace }} |
| 194 | + path: /validate-gateway-networking-k8s-io-v1-gateway |
| 195 | + failurePolicy: {{ .Values.webhook.failurePolicy }} |
| 196 | + {{- with .Values.webhook.timeoutSeconds }} |
| 197 | + timeoutSeconds: {{ . }} |
| 198 | + {{- end }} |
| 199 | + sideEffects: None |
| 200 | + rules: |
| 201 | + - operations: ["CREATE", "UPDATE"] |
| 202 | + apiGroups: ["gateway.networking.k8s.io"] |
| 203 | + apiVersions: ["v1"] |
| 204 | + resources: ["gateways"] |
| 205 | + |
| 206 | +--- |
| 207 | +apiVersion: v1 |
| 208 | +kind: Service |
| 209 | +metadata: |
| 210 | + name: {{ include "api7-ingress-controller-manager.webhook.serviceName" . }} |
| 211 | + namespace: {{ .Release.Namespace }} |
| 212 | + labels: |
| 213 | + {{- include "api7-ingress-controller-manager.labels" . | nindent 4 }} |
| 214 | +spec: |
| 215 | + ports: |
| 216 | + - name: webhook |
| 217 | + port: 443 |
| 218 | + protocol: TCP |
| 219 | + targetPort: webhook |
| 220 | + selector: |
| 221 | + {{- include "api7-ingress-controller-manager.selectorLabels" . | nindent 4 }} |
| 222 | + |
| 223 | +{{- if not .Values.webhook.certificate.provided }} |
| 224 | +--- |
| 225 | +apiVersion: v1 |
| 226 | +kind: Secret |
| 227 | +metadata: |
| 228 | + name: {{ include "api7-ingress-controller-manager.webhook.secretName" . }} |
| 229 | + namespace: {{ .Release.Namespace }} |
| 230 | + labels: |
| 231 | + {{- include "api7-ingress-controller-manager.labels" . | nindent 4 }} |
| 232 | +type: kubernetes.io/tls |
| 233 | +data: |
| 234 | + tls.crt: {{ b64enc $certCert }} |
| 235 | + tls.key: {{ b64enc $certKey }} |
| 236 | + ca.crt: {{ b64enc $caCert }} |
| 237 | +{{- end }} |
| 238 | +{{- end }} |
0 commit comments