#
# 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.
#

# Default values for celeborn.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

# -- String to override the default generated name
nameOverride: ""

# -- String to override the default generated fullname
fullnameOverride: ""

# Specifies the Celeborn image to use
image:
  # -- Image repository
  repository: aliyunemr/remote-shuffle-service
  # -- Image tag
  tag: 0.1.1-6badd20
  # -- Image pull policy
  pullPolicy: Always
  # -- Image name for init containter. (your-private-repo/alpine:3.18)
  initContainerImage: alpine:3.18

# -- Image pull secrets for private image registry
imagePullSecrets: []

# -- Specifies the number of Celeborn master replicas to deploy, master replicas should not less than 3
masterReplicas: 3
# -- Specifies the number of Celeborn worker replicas to deploy, should less than node number
workerReplicas: 5

service:
  # -- Specifies service type
  type: ClusterIP
  # -- Specifies service port
  port: 9097

cluster:
  # -- Specifies Kubernetes cluster name
  name: cluster

# Specifies Celeborn volumes.
# Currently supported volume types are `emptyDir` and `hostPath`.
# Note that `hostPath` only works in hostPath type using to set `volumes hostPath path`.
# Celeborn Master will pick first volumes for store raft log.
# `diskType` only works in Celeborn Worker with hostPath type to manifest local disk type.
volumes:
  # -- Specifies volumes for Celeborn master pods
  master:
    - mountPath: /mnt/celeborn_ratis
      hostPath: /mnt/celeborn_ratis
      type: hostPath
      capacity: 100Gi
  # -- Specifies volumes for Celeborn worker pods
  worker:
    - mountPath: /mnt/disk1
      hostPath: /mnt/disk1
      type: hostPath
      diskType: SSD
      capacity: 100Gi
    - mountPath: /mnt/disk2
      hostPath: /mnt/disk2
      type: hostPath
      diskType: SSD
      capacity: 100Gi
    - mountPath: /mnt/disk3
      hostPath: /mnt/disk3
      type: hostPath
      diskType: SSD
      capacity: 100Gi
    - mountPath: /mnt/disk4
      hostPath: /mnt/disk4
      type: hostPath
      diskType: SSD
      capacity: 100Gi

# -- Celeborn configurations
celeborn:
  celeborn.master.ha.enabled: true
  celeborn.metrics.enabled: true
  celeborn.metrics.prometheus.path: /metrics/prometheus
  celeborn.master.http.port: 9098
  celeborn.worker.http.port: 9096
  celeborn.worker.monitor.disk.enabled: false
  celeborn.shuffle.chunk.size: 8m
  celeborn.rpc.io.serverThreads: 64
  celeborn.rpc.io.numConnectionsPerPeer: 2
  celeborn.rpc.io.clientThreads: 64
  celeborn.rpc.dispatcher.numThreads: 4
  celeborn.worker.flusher.buffer.size: 256K
  celeborn.worker.fetch.io.threads: 32
  celeborn.worker.push.io.threads: 32
  celeborn.push.stageEnd.timeout: 120s
  celeborn.application.heartbeat.timeout: 120s
  celeborn.worker.heartbeat.timeout: 120s

# -- Celeborn environment variables
environments:
  CELEBORN_MASTER_MEMORY: 2g
  CELEBORN_MASTER_JAVA_OPTS: "-XX:-PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:gc-master.out -Dio.netty.leakDetectionLevel=advanced"
  CELEBORN_WORKER_MEMORY: 2g
  CELEBORN_WORKER_OFFHEAP_MEMORY: 12g
  CELEBORN_WORKER_JAVA_OPTS: "-XX:-PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -Xloggc:gc-worker.out -Dio.netty.leakDetectionLevel=advanced"
  CELEBORN_NO_DAEMONIZE: 1
  TZ: "Asia/Shanghai"

# -- Specifies the DNS policy for Celeborn pods to use
dnsPolicy: ClusterFirst

# -- Specifies whether to use the host's network namespace
hostNetwork: false

resources:
  # -- Pod resources for Celeborn master pods
  master: {}
    # limits:
    #   cpu: 100m
    #   memory: 128Mi
    # requests:
    #   cpu: 100m
    #   memory: 128Mi

  # -- Pod resources for Celeborn worker pods
  worker: {}
    # limits:
    #   cpu: 100m
    #   memory: 128Mi
    # requests:
    #   cpu: 100m
    #   memory: 128Mi

# -- Container security context
securityContext:
  # Specifies the user ID to run the entrypoint of the container process
  runAsUser: 10006
  # Specifies the group ID to run the entrypoint of the container process
  runAsGroup: 10006
  # Specifies the group ID to use when modifying ownership and permissions of the mounted volumes
  fsGroup: 10006

priorityClass:
  # Priority class for Celeborn master pods
  master:
    # -- Specifies whether a new priority class for Celeborn master pods should be created
    create: false
    # -- Specifies the name of priority class for Celeborn master pods to be used (created if `create: true`), empty means `${Release.Name}-master-priority-class`
    name: ""
    # -- Specifies the integer value of this priority class, default is half of system-cluster-critical
    value: 1000000000

  # Priority class for Celeborn worker pods
  worker:
    # -- Specifies whether a new priority class for Celeborn worker pods should be created
    create: false
    # -- Specifies the name of priority class for Celeborn worker pods to be used (created if `create: true`), empty means `${Release.Name}-worker-priority-class`
    name: ""
    # -- Specifies the integer value of this priority class, default is Celeborn master value minus 1000
    value: 999999000

# -- Pod annotations
podAnnotations: {}
# key1: value1
# key2: value2

# -- Pod node selector
nodeSelector: {}
# key1: value1
# key2: value2

# -- Pod tolerations
tolerations: []
# - key: key1
#   operator: Equal
#   value: value1
#   effect: NoSchedule
# - key: key2
#   operator: Exists
#   effect: NoSchedule

affinity:
  # -- Pod affinity for Celeborn master pods
  master:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: app.kubernetes.io/name
                operator: In
                values:
                  - celeborn
              - key: app.kubernetes.io/role
                operator: In
                values:
                  - master
          topologyKey: kubernetes.io/hostname
  # -- Pod affinity for Celeborn worker pods
  worker:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: app.kubernetes.io/name
                operator: In
                values:
                  - celeborn
              - key: app.kubernetes.io/role
                operator: In
                values:
                  - worker
          topologyKey: "kubernetes.io/hostname"

podMonitor:
  # -- Specifies whether to enable creating pod monitors for Celeborn pods
  enable: true
  # -- Specifies pod metrics endpoint
  podMetricsEndpoint:
    # Specifies scheme
    scheme: http
    # Specifies scrape interval
    interval: 5s
    # Specifies port name
    portName: metrics
