{{- if semverCompare "^1.9-0" .Capabilities.KubeVersion.GitVersion }}
apiVersion: apps/v1
{{- else }}
apiVersion: apps/v1beta1
{{- end }}
kind: Deployment
metadata:
  labels: {{ include "eventrouter.labels" . | indent 4 }}
  name: {{ template "eventrouter.fullname" . }}
  namespace: {{ .Release.Namespace }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "eventrouter.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "eventrouter.name" . }}
        release: {{ .Release.Name }}
    {{- if .Values.podAnnotations }}
      annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
    {{- end }}
    spec:
      containers:
      - name: {{ .Chart.Name }}
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        volumeMounts:
          - name: config-volume
            mountPath: /etc/eventrouter
    {{- if .Values.containerPorts }}
        ports:
{{ toYaml .Values.containerPorts | indent 10 }}
    {{- end }}
        resources:
{{ toYaml .Values.resources | indent 10 }}
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}
    {{- if .Values.tolerations }}
      tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
    {{- end }}
    {{- if .Values.securityContext }}
      securityContext:
{{ toYaml .Values.securityContext | indent 8 }}
    {{- end }}
      serviceAccountName: {{ template "eventrouter.serviceAccountName" . }}
      volumes:
        - name: config-volume
          configMap:
            name: {{ template "eventrouter.fullname" . }}
