apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "prometheus-nats-exporter.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "prometheus-nats-exporter.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    helm.sh/chart: {{ include "prometheus-nats-exporter.chart" . }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "prometheus-nats-exporter.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "prometheus-nats-exporter.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
      annotations:
{{- if .Values.annotations }}
{{ toYaml .Values.annotations | indent 8 }}
{{- end}}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          args:
            - "-port"
            - "{{ .Values.service.targetPort }}"
            {{- if .Values.config.metrics.varz }}
            - "-varz"
            {{- end }}
            {{- if .Values.config.metrics.channelz }}
            - "-channelz"
            {{- end }}
            {{- if .Values.config.metrics.connz }}
            - "-connz"
            {{- end }}
            {{- if .Values.config.metrics.routez }}
            - "-routez"
            {{- end }}
            {{- if .Values.config.metrics.serverz }}
            - "-serverz"
            {{- end }}
            {{- if .Values.config.metrics.subz }}
            - "-subz"
            {{- end }}
            {{- if .Values.config.metrics.gatewayz }}
            - "-gatewayz"
            {{- end }}
            - "http://{{ .Values.config.nats.service }}.{{ .Values.config.nats.namespace }}.svc:{{ .Values.config.nats.port }}"
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: {{ .Values.service.targetPort }}
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /metrics
              port: http
          readinessProbe:
            httpGet:
              path: /metrics
              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 }}
{{- with .Values.extraVolumes }}
{{ tpl . $ | indent 6 }}
{{- end }}
