Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for disabling leader election #2423

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions charts/spark-operator-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall) for command docum
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy. |
| image.pullSecrets | list | `[]` | Image pull secrets for private image registry. |
| controller.replicas | int | `1` | Number of replicas of controller. |
| controller.leaderElection.enable | bool | `true` | Specifies whether to enable leader election for controller. |
| controller.workers | int | `10` | Reconcile concurrency, higher values might increase memory usage. |
| controller.logLevel | string | `"info"` | Configure the verbosity of logging, can be one of `debug`, `info`, `error`. |
| controller.driverPodCreationGracePeriod | string | `"10s"` | Grace period after a successful spark-submit when driver pod not found errors will be retried. Useful if the driver pod can take some time to be created. |
Expand Down Expand Up @@ -127,6 +128,7 @@ See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall) for command docum
| controller.workqueueRateLimiter.maxDelay.duration | string | `"6h"` | Specifies the maximum delay duration for the workqueue rate limiter. |
| webhook.enable | bool | `true` | Specifies whether to enable webhook. |
| webhook.replicas | int | `1` | Number of replicas of webhook server. |
| webhook.leaderElection.enable | bool | `true` | Specifies whether to enable leader election for webhook. |
| webhook.logLevel | string | `"info"` | Configure the verbosity of logging, can be one of `debug`, `info`, `error`. |
| webhook.port | int | `9443` | Specifies webhook port. |
| webhook.portName | string | `"webhook"` | Specifies webhook service port name. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ spec:
- --metrics-prefix={{ .Values.prometheus.metrics.prefix }}
- --metrics-labels=app_type
{{- end }}
{{ if .Values.controller.leaderElection.enable }}
- --leader-election=true
- --leader-election-lock-name={{ include "spark-operator.controller.leaderElectionName" . }}
- --leader-election-lock-namespace={{ .Release.Namespace }}
{{- else -}}
- --leader-election=false
{{- end }}
{{- if .Values.controller.pprof.enable }}
- --pprof-bind-address=:{{ .Values.controller.pprof.port }}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions charts/spark-operator-chart/templates/controller/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ metadata:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
{{- if .Values.controller.leaderElection.enable }}
- apiGroups:
- coordination.k8s.io
resources:
Expand All @@ -100,6 +101,7 @@ rules:
verbs:
- get
- update
{{- end }}
{{- if has .Release.Namespace .Values.spark.jobNamespaces }}
{{ include "spark-operator.controller.policyRules" . }}
{{- end }}
Expand Down
4 changes: 4 additions & 0 deletions charts/spark-operator-chart/templates/webhook/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ spec:
- --metrics-prefix={{ .Values.prometheus.metrics.prefix }}
- --metrics-labels=app_type
{{- end }}
{{ if .Values.webhook.leaderElection.enable }}
- --leader-election=true
- --leader-election-lock-name={{ include "spark-operator.webhook.leaderElectionName" . }}
- --leader-election-lock-namespace={{ .Release.Namespace }}
{{- else -}}
- --leader-election=false
{{- end }}
ports:
- name: {{ .Values.webhook.portName | quote }}
containerPort: {{ .Values.webhook.port }}
Expand Down
2 changes: 2 additions & 0 deletions charts/spark-operator-chart/templates/webhook/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ rules:
verbs:
- get
- update
{{- if .Values.webhook.leaderElection.enable }}
- apiGroups:
- coordination.k8s.io
resources:
Expand All @@ -122,6 +123,7 @@ rules:
verbs:
- get
- update
{{- end }}
{{- if has .Release.Namespace .Values.spark.jobNamespaces }}
{{ include "spark-operator.webhook.policyRules" . }}
{{- end }}
Expand Down
10 changes: 10 additions & 0 deletions charts/spark-operator-chart/tests/controller/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ tests:
- contains:
path: spec.template.spec.containers[?(@.name=="spark-operator-controller")].args
content: --leader-election-lock-namespace=spark-operator

- it: Should disable leader election if `controller.leaderElection.enable` is set to `false`
set:
controller:
leaderElection:
enable: false
asserts:
- contains:
path: spec.template.spec.containers[?(@.name=="spark-operator-controller")].args
content: --leader-election=false

- it: Should add metric ports if `prometheus.metrics.enable` is true
set:
Expand Down
10 changes: 10 additions & 0 deletions charts/spark-operator-chart/tests/webhook/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ tests:
path: spec.template.spec.containers[?(@.name=="spark-operator-webhook")].args
content: --leader-election-lock-namespace=spark-operator

- it: Should disable leader election if `webhook.leaderElection.enable` is set to `false`
set:
webhook:
leaderElection:
enable: false
asserts:
- contains:
path: spec.template.spec.containers[?(@.name=="spark-operator-webhook")].args
content: --leader-election=false

- it: Should add webhook port
set:
webhook:
Expand Down
8 changes: 8 additions & 0 deletions charts/spark-operator-chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ controller:
# -- Number of replicas of controller.
replicas: 1

leaderElection:
# -- Specifies whether to enable leader election for controller.
enable: true

# -- Reconcile concurrency, higher values might increase memory usage.
workers: 10

Expand Down Expand Up @@ -220,6 +224,10 @@ webhook:
# -- Number of replicas of webhook server.
replicas: 1

leaderElection:
# -- Specifies whether to enable leader election for webhook.
enable: true

# -- Configure the verbosity of logging, can be one of `debug`, `info`, `error`.
logLevel: info

Expand Down