apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zookeeper-server
spec:
  selector:
    matchLabels: {}
  serviceName: zookeeper-server
  podManagementPolicy: Parallel
  replicas: 3
  template:
    spec:
      initContainers:
      - name: wait-for-dns
        image: zookage-util
        args:
        - wait-for-dns
      - name: init
        image: zookage-zookeeper
        command:
        - /bin/bash
        args:
        - -c
        - |
          readonly myid=$(( ${POD_NAME##*-} + 1 ))
          /opt/zookeeper/bin/zkServer-initialize.sh "--configfile=${ZOOCFGDIR}/zoo.cfg" "--myid=${myid}"
        envFrom:
        - configMapRef:
            name: zookeeper-env
        env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        volumeMounts:
        - name: zookeeper-conf
          mountPath: /etc/zookeeper/conf
        - name: mnt
          mountPath: /mnt
      containers:
      - name: server
        image: zookage-zookeeper
        command:
        - /opt/zookeeper/bin/zkServer.sh
        args:
        - start-foreground
        envFrom:
        - configMapRef:
            name: zookeeper-env
        readinessProbe:
          exec:
            command:
            - /opt/zookeeper/bin/zkServer.sh
            - status
        volumeMounts:
        - name: zookeeper-conf
          mountPath: /etc/zookeeper/conf
        - name: mnt
          mountPath: /mnt
      terminationGracePeriodSeconds: 5
      volumes:
      - name: zookeeper-conf
        configMap:
          name: zookeeper-conf
      - name: mnt
        emptyDir: {}
  volumeClaimTemplates: []
