# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: v1
kind: Service
metadata:
  name: zoo
  namespace: voltha
spec:
  clusterIP: None
  selector:
    app: zookeeper
  ports:
  - name: client
    port: 2181
    targetPort: 2181
  - name: follower
    port: 2888
    targetPort: 2888
  - name: leader
    port: 3888
    targetPort: 3888
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: zookeeper
  namespace: voltha
spec:
  serviceName: zoo
  replicas: 1
  selector:
    matchLabels:
      app: zookeeper
  template:
    metadata:
      labels:
        app: zookeeper
      annotations:
        cni: "calico"
    spec:
      containers:
      - name: zoo
        image: zookeeper:3.4.11
        ports:
        - containerPort: 2181
        - containerPort: 2888
        - containerPort: 3888
        env:
        - name: NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: ZOO_MY_ID
          value: "1"
#        - name: ZOO_SERVERS
#          value: >
#            server.1=zookeeper1-0.zoo1.$(NAMESPACE).svc.cluster.local:2888:3888

