kind: StatefulSet
apiVersion: apps/v1
metadata:
  name: doris-cluster-be
  namespace: zjejpt-uas
  labels:
    app.kubernetes.io/component: doris-cluster-be
spec:
  replicas: 3
  selector:
    matchLabels:
      app.kubernetes.io/component: doris-cluster-be
  template:
    metadata:
      name: doris-cluster-be
      labels:
        app.kubernetes.io/component: doris-cluster-be
    spec:
      imagePullSecrets:
        - name: harborsecret
      volumes:
        - name: podinfo
          downwardAPI:
            items:
              - path: labels
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.labels
              - path: annotations
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.annotations
            defaultMode: 420
        - name: doris-cluster-be-conf
          configMap:
            name: doris-cluster-be-conf
            defaultMode: 420
      initContainers:
        - name: default-init
          image: '192.168.10.3:8033/cmii/alpine:1.0.0'
          command:
            - /bin/sh
          args:
            - '-c'
            - sysctl -w vm.max_map_count=2000000 && swapoff -a
          resources:
            limits:
              cpu: '2'
              memory: 2Gi
            requests:
              cpu: '1'
              memory: 1Gi
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
      containers:
        - name: be
          image: '192.168.10.3:8033/cmii/doris.be-amd64:2.1.6'
          command:
            - /opt/apache-doris/be_entrypoint.sh
          args:
            - $(ENV_FE_ADDR)
          ports:
            - name: be-port
              containerPort: 9060
              protocol: TCP
            - name: webserver-port
              containerPort: 8040
              protocol: TCP
            - name: heartbeat-port
              containerPort: 9050
              protocol: TCP
            - name: brpc-port
              containerPort: 8060
              protocol: TCP
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.name
            - name: POD_IP
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: status.podIP
            - name: HOST_IP
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: status.hostIP
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.namespace
            - name: CONFIGMAP_MOUNT_PATH
              value: /etc/doris
            - name: USER
              value: root
            - name: DORIS_ROOT
              value: /opt/apache-doris
            - name: ENV_FE_ADDR
              value: doris-cluster-fe-service
            - name: FE_QUERY_PORT
              value: '9030'
          resources:
            limits:
              cpu: '16'
              memory: 32Gi
            requests:
              cpu: '8'
              memory: 32Gi
          volumeMounts:
            - name: podinfo
              mountPath: /etc/podinfo
            - name: be-storage
              mountPath: /opt/apache-doris/be/storage
            - name: be-storage
              mountPath: /opt/apache-doris/be/log
            - name: doris-cluster-be-conf
              mountPath: /etc/doris
          livenessProbe:
            tcpSocket:
              port: 9050
            initialDelaySeconds: 80
            timeoutSeconds: 180
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /api/health
              port: 8040
              scheme: HTTP
            timeoutSeconds: 1
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
          startupProbe:
            tcpSocket:
              port: 9050
            timeoutSeconds: 1
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 60
          lifecycle:
            preStop:
              exec:
                command:
                  - /opt/apache-doris/be_prestop.sh
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      securityContext: {}
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            - labelSelector:
                matchExpressions:
                  - key: app.kubernetes.io/component
                    operator: In
                    values: [ "doris-cluster-be" ]
              topologyKey: "kubernetes.io/hostname"
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
              - matchExpressions:
                  - key: doris-be-node
                    operator: In
                    values: [ "true" ]
      schedulerName: default-scheduler
  volumeClaimTemplates:
    - metadata:
        name: be-storage
      spec:
        accessModes: [ "ReadWriteOnce" ]
        storageClassName: "local-storage"
        resources:
          requests:
            storage: 1500Gi
  serviceName: doris-cluster-be-internal
  podManagementPolicy: Parallel