kubernetes/test/e2e/testing-manifests/statefulset/zookeeper/statefulset.yaml

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zoo
spec:
  serviceName: "zk"
  replicas: 3
  selector:
    matchLabels:
      app: zk
  template:
    metadata:
      labels:
        app: zk
    spec:
      initContainers:
      - name: install
        image: registry.k8s.io/e2e-test-images/pets/zookeeper-installer:1.5
        imagePullPolicy: Always
        args:
        - "--install-into=/opt"
        - "--work-dir=/work-dir"
        volumeMounts:
        - name: opt
          mountPath: "/opt/"
        - name: workdir
          mountPath: "/work-dir"
      - name: bootstrap
        image: java:openjdk-8-jre
        command:
        - "/work-dir/peer-finder"
        args:
        - -on-start="/work-dir/on-start.sh"
        - "-service=zk"
        env:
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
        volumeMounts:
        - name: opt
          mountPath: "/opt"
        - name: workdir
          mountPath: "/work-dir"
        - name: datadir
          mountPath: "/tmp/zookeeper"
      containers:
      - name: zk
        image: openjdk:8-jre
        ports:
        - containerPort: 2888
          name: peer
        - containerPort: 3888
          name: leader-election
        command:
        - /opt/zookeeper/bin/zkServer.sh
        args:
        - start-foreground
        readinessProbe:
          exec:
            command:
            - sh
            - -c
            - "/opt/zookeeper/bin/zkCli.sh ls /"
          initialDelaySeconds: 15
          timeoutSeconds: 5
        volumeMounts:
        - name: datadir
          mountPath: /tmp/zookeeper
        - name: opt
          mountPath: /opt
        # Mount the work-dir just for debugging
        - name: workdir
          mountPath: /work-dir
      volumes:
      - name: opt
        emptyDir: {}
      - name: workdir
        emptyDir: {}
  volumeClaimTemplates:
  - metadata:
      name: datadir
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi