apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "prometheus.fullname" . }}
  labels:
    {{- include "prometheus.labels" . | nindent 4 }}
spec:
  replicas: 1
  selector:
    matchLabels:
      {{- include "prometheus.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "prometheus.labels" . | nindent 8 }}
        {{- with .Values.podLabels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
    spec:
      serviceAccountName: prometheus-sa
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          env:
          - name: POD_NAMESPACE
            value: {{ .Release.Namespace }}
          ports:
            - name: http
              containerPort: {{ .Values.service.port }}
              protocol: TCP
          resources:
            limits:
              cpu: 500m
              memory: 500Mi
            requests:
              cpu: 50m
              memory: 50Mi
          volumeMounts:
            - mountPath: /etc/metrics
              name: prometheus-meta-config
              readOnly: true
      volumes:
        - configMap:
            defaultMode: 420
            name: {{ include "prometheus.fullname" . }}-meta-config
          name: prometheus-meta-config
      {{- if not .Values.disableDedicatedNodepool }}
      nodeSelector:
        component: "metrics-integration"
      tolerations:
        - key: "app"
          operator: "Equal"
          value: "metrics-integration"
          effect: "NoSchedule"
      {{- end }}
