125 lines
3.7 KiB
YAML
125 lines
3.7 KiB
YAML
{{/*
|
|
Copyright 2024 The Kubeflow authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/}}
|
|
|
|
{{- if .Values.webhook.enable }}
|
|
apiVersion: admissionregistration.k8s.io/v1
|
|
kind: MutatingWebhookConfiguration
|
|
metadata:
|
|
name: {{ include "spark-operator.webhook.name" . }}
|
|
labels:
|
|
{{- include "spark-operator.webhook.labels" . | nindent 4 }}
|
|
webhooks:
|
|
- name: mutate--v1-pod.sparkoperator.k8s.io
|
|
admissionReviewVersions: ["v1"]
|
|
clientConfig:
|
|
service:
|
|
name: {{ include "spark-operator.webhook.serviceName" . }}
|
|
namespace: {{ .Release.Namespace }}
|
|
port: {{ .Values.webhook.port }}
|
|
path: /mutate--v1-pod
|
|
sideEffects: NoneOnDryRun
|
|
{{- with .Values.webhook.failurePolicy }}
|
|
failurePolicy: {{ . }}
|
|
{{- end }}
|
|
{{- with .Values.spark.jobNamespaces }}
|
|
{{- if not (has "" .) }}
|
|
namespaceSelector:
|
|
matchExpressions:
|
|
- key: kubernetes.io/metadata.name
|
|
operator: In
|
|
values:
|
|
{{- range $jobNamespace := . }}
|
|
- {{ $jobNamespace }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
objectSelector:
|
|
matchLabels:
|
|
sparkoperator.k8s.io/launched-by-spark-operator: "true"
|
|
rules:
|
|
- apiGroups: [""]
|
|
apiVersions: ["v1"]
|
|
resources: ["pods"]
|
|
operations: ["CREATE"]
|
|
{{- with .Values.webhook.timeoutSeconds }}
|
|
timeoutSeconds: {{ . }}
|
|
{{- end }}
|
|
- name: mutate-sparkoperator-k8s-io-v1beta2-sparkapplication.sparkoperator.k8s.io
|
|
admissionReviewVersions: ["v1"]
|
|
clientConfig:
|
|
service:
|
|
name: {{ include "spark-operator.webhook.serviceName" . }}
|
|
namespace: {{ .Release.Namespace }}
|
|
port: {{ .Values.webhook.port }}
|
|
path: /mutate-sparkoperator-k8s-io-v1beta2-sparkapplication
|
|
sideEffects: NoneOnDryRun
|
|
{{- with .Values.webhook.failurePolicy }}
|
|
failurePolicy: {{ . }}
|
|
{{- end }}
|
|
{{- with .Values.spark.jobNamespaces }}
|
|
{{- if not (has "" .) }}
|
|
namespaceSelector:
|
|
matchExpressions:
|
|
- key: kubernetes.io/metadata.name
|
|
operator: In
|
|
values:
|
|
{{- range $jobNamespace := . }}
|
|
- {{ $jobNamespace }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
rules:
|
|
- apiGroups: ["sparkoperator.k8s.io"]
|
|
apiVersions: ["v1beta2"]
|
|
resources: ["sparkapplications"]
|
|
operations: ["CREATE", "UPDATE"]
|
|
{{- with .Values.webhook.timeoutSeconds }}
|
|
timeoutSeconds: {{ . }}
|
|
{{- end }}
|
|
- name: mutate-sparkoperator-k8s-io-v1beta2-scheduledsparkapplication.sparkoperator.k8s.io
|
|
admissionReviewVersions: ["v1"]
|
|
clientConfig:
|
|
service:
|
|
name: {{ include "spark-operator.webhook.serviceName" . }}
|
|
namespace: {{ .Release.Namespace }}
|
|
port: {{ .Values.webhook.port }}
|
|
path: /mutate-sparkoperator-k8s-io-v1beta2-scheduledsparkapplication
|
|
sideEffects: NoneOnDryRun
|
|
{{- with .Values.webhook.failurePolicy }}
|
|
failurePolicy: {{ . }}
|
|
{{- end }}
|
|
{{- with .Values.spark.jobNamespaces }}
|
|
{{- if not (has "" .) }}
|
|
namespaceSelector:
|
|
matchExpressions:
|
|
- key: kubernetes.io/metadata.name
|
|
operator: In
|
|
values:
|
|
{{- range $jobNamespace := . }}
|
|
- {{ $jobNamespace }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
rules:
|
|
- apiGroups: ["sparkoperator.k8s.io"]
|
|
apiVersions: ["v1beta2"]
|
|
resources: ["scheduledsparkapplications"]
|
|
operations: ["CREATE", "UPDATE"]
|
|
{{- with .Values.webhook.timeoutSeconds }}
|
|
timeoutSeconds: {{ . }}
|
|
{{- end }}
|
|
{{- end }}
|