kind: Deployment
apiVersion: apps/v1
metadata:
  name: zeppelin-server
  labels:
    app.kubernetes.io/name: zeppelin-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: zeppelin-server
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: zeppelin-server
    spec:
      serviceAccountName: zeppelin-server
      containers:
        - name: zeppelin-server
          image: apache/zeppelin
          # $(ZEPPELIN_K8S_CONTAINER_IMAGE) is defined in kustomization.yml, which Interpreter needs to know.
          command: ["sh", "-c", "ZEPPELIN_K8S_CONTAINER_IMAGE=$(ZEPPELIN_K8S_CONTAINER_IMAGE) $(ZEPPELIN_HOME)/bin/zeppelin.sh"]
          lifecycle:
            preStop:
              exec:
                # SIGTERM triggers a quick exit; gracefully terminate instead
                command:
                  [
                    "sh",
                    "-c",
                    "ps -ef | grep org.apache.zeppelin.server.ZeppelinServer | grep -v grep | awk '{print $2}' | xargs kill",
                  ]
          ports:
            - name: http
              containerPort: 8080
            - name: https
              containerPort: 8443
            - name: rpc
              containerPort: 12320
          env:
            - name: POD_UID
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.uid
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.name
          envFrom:
            - configMapRef:
                name: zeppelin-server-conf-map

