From d18886dbcc1a084b05b1f79fbb8d62c027cba170 Mon Sep 17 00:00:00 2001 From: Chaoran Yu Date: Tue, 11 Dec 2018 11:51:36 +0800 Subject: [PATCH] Fixed webhook and support multiple instances of the operator in the same cluster (#9840) * Fixed webhook Signed-off-by: Chaoran Yu * Updated operator version in Chart.yaml Signed-off-by: Chaoran Yu * Support multiple instances of operator in the same cluster Signed-off-by: Chaoran Yu * Testing fixing the secrets not found error Signed-off-by: Chaoran Yu * Revert "Testing fixing the secrets not found error" This reverts commit bd404ddac41cfcfc014ee11b7503b94dfef52b0f. Signed-off-by: Chaoran Yu * Updated default image Signed-off-by: Chaoran Yu * Disable webhook Signed-off-by: Chaoran Yu --- incubator/sparkoperator/Chart.yaml | 4 ++-- incubator/sparkoperator/README.md | 5 ++-- .../templates/spark-namespace.yaml | 11 --------- .../templates/spark-operator-deployment.yaml | 24 +++++++------------ .../templates/spark-operator-rbac.yaml | 6 ++--- .../templates/webhook-cleanup-job.yaml | 2 +- .../templates/webhook-init-job.yaml | 4 ++-- incubator/sparkoperator/values.yaml | 9 +++---- 8 files changed, 23 insertions(+), 42 deletions(-) delete mode 100644 incubator/sparkoperator/templates/spark-namespace.yaml diff --git a/incubator/sparkoperator/Chart.yaml b/incubator/sparkoperator/Chart.yaml index 7026d1e6ba..115bd742c6 100644 --- a/incubator/sparkoperator/Chart.yaml +++ b/incubator/sparkoperator/Chart.yaml @@ -1,7 +1,7 @@ name: sparkoperator description: A Helm chart for Spark on Kubernetes operator -version: 0.1.3 -appVersion: v1alpha1-0.4-2.3.x +version: 0.1.4 +appVersion: v1alpha1-0.5-2.4.0 kubeVersion: ">=1.8.0-0" keywords: - spark diff --git a/incubator/sparkoperator/README.md b/incubator/sparkoperator/README.md index 7089720a66..f5e6bfa53d 100644 --- a/incubator/sparkoperator/README.md +++ b/incubator/sparkoperator/README.md @@ -24,10 +24,9 @@ The following table lists the configurable parameters of the Spark operator char | Parameter | Description | Default | | ------------------------- | ----------------------------------------------------- | -------------------------------------- | | `operatorImageName` | The name of the operator image | `gcr.io/spark-operator/spark-operator` | -| `operatorVersion` | The version of the operator to install | `v2.3.1-v1alpha1-latest` | +| `operatorVersion` | The version of the operator to install | `v2.4.0-v1alpha1-latest` | | `sparkJobNamespace` | K8s namespace where Spark jobs are to be deployed. | `default` | -| `createSparkJobNamespace` | Whether to create the Spark job namespace | false | -| `enableWebhook` | Whether to enable mutating admission webhook | true | +| `enableWebhook` | Whether to enable mutating admission webhook | false | | `enableMetrics` | Whether to expose metrics to be scraped by Premetheus | true | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. diff --git a/incubator/sparkoperator/templates/spark-namespace.yaml b/incubator/sparkoperator/templates/spark-namespace.yaml deleted file mode 100644 index f9beb4929f..0000000000 --- a/incubator/sparkoperator/templates/spark-namespace.yaml +++ /dev/null @@ -1,11 +0,0 @@ -{{ if .Values.createSparkJobNamespace }} -apiVersion: v1 -kind: Namespace -metadata: - name: {{ .Values.sparkJobNamespace }} - labels: - app.kubernetes.io/name: {{ include "sparkoperator.name" . }} - helm.sh/chart: {{ include "sparkoperator.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -{{ end }} diff --git a/incubator/sparkoperator/templates/spark-operator-deployment.yaml b/incubator/sparkoperator/templates/spark-operator-deployment.yaml index f2c2be70d5..12292d3a63 100644 --- a/incubator/sparkoperator/templates/spark-operator-deployment.yaml +++ b/incubator/sparkoperator/templates/spark-operator-deployment.yaml @@ -45,7 +45,7 @@ spec: containers: - name: sparkoperator image: {{ .Values.operatorImageName }}:{{ .Values.operatorVersion }} - imagePullPolicy: IfNotPresent + imagePullPolicy: {{ .Values.imagePullPolicy }} {{- if .Values.enableWebhook }} volumeMounts: - name: webhook-certs @@ -56,24 +56,16 @@ spec: - containerPort: 10254 {{ end }} command: ["/usr/bin/spark-operator"] - {{- if and (.Values.enableMetrics) (.Values.enableWebhook) }} args: + - -logtostderr + - -namespace={{ .Values.sparkJobNamespace }} + {{- if .Values.enableMetrics }} - -enable-metrics=true - -metrics-labels=app_type + {{- end }} + {{- if .Values.enableWebhook }} - -enable-webhook=true - -webhook-svc-namespace={{ .Release.Namespace }} - - -logtostderr - {{- else if (.Values.enableMetrics) }} - args: - - -enable-metrics=true - - -metrics-labels=app_type - - -logtostderr - {{- else if (.Values.enableWebhook) }} - args: - - -enable-webhook=true - - -webhook-svc-namespace={{ .Release.Namespace }} - - -logtostderr - {{- else }} - args: - - -logtostderr + - -webhook-svc-name={{ include "sparkoperator.fullname" . }}-webhook + - -webhook-config-name={{ include "sparkoperator.fullname" . }}-webhook-config {{- end }} diff --git a/incubator/sparkoperator/templates/spark-operator-rbac.yaml b/incubator/sparkoperator/templates/spark-operator-rbac.yaml index d87403cbb9..3ff3f9ae12 100644 --- a/incubator/sparkoperator/templates/spark-operator-rbac.yaml +++ b/incubator/sparkoperator/templates/spark-operator-rbac.yaml @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: sparkoperator-cr + name: {{ include "sparkoperator.fullname" . }}-cr labels: app.kubernetes.io/name: {{ include "sparkoperator.name" . }} helm.sh/chart: {{ include "sparkoperator.chart" . }} @@ -34,7 +34,7 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: sparkoperator-crb + name: {{ include "sparkoperator.fullname" . }}-crb namespace: {{ .Release.Namespace }} labels: app.kubernetes.io/name: {{ include "sparkoperator.name" . }} @@ -47,6 +47,6 @@ subjects: namespace: {{ .Release.Namespace }} roleRef: kind: ClusterRole - name: sparkoperator-cr + name: {{ include "sparkoperator.fullname" . }}-cr apiGroup: rbac.authorization.k8s.io {{- end }} diff --git a/incubator/sparkoperator/templates/webhook-cleanup-job.yaml b/incubator/sparkoperator/templates/webhook-cleanup-job.yaml index 3112b81e1e..e2a2531d39 100644 --- a/incubator/sparkoperator/templates/webhook-cleanup-job.yaml +++ b/incubator/sparkoperator/templates/webhook-cleanup-job.yaml @@ -19,7 +19,7 @@ spec: containers: - name: main image: {{ .Values.operatorImageName }}:{{ .Values.operatorVersion }} - imagePullPolicy: IfNotPresent + imagePullPolicy: {{ .Values.imagePullPolicy }} command: - "/bin/sh" - "-c" diff --git a/incubator/sparkoperator/templates/webhook-init-job.yaml b/incubator/sparkoperator/templates/webhook-init-job.yaml index c459e9fad5..f2af09b95a 100644 --- a/incubator/sparkoperator/templates/webhook-init-job.yaml +++ b/incubator/sparkoperator/templates/webhook-init-job.yaml @@ -19,6 +19,6 @@ spec: containers: - name: main image: {{ .Values.operatorImageName }}:{{ .Values.operatorVersion }} - imagePullPolicy: IfNotPresent - command: ["/usr/bin/gencerts.sh", "-n", "{{ .Release.Namespace }}", "-p"] + imagePullPolicy: {{ .Values.imagePullPolicy }} + command: ["/usr/bin/gencerts.sh", "-n", "{{ .Release.Namespace }}", "-s", '{{ include "sparkoperator.fullname" . }}-webhook', "-p"] {{ end }} diff --git a/incubator/sparkoperator/values.yaml b/incubator/sparkoperator/values.yaml index 7f5b04506f..767a5fcb61 100644 --- a/incubator/sparkoperator/values.yaml +++ b/incubator/sparkoperator/values.yaml @@ -1,6 +1,7 @@ operatorImageName: gcr.io/spark-operator/spark-operator -operatorVersion: v2.3.1-v1alpha1-latest -sparkJobNamespace: default +operatorVersion: v2.4.0-v1alpha1-latest + +imagePullPolicy: IfNotPresent rbac: create: true @@ -13,7 +14,7 @@ serviceAccounts: create: true name: -createSparkJobNamespace: false +sparkJobNamespace: default -enableWebhook: true +enableWebhook: false enableMetrics: true