This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-kubernetes-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new de62b0c  [SPARK-54896] Improve Helm templates to use Spark Operator HA 
feature easily
de62b0c is described below

commit de62b0c1aa2e5c45dffdcc0c89ae2876c64283d7
Author: [email protected] <[email protected]>
AuthorDate: Sat Jan 17 17:29:13 2026 +0900

    [SPARK-54896] Improve Helm templates to use Spark Operator HA feature easily
    
    ### What changes were proposed in this pull request?
    
    Set default configuration on the helm template in order to support high 
availability of the operator without requiring specific configuration from the 
user
    
    ### Why are the changes needed?
    
    Simplify setup of HA, only need to increase the number of replicas
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    Run helm template with 1 and more replicas to check that added resources 
are well displayed
    Deployed on a local kubernetes cluster with replicas set to 3
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No
    
    Closes #437 from ashangit/nfraison/high-availability.
    
    Authored-by: [email protected] <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 .../templates/_helpers.tpl                         |  3 +++
 .../templates/operator-rbac.yaml                   |  8 ++++++
 .../spark-kubernetes-operator/templates/pdb.yaml   | 30 ++++++++++++++++++++++
 3 files changed, 41 insertions(+)

diff --git a/build-tools/helm/spark-kubernetes-operator/templates/_helpers.tpl 
b/build-tools/helm/spark-kubernetes-operator/templates/_helpers.tpl
index d6055cc..a24ba57 100644
--- a/build-tools/helm/spark-kubernetes-operator/templates/_helpers.tpl
+++ b/build-tools/helm/spark-kubernetes-operator/templates/_helpers.tpl
@@ -119,6 +119,9 @@ spark.kubernetes.operator.health.probePort={{ include 
"spark-operator.probePort"
 {{- if .Values.workloadResources.namespaces.overrideWatchedNamespaces }}
 spark.kubernetes.operator.watchedNamespaces={{ include 
"spark-operator.workloadNamespacesStr" . | trim }}
 {{- end }}
+{{- if gt (int .Values.operatorDeployment.replicas) 1 }}
+spark.kubernetes.operator.leaderElection.enabled=true
+{{- end }}
 {{- end }}
 
 {{/*
diff --git 
a/build-tools/helm/spark-kubernetes-operator/templates/operator-rbac.yaml 
b/build-tools/helm/spark-kubernetes-operator/templates/operator-rbac.yaml
index e0ca9cb..55840c4 100644
--- a/build-tools/helm/spark-kubernetes-operator/templates/operator-rbac.yaml
+++ b/build-tools/helm/spark-kubernetes-operator/templates/operator-rbac.yaml
@@ -58,6 +58,14 @@ rules:
       - poddisruptionbudgets
     verbs:
       - '*'
+{{- if gt (int .Values.operatorDeployment.replicas) 1 }}
+  - apiGroups:
+      - "coordination.k8s.io"
+    resources:
+      - leases
+    verbs:
+      - '*'
+{{- end }}
 {{- end }}
 
 {{/*
diff --git a/build-tools/helm/spark-kubernetes-operator/templates/pdb.yaml 
b/build-tools/helm/spark-kubernetes-operator/templates/pdb.yaml
new file mode 100644
index 0000000..c1231bf
--- /dev/null
+++ b/build-tools/helm/spark-kubernetes-operator/templates/pdb.yaml
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+#     http://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 gt (int .Values.operatorDeployment.replicas) 1 }}
+---
+apiVersion: policy/v1
+kind: PodDisruptionBudget
+metadata:
+  name: spark-kubernetes-operator-pdb-{{ $.Release.Name }}
+  namespace: {{ .Release.Namespace }}
+  labels:
+    {{- include "spark-operator.commonLabels" . | nindent 4 }}
+spec:
+  maxUnavailable: 1
+  selector:
+    matchLabels:
+      app.kubernetes.io/name: {{ include "spark-operator.name" . }}
+{{- end }}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to