---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: etcd
  labels:
    app: {{ template "etcd.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
    suite: pachyderm
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{ template "etcd.fullname" . }}
      suite: pachyderm
  template:
    metadata:
      name: etcd
      labels:
        app: {{ template "etcd.fullname" . }}
        suite: pachyderm
    spec:
      volumes:
        - name: etcdvol
        {{- if .Values.etcd.persistence.enabled }}
          persistentVolumeClaim:
            claimName: {{ template "etcd.fullname" . }}-pvc
        {{- else }}
          hostPath:
           path: "/var/pachyderm/etcd"
        {{- end }}
      containers:
        - name: etcd
          image: '{{ .Values.etcd.image.repository }}:{{ .Values.etcd.image.tag }}'
          command:
          - "/usr/local/bin/etcd"
          - "--listen-client-urls=http://0.0.0.0:2379"
          - "--advertise-client-urls=http://0.0.0.0:2379"
          - "--data-dir=/var/data/etcd"
          - "--auto-compaction-retention=1"
          - "--max-txn-ops=5000"
          ports:
            - name: client-port
              containerPort: 2379
            - name: peer-port
              containerPort: 2380
          resources:
           requests:
            cpu: '{{ .Values.etcd.resources.requests.cpu }}'
            memory: {{ .Values.etcd.resources.requests.memory }}
          volumeMounts:
            - name: etcdvol
              mountPath: "/var/data/etcd"
          imagePullPolicy: {{ .Values.etcd.image.pullPolicy }}
