apiVersion: "apps/v1"
kind: StatefulSet
metadata:
  name: codis-dashboard
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: codis-dashboard
  serviceName: codis-dashboard
  template:
    metadata:
      labels:
        app.kubernetes.io/name: codis-dashboard
    spec:
      # imagePullSecrets:
      # - name: your-registry
      containers:
      - name: codis-dashboard
        image: codis-image:local
        imagePullPolicy: Never
        command: ["codis-dashboard"]
        args: ["-c","$(CODIS_PATH)/config/dashboard.toml","--host-admin","$(POD_IP):18080", "--zookeeper","$(ZK_ADDR)","--product_name","$(PRODUCT_NAME)","--pidfile","log/dashboard.pid","--remove-lock"]
        # lifecycle:
        #   postStart:
        #     exec:
        #       command: ["/bin/bash", "-c", "codis-admin --dashboard-list  --zookeeper=${ZK_ADDR}"]
        #   preStop:
        #     exec:
        #       command: [/bin/sh", "-c", "PID=$(cat log/dashboard.pid) && kill $PID && while ps -p 1 > /dev/null; do sleep 1; done"]
        env:
        - name: CODIS_PATH
          value: "/gopath/src/github.com/CodisLabs/codis"
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: ZK_ADDR
          value: "zookeeper:2181"
        - name: PRODUCT_NAME
          value: "codis-test"
        #- name: PRODUCT_AUTH
        #  value: ""
        ports:
        - containerPort: 18080
          name: dashboard
        resources:
          limits:
            cpu: "4"
            memory: 4Gi
          requests:
            cpu: "0.1"
            memory: 0.1Gi
