apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "prometheus-mongodb-exporter.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "prometheus-mongodb-exporter.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    helm.sh/chart: {{ include "prometheus-mongodb-exporter.chart" . }}
  annotations:
    {{- toYaml .Values.annotations | nindent 4 }}
spec:
  replicas: {{ .Values.replicas }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "prometheus-mongodb-exporter.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "prometheus-mongodb-exporter.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      containers:
      - name: mongodb-exporter
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        args:
        - -mongodb.uri={{ required "A MongoDB URI is required" .Values.mongodb.uri }}
        {{- toYaml .Values.extraArgs | nindent 8 }}
        ports:
        - name: metrics
          containerPort: 9216
          protocol: TCP
        livenessProbe:
          {{- toYaml .Values.livenessProbe | nindent 10 }}
        readinessProbe:
          {{- toYaml .Values.readinessProbe | nindent 10 }}
        resources:
          {{- toYaml .Values.resources | nindent 10 }}
        securityContext:
          {{- toYaml .Values.securityContext | nindent 10 }}
      affinity:
        {{- toYaml .Values.affinity | nindent 8 }}
      imagePullSecrets:
        {{- toYaml .Values.imagePullSecrets | nindent 8 }}
      nodeSelector:
        {{- toYaml .Values.nodeSelector | nindent 8 }}
      {{- if .Values.priorityClassName }}
      priorityClassName: {{ .Values.priorityClassName }}
      {{- end }}
      terminationGracePeriodSeconds: 30
      tolerations:
        {{- toYaml .Values.tolerations | nindent 8 }}

