apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: {{ template "drakemall-devtools.fullname" . }}
  labels:
    app: {{ template "drakemall-devtools.name" . }}
    chart: {{ template "drakemall-devtools.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "drakemall-devtools.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "drakemall-devtools.name" . }}
        release: {{ .Release.Name }}
    spec:
      serviceAccountName: tiller
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          env: 
          - name: PORT
            value: "80"
          - name: NODE_ENV
            value: production
          {{ if .Values.service.loadBalancerIP }}
          - name: DOMAIN_NAME
            value: {{ .Values.service.loadBalancerIP }}
          {{ end }}
          {{ if .Values.httpProxy }}
          - name: HTTP_PROXY
            value: {{ .Values.httpProxy }}
          {{ end }}
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /health
              port: http
          readinessProbe:
            httpGet:
              path: /health
              port: http
          resources:
{{ toYaml .Values.resources | indent 12 }}
    {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}
