apiVersion: apps/v1beta2
kind: Deployment
metadata:
  labels:
    app: {{ template "kubewatch.name" . }}
    chart: {{ template "kubewatch.chart" . }}
    heritage: "{{ .Release.Service }}"
    release: "{{ .Release.Name }}"
  name: {{ template "kubewatch.fullname" . }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "kubewatch.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      annotations:
        checksum/config-map: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
      {{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
      {{- end }}
      labels:
        app: {{ template "kubewatch.name" . }}
        release: "{{ .Release.Name }}"
        chart: {{ template "kubewatch.chart" . }}
      {{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
      {{- end }}
    spec:
      containers:
      - name: {{ template "kubewatch.name" . }}
        image: {{ template "kubewatch.image" . }}
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        volumeMounts:
        - name: {{ template "kubewatch.name" . }}-config-map
          mountPath: /opt/bitnami/kubewatch/.kubewatch.yaml
          subPath: .kubewatch.yaml
        resources:
{{ toYaml .Values.resources | indent 10 }}
    {{- if .Values.affinity }}
      affinity:
{{ toYaml .Values.affinity | indent 8 }}
    {{- end }}
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}
      serviceAccountName: {{ template "kubewatch.serviceAccountName" . }}
      tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
      restartPolicy: Always
      volumes:
      - name: {{ template "kubewatch.name" . }}-config-map
        configMap:
          name: {{ template "kubewatch.fullname" . }}-config
