apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: {{ template "dacap.fullname" . }}
  labels:
    app: {{ template "dacap.name" . }}
    chart: {{ template "dacap.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "dacap.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "dacap.name" . }}
        release: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 3000
              protocol: TCP
          livenessProbe:
            tcpSocket:
              port: http
          readinessProbe:
            tcpSocket:
              port: http
          volumeMounts:
          - mountPath: /data
            name: data
          envFrom:
          - configMapRef:
              name: {{ .Release.Name }}-environment
              key: environment
          resources:
{{ toYaml .Values.resources | indent 12 }}

      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: {{ .Release.Name }}-data
{{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}
