Configure Celeborn for Spark on Kubernetes using Helm

This article shows how to use Apache Celeborn as an external shuffle service for Spark in Kubernetes using Helm.

You can install Celeborn as a separate Helm release. To make a Spark application use the Celeborn server as a shuffle service, you have to provide Celeborn configurations when submitting the Spark app. There are two ways to provide Celeborn configurations to a Spark application:

  • Specify Celeborn configurations in a Helm values file (under the sparkConf section). This method is described later in the article.

  • Create a Kubernetes secret with Celeborn configurations and reference the secret when submitting the Spark application.

Choose the method that best suits your environment and security requirements.

Prerequisites

  • A Kubernetes cluster (1.32 — 1.34) accessible through kubectl.

  • Helm (3.8.0 or higher) — a package manager that allows quick deployment of Docker images in Kubernetes.

  • Spark operator is deployed in Kubernetes according to the instruction.

  • The hub.arenadata.io/adc-enterprise/celeborn:<version> image is unpacked and pushed to your repository.

  • S3 storage is available (used for demonstrating Celeborn activity in this particular example).

Deployment steps

Step 1. Install Celeborn server

  1. Create a Helm values file celeborn.yaml:

    celeborn.yaml
    # Specifies the Celeborn image to use
    image:
      # -- Image registry
      registry: "registry" (1)
      # -- Image repository
      repository: ng/celeborn/server (2)
      # -- Image tag, default is chart `appVersion`
      tag: "version"
      # -- Image pull policy
      pullPolicy: Always
      # -- Image name for init container. (your-private-repo/alpine:3.18)
      initContainerImage: alpine:3.18
      # Credentials for pulling the image from a private registry. Either reference an
      # existing docker-registry Secret via `name`, or provide `credentials` and the
      # chart will render a `kubernetes.io/dockerconfigjson` Secret for you.
      pullSecret:
        # -- Name of an existing docker-registry Secret. When empty and `credentials`
        # is set, a Secret named `<fullname>-docker-config` is created.
        name: ""
        # -- Registry credentials used to render a docker-config Secret.
        credentials: {}
        #   registry: private-docker-registry
        #   username: user
        #   password: pass
    
    celeborn:
      celeborn.storage.availableTypes: MEMORY,SSD,S3 (3)
      celeborn.worker.storage.dirs: "/mnt/disk1:disktype=SSD" (4)
      celeborn.storage.s3.dir: "s3a://ka-adh-demo/celeborn" (5)
      celeborn.storage.s3.endpoint.region: ru-central1 (6)
      celeborn.hadoop.fs.s3a.access.key: <access_key> (7)
      celeborn.hadoop.fs.s3a.secret.key: <secret_key>
      celeborn.hadoop.fs.s3a.endpoint: https://storage.yandexcloud.net (8)
      celeborn.hadoop.fs.s3a.path.style.access: true
    1 Address of your OCI registry to pull images from.
    2 Name of the repository in your registry.
    3 Storage types Celeborn can use.
    4 Local directories on Celeborn workers used for disk-based shuffle storage.
    5 Base S3 path where Celeborn stores data when using S3 storage.
    6 S3 region associated with the object-storage endpoint.
    7 S3 credentials (access key, secret key).
    8 S3 endpoint URL.
  2. Install Celeborn using Helm:

    $ helm upgrade --install helm-celeborn oci://<registry-address>/adc-enterprise/charts/celeborn:<version> -f celeborn.yaml --namespace spark-apps-s3 --create-namespace

    where <registry-address> is the address of your OCI registry with loaded Spark Helm charts.

    The installation output contains information similar to the following:

    Master endpoints (3 replicas, RPC port 9097)
    ====================================================================
    
      celeborn.master.endpoints=helm-celeborn-master-0.helm-celeborn-master-svc.helm-celeborn.svc.cluster.local:9097,helm-celeborn-master-1.helm-celeborn-master-svc.helm-celeborn.svc.cluster.local:9097,helm-celeborn-master-2.helm-celeborn-master-svc.helm-celeborn.svc.cluster.local:9097
    
    These are the per-pod (StatefulSet) DNS names of every master replica, not the
    Service VIP — clients connect to each replica directly so HA failover works.
    The list above is also written verbatim into the server config Secret
    (helm-celeborn-conf, key celeborn-defaults.conf), so master and
    worker pods already use it. The port can be omitted in this value (Celeborn
    defaults to 9097); it is shown explicitly here for clarity.
    
    Point Spark clients at the same endpoints:
    
      spark.celeborn.master.endpoints=helm-celeborn-master-0.helm-celeborn-master-svc.helm-celeborn.svc.cluster.local:9097,helm-celeborn-master-1.helm-celeborn-master-svc.helm-celeborn.svc.cluster.local:9097,helm-celeborn-master-2.helm-celeborn-master-svc.helm-celeborn.svc.cluster.local:9097
    TIP
    Copy the spark.celeborn.master.endpoints value for further steps.
  3. Verify the Celeborn pods:

    $ kubectl get pods -n spark-apps-s3

    The result:

    NAME                     READY   STATUS    RESTARTS       AGE
    helm-celeborn-master-0   1/1     Running   5 (109s ago)   6m28s
    helm-celeborn-master-1   1/1     Running   5 (108s ago)   6m6s
    helm-celeborn-master-2   1/1     Running   5 (107s ago)   6m2s
    helm-celeborn-worker-0   1/1     Running   4 (72s ago)    6m28s
    helm-celeborn-worker-1   1/1     Running   4 (74s ago)    6m7s
    helm-celeborn-worker-2   1/1     Running   4 (68s ago)    5m39s

Step 2. Create a secret for accessing S3

The test Spark application demonstrated in this scenario assumes interaction with S3. To enable communication with S3, create a Kubernetes secret as shown below.

  1. Create the files:

    core-site.xml
    <configuration>
        <property>
            <name>fs.defaultFS</name>
            <value>s3a://adh-demo</value>
        </property>
        <property>
            <name>fs.s3a.aws.credentials.provider</name>
            <value>org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider</value>
        </property>
        <property>
            <name>fs.s3a.endpoint</name>
            <value>https://storage.yandexcloud.net</value>
        </property>
        <property>
            <name>fs.s3a.impl</name>
            <value>org.apache.hadoop.fs.s3a.S3AFileSystem</value>
        </property>
        <property>
            <name>fs.s3a.path.style.access</name>
            <value>true</value>
        </property>
        <property>
            <name>fs.s3a.region</name>
            <value>ru-central1</value>
        </property>
        <property>
            <name>fs.s3a.access.key</name>
            <value>...</value>
        </property>
        <property>
            <name>fs.s3a.secret.key</name>
            <value>...</value>
        </property>
    </configuration>
    hive-site.xml
    <configuration>
        <property>
            <name>hive.metastore.uris</name>
            <value>thrift://ka-adh-1.ru-central1.internal:9083</value>
        </property>
        <property>
            <name>hive.metastore.warehouse.dir</name>
            <value>s3a://adh-demo/apps/hive/warehouse</value>
        </property>
        <property>
            <name>metastore.use.SSL</name>
            <value>false</value>
        </property>
    </configuration>
  2. Create the secret:

    $ kubectl create secret generic s3-conf -n spark-apps-s3 --from-file=core-site.xml --from-file=hive-site.xml

Step 3. Create a test Spark application

In this scenario, Spark pulls a PySpark application file from S3 and runs it. To prepare a test application, do the following:

  1. Create the demo-load.py file:

    from pyspark.sql import SparkSession
    from pyspark import SparkConf
    
    
    spark = SparkSession.builder \
        .appName("Demo_PySpark_Load") \
        .enableHiveSupport() \
        .getOrCreate()
    
    sql = "select count(*) from tpcds_1tb.store_sales"
    df = spark.sql(sql).show(1,0)
    
    spark.sparkContext.stop()
  2. Upload demo-load.py to S3.

Step 4. Submit a Spark application

  1. Create spark-celeborn-submit.yaml:

    spark-celeborn-submit.yaml
    image:
      registry: "registry" (1)
      repository: "repository" (2)
      tag: "version"
      ## Specify a pullPolicy
      ## ref: https://kubernetes.io/docs/concepts/containers/images/#pre-pulled-images
      ##
      pullPolicy: "Always"
      ## Existing secret or secret to create to use for image pulling, they must exist in all product namespaces
      ##
      pullSecret:
        name: ""
        credentials: {}
    #      registry: private-docker-registry
    #      username: user
    #      password: pass
    
    #ServiceAccount name for Spark driver/executor pods
    serviceAccountName: "spark-apps-s3"
    
    #Application
    #mainApplicationFile: path to the main app file (hdfs://, local://, etc.)
    mainApplicationFile: "s3a://adh-demo/demo/apps/spark-submit/scripts/demo-load.py" (3)
    
    #Restart policy on failure: Never or OnFailure
    #When set to OnFailure, maxRetries must be specified
    restartPolicy: ""
    
    #Maximum number of Job restart attempts on failure
    #Required when restartPolicy is OnFailure
    #maxRetries:
    
    #Seconds to keep a finished (Succeeded or Failed) SparkApplication CR around
    #before it is automatically deleted. A Failed application with restart
    #attempts remaining does not count as finished. Omit to keep finished CRs
    #until explicit deletion; 0 deletes as soon as the terminal status is recorded.
    #ttlSecondsAfterFinished: 3600
    
    #mainClass: set only for JVM apps (e.g. SparkConnectServer)
    mainClass: ""
    
    
    #Hadoop configurations
    hadoopConfigsSecretName: "s3-conf" (4)
    
    #Spark configurations. When set, this client-managed Secret is the complete
    #Spark configuration source. If Ranger is enabled, include the ranger-spark-*.xml
    #files in this Secret; the chart does not create a separate Ranger config Secret.
    sparkConfigsSecretName: ""
    
    #Kerberos (keytab mode), disabled by default.
    #The referenced Secret must already exist and carry two keys: keytab + krb5.conf.
    #Ticket-cache mode is CLI-only and is not exposed here.
    #Extra confs (e.g. spark.kerberos.access.hadoopFileSystems) go under sparkConf.
    #kerberos:
    #  principal: spark/spark-ozone.ru-central1.internal
    #  keytab:
    #    secretName: keytab-secret
    
    # Arguments passed to the main application class after the main file
    args: []
    #  - "1000"
    
    #Spark configuration
    #Key/value map rendered into spec.sparkConf
    sparkConf: (5)
      spark.artifactory.dir.path: /tmp/artifacts
      spark.jars.ivy: /tmp/ivy
      spark.local.dir: /tmp/data
      spark.sql.catalog.spark_catalog: org.apache.iceberg.spark.SparkSessionCatalog
      spark.sql.extensions: org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions
      spark.sql.security.confblacklist: spark.sql.extensions
      spark.metrics.executorMetricsSource.enabled: "true"
      spark.metrics.appStatusSource.enabled: "true"
      spark.executor.processTreeMetrics.enabled: "true"
      spark.hadoop.fs.s3a.access.key: <key>
      spark.hadoop.fs.s3a.secret.key: <secret>
      spark.hadoop.fs.s3a.endpoint: "https://storage.yandexcloud.net"
      spark.hadoop.fs.s3a.region: "ru-central1"
      spark.hadoop.fs.s3a.path.style.access: "true"
      spark.celeborn.master.endpoints: helm-celeborn-master-0.helm-celeborn-master-svc.spark-apps-s3.svc.cluster.local:9097,helm-celeborn-master-1.helm-celeborn-master-svc.spark-apps-s3.svc.cluster.local:9097,helm-celeborn-master-2.helm-celeborn-master-svc.spark-apps-s3.svc.cluster.local:9097 (6)
      spark.celeborn.storage.availableTypes: S3
      spark.celeborn.hadoop.fs.s3a.secret.key: <secret>
      spark.celeborn.client.spark.shuffle.writer: hash
      spark.shuffle.sort.io.plugin.class: org.apache.spark.shuffle.celeborn.CelebornShuffleDataIO
      spark.celeborn.hadoop.fs.s3a.access.key: <key>
      spark.shuffle.manager: org.apache.spark.shuffle.celeborn.SparkShuffleManager
      spark.celeborn.storage.s3.endpoint.region: ru-central1
      spark.celeborn.storage.s3.dir: s3a://adh-demo/celeborn
      spark.celeborn.client.shuffle.compression.zstd.level: "12"
      spark.celeborn.client.push.replicate.enabled: "false"
      spark.celeborn.client.shuffle.compression.codec: zstd
    
    
    #SSL / truststore settings. The referenced Secret must already exist;
    #the operator mounts the stores at /etc/ssl.
    #Enabled implicitly when secretName is set.
    #ssl:
    #  secretName: "custom-ssl-secret"
    #  trustStoreKey: "truststore.jks"
    ##  keyStoreKey: "keystore.jks"
    
    #Ranger authorization (Kyuubi Spark Authz plugin), disabled by default.
    #When enabled without sparkConfigsSecretName, the chart renders the
    #ranger-spark-*.xml config Secret. The spark-apps.sparkConf helper always appends
    #the Ranger extension to spark.sql.extensions.
    #The audit JAAS block is written only when the kerberos block is set (keytab mode);
    #the policymgr-ssl truststore is rendered only when ssl.enabled.
    ranger:
      enabled: false
      # ranger.plugin.spark.policy.rest.url
      policyRestURL: ""
      # ranger.plugin.spark.service.name
      serviceName: ""
      # xasecure.audit.destination.solr.zookeepers
      solrZookeepers: ""
    
    job:
      ## @param replicas set number of job replicas
      ##
      replicas: 1
    
      ## When false, the spark-submit Job pod is not automatically deleted after completion (useful for log inspection)
      ##
      #deleteOnTermination: false
    
      ## Additional configuration that you want to be added to job-config
      args: {}
      #  task.max-worker-threads: 8
    
      ## Annotations for job pods
      annotations: {}
    
      ## Set container requests and limits for resource like CPU or memory (essential for production workloads)
      ##
      resources: {}
        #limits:
        #  cpu: "2"
        #  memory: "8Gi"
        #requests:
        #  cpu: "2"
      #  memory: "8Gi"
    
      ## Request additional PVC for pod
      ##
      persistentVolume: {}
      #  mountPath: "/data/spark"
      #  volumeClaimTemplates:
      #    - metadata:
      #        name: data
      #      spec:
      #        accessModes: ["ReadWriteOnce"]
      #        resources:
      #          requests:
      #            storage: 10Gi
      #        storageClassName: default
    
      ## nodeAffinity: Object defining constraints to place pods on a specific set of Nodes
      ##
      nodeSelector: {}
    
      topologySpreadConstraints: []
    
      ## Allow a Pod to be scheduled onto nodes that have taints.
      ## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
      ##
      tolerations: []
        # - key: "example-key"
        #   operator: "Exists"
      #   effect: "NoSchedule"
    
      ## affinity: Object defining soft rules to place pods on a specific set of Nodes or didn't place pod to nodes due to some conditions
      ##
      affinity: {}
      #  nodeAffinity:
      #      requiredDuringSchedulingIgnoredDuringExecution:
      #        nodeSelectorTerms:
      #        - matchExpressions:
      #          - key: topology.kubernetes.io/zone
      #            operator: In
      #            values:
      #            - antarctica-east1
      #            - antarctica-west1
      #      preferredDuringSchedulingIgnoredDuringExecution:
      #      - weight: 1
      #        preference:
      #          matchExpressions:
      #          - key: another-node-label-key
      #            operator: In
      #            values:
      #            - another-node-label-value
    
      startupProbe: {}
      #  type: httpGet
      #  port: 8080
      #  path: /v1/info
      #  scheme: HTTP
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      livenessProbe: {}
      #  type: httpGet
      #  port: 8080
      #  path: /v1/info
      #  scheme: HTTP
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      readinessProbe: {}
      #  type: exec
      #  command: test -f /opt/spark/etc/truststore/custom-truststore.jks
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      ## Mount additional secrets into the pod
      ##
      mountSecrets: []
      #  - secretName: my-secret
      #    mountPath: /etc/spark/my-secret
    
    driver:
      ## @param replicas set number of driver replicas
      ##
      replicas: 1
    
      ## Additional configuration that you want to be added to driver-config
      args: {}
      #  task.max-worker-threads: 8
    
      ## Annotations for driver pods
      annotations: {}
    
      ## Set container requests and limits for resource like CPU or memory (essential for production workloads)
      ##
      resources: {}
        #limits:
        #  cpu: "2"
        #  memory: "8Gi"
        #requests:
        #  cpu: "2"
      #  memory: "8Gi"
    
      ## Request additional PVC for pod
      ##
      persistentVolume: {}
      #  mountPath: "/data/spark"
      #  volumeClaimTemplates:
      #    - metadata:
      #        name: data
      #      spec:
      #        accessModes: ["ReadWriteOnce"]
      #        resources:
      #          requests:
      #            storage: 10Gi
      #        storageClassName: default
    
      ## nodeAffinity: Object defining constraints to place pods on a specific set of Nodes
      ##
      nodeSelector: {}
    
      topologySpreadConstraints: []
    
      ## Allow a Pod to be scheduled onto nodes that have taints.
      ## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
      ##
      tolerations: []
        # - key: "example-key"
        #   operator: "Exists"
      #   effect: "NoSchedule"
    
      ## affinity: Object defining soft rules to place pods on a specific set of Nodes or didn't place pod to nodes due to some conditions
      ##
      affinity: {}
      #  nodeAffinity:
      #      requiredDuringSchedulingIgnoredDuringExecution:
      #        nodeSelectorTerms:
      #        - matchExpressions:
      #          - key: topology.kubernetes.io/zone
      #            operator: In
      #            values:
      #            - antarctica-east1
      #            - antarctica-west1
      #      preferredDuringSchedulingIgnoredDuringExecution:
      #      - weight: 1
      #        preference:
      #          matchExpressions:
      #          - key: another-node-label-key
      #            operator: In
      #            values:
      #            - another-node-label-value
    
      startupProbe: {}
      #  type: httpGet
      #  port: 8080
      #  path: /v1/info
      #  scheme: HTTP
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      livenessProbe: {}
      #  type: httpGet
      #  port: 8080
      #  path: /v1/info
      #  scheme: HTTP
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      readinessProbe: {}
      #  type: exec
      #  command: test -f /opt/spark/etc/truststore/custom-truststore.jks
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      ## Mount additional secrets into the pod
      ##
      mountSecrets: []
      #  - secretName: my-secret
      #    mountPath: /etc/spark/my-secret
    
    executor:
      ## @param replicas set number of executor replicas
      ##
      replicas: 1
    
      ## Additional configuration that you want to be added to executor-config
      args: {}
      #  task.max-worker-threads: 8
    
      ## Annotations for executor pods
      annotations: {}
    
      ## Set container requests and limits for resource like CPU or memory (essential for production workloads)
      ##
      resources: {}
        #limits:
        #  cpu: "2"
        #  memory: "8Gi"
        #requests:
        #  cpu: "2"
      #  memory: "8Gi"
    
      ## Request additional PVC for pod
      ##
      persistentVolume: {}
      #  mountPath: "/data/spark"
      #  volumeClaimTemplates:
      #    - metadata:
      #        name: data
      #      spec:
      #        accessModes: ["ReadWriteOnce"]
      #        resources:
      #          requests:
      #            storage: 10Gi
      #        storageClassName: default
    
      ## nodeAffinity: Object defining constraints to place pods on a specific set of Nodes
      ##
      nodeSelector: {}
    
      topologySpreadConstraints: []
    
      ## Allow a Pod to be scheduled onto nodes that have taints.
      ## ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
      ##
      tolerations: []
        # - key: "example-key"
        #   operator: "Exists"
      #   effect: "NoSchedule"
    
      ## affinity: Object defining soft rules to place pods on a specific set of Nodes or didn't place pod to nodes due to some conditions
      ##
      affinity: {}
      #  nodeAffinity:
      #      requiredDuringSchedulingIgnoredDuringExecution:
      #        nodeSelectorTerms:
      #        - matchExpressions:
      #          - key: topology.kubernetes.io/zone
      #            operator: In
      #            values:
      #            - antarctica-east1
      #            - antarctica-west1
      #      preferredDuringSchedulingIgnoredDuringExecution:
      #      - weight: 1
      #        preference:
      #          matchExpressions:
      #          - key: another-node-label-key
      #            operator: In
      #            values:
      #            - another-node-label-value
    
      startupProbe: {}
      #  type: httpGet
      #  port: 8080
      #  path: /v1/info
      #  scheme: HTTP
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      livenessProbe: {}
      #  type: httpGet
      #  port: 8080
      #  path: /v1/info
      #  scheme: HTTP
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      readinessProbe: {}
      #  type: exec
      #  command: test -f /opt/spark/etc/truststore/custom-truststore.jks
      #  initialDelaySeconds: 20
      #  periodSeconds: 5
      #  timeoutSeconds: 3
      #  successThreshold: 1
      #  failureThreshold: 2
    
      ## Mount additional secrets into the pod
      ##
      mountSecrets: []
      #  - secretName: my-secret
      #    mountPath: /etc/spark/my-secret
    
    
    #Optional: inline Secret for properties-file pattern
    propertiesFile:
      enabled: false
      # Raw content rendered into the Secret's stringData
      content: ""
    
    #RBAC
    rbac:
      # Set to false if the ServiceAccount/Role/RoleBinding already exist
      create: false
      rules:
        - apiGroups:
            - ""
          resources:
            - pods
            - configmaps
            - persistentvolumeclaims
            - services
            - secrets
          verbs:
            - get
            - list
            - watch
            - create
            - update
            - patch
            - delete
            - deletecollection
        - apiGroups:
            - networking.k8s.io
          verbs:
            - get
            - list
            - watch
            - create
            - update
            - patch
            - delete
          resources:
            - networkpolicies
    1 Address of your OCI registry to pull images from.
    2 Name of repository in your registry.
    3 PySpark application to run.
    4 Kubernetes secret with S3 access parameters.
    5 Spark configuration section containing Celeborn settings, S3 connectivity parameters, Spark shuffle settings, and other relevant parameters. You can also specify these settings in a Kubernetes secret and then reference the secret in spark-celeborn-submit.yaml.
    6 Celeborn master endpoint. Use the value copied on the Celeborn install step.
  2. Submit the Spark application using Helm:

    $ helm upgrade --install spark-application oci://<registry-address>/adc-enterprise/charts/spark-apps:<version> -f spark-celeborn-submit.yaml --namespace spark-apps-s3 --create-namespace
  3. To ensure that Celeborn is used as a shuffle service, inspect the logs of the Celeborn master pod:

    $ kubectl logs helm-celeborn-master-0 -n spark-apps-s3
Found a mistake? Seleсt text and press Ctrl+Enter to report it