webhook.yaml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. ################################################################################
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. ################################################################################
  18. ---
  19. {{- if eq (include "flink-operator.webhook-enabled" .) "true" }}
  20. ---
  21. apiVersion: v1
  22. kind: Service
  23. metadata:
  24. name: flink-operator-webhook-service
  25. namespace: {{ .Release.Namespace }}
  26. spec:
  27. ports:
  28. - port: 443
  29. targetPort: 9443
  30. selector:
  31. app.kubernetes.io/name: {{ include "flink-operator.name" . }}
  32. ---
  33. {{- if .Values.webhook.keystore.useDefaultPassword }}
  34. apiVersion: v1
  35. kind: Secret
  36. metadata:
  37. name: flink-operator-webhook-secret
  38. namespace: {{ .Release.Namespace }}
  39. type: Opaque
  40. data:
  41. password: cGFzc3dvcmQxMjM0
  42. {{- end }}
  43. ---
  44. apiVersion: cert-manager.io/v1
  45. kind: Certificate
  46. metadata:
  47. name: flink-operator-serving-cert
  48. namespace: {{ .Release.Namespace }}
  49. spec:
  50. dnsNames:
  51. - flink-operator-webhook-service.{{ .Release.Namespace }}.svc
  52. - flink-operator-webhook-service.{{ .Release.Namespace }}.svc.cluster.local
  53. keystores:
  54. pkcs12:
  55. create: true
  56. passwordSecretRef:
  57. {{- if .Values.webhook.keystore.useDefaultPassword }}
  58. name: flink-operator-webhook-secret
  59. key: password
  60. {{- else }}
  61. {{- with .Values.webhook.keystore.passwordSecretRef }}
  62. {{- toYaml . | nindent 8 }}
  63. {{- end }}
  64. {{- end }}
  65. issuerRef:
  66. kind: Issuer
  67. name: flink-operator-selfsigned-issuer
  68. commonName: FlinkDeployment Validator
  69. secretName: webhook-server-cert
  70. ---
  71. apiVersion: cert-manager.io/v1
  72. kind: Issuer
  73. metadata:
  74. name: flink-operator-selfsigned-issuer
  75. namespace: {{ .Release.Namespace }}
  76. spec:
  77. selfSigned: {}
  78. {{- end }}
  79. {{- if eq (include "flink-operator.validating-webhook-enabled" .) "true" }}
  80. ---
  81. apiVersion: admissionregistration.k8s.io/v1
  82. kind: ValidatingWebhookConfiguration
  83. metadata:
  84. annotations:
  85. cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/flink-operator-serving-cert
  86. name: flink-operator-{{ .Release.Namespace }}-webhook-configuration
  87. webhooks:
  88. - name: validationwebhook.flink.apache.org
  89. admissionReviewVersions: ["v1"]
  90. clientConfig:
  91. service:
  92. name: flink-operator-webhook-service
  93. namespace: {{ .Release.Namespace }}
  94. path: /validate
  95. failurePolicy: Fail
  96. rules:
  97. - apiGroups: ["flink.apache.org"]
  98. apiVersions: ["*"]
  99. scope: "Namespaced"
  100. operations:
  101. - CREATE
  102. - UPDATE
  103. resources:
  104. - flinkdeployments
  105. - flinksessionjobs
  106. sideEffects: None
  107. {{- if .Values.watchNamespaces }}
  108. namespaceSelector:
  109. matchExpressions:
  110. - key: kubernetes.io/metadata.name
  111. operator: In
  112. values: [{{- range .Values.watchNamespaces }}{{ . | quote }},{{- end}}]
  113. {{- end }}
  114. {{- end }}
  115. {{- if eq (include "flink-operator.mutating-webhook-enabled" .) "true" }}
  116. ---
  117. apiVersion: admissionregistration.k8s.io/v1
  118. kind: MutatingWebhookConfiguration
  119. metadata:
  120. annotations:
  121. cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/flink-operator-serving-cert
  122. name: flink-operator-{{ .Release.Namespace }}-webhook-configuration
  123. webhooks:
  124. - name: mutationwebhook.flink.apache.org
  125. admissionReviewVersions: ["v1"]
  126. clientConfig:
  127. service:
  128. name: flink-operator-webhook-service
  129. namespace: {{ .Release.Namespace }}
  130. path: /mutate
  131. failurePolicy: Fail
  132. rules:
  133. - apiGroups: ["flink.apache.org"]
  134. apiVersions: ["*"]
  135. scope: "Namespaced"
  136. operations:
  137. - CREATE
  138. resources:
  139. - flinksessionjobs
  140. sideEffects: None
  141. {{- if .Values.watchNamespaces }}
  142. namespaceSelector:
  143. matchExpressions:
  144. - key: kubernetes.io/metadata.name
  145. operator: In
  146. values: [{{- range .Values.watchNamespaces }}{{ . | quote }},{{- end}}]
  147. {{- end }}
  148. {{- end }}