{{ if .Values.enabledComponents.dgxcExporter }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dgxc-exporter
  namespace: {{ .Release.Namespace }}
  labels:
    app.kubernetes.io/name: dgxc-exporter
    helm.sh/chart: {{ include "dgxcController.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: dgxc-exporter
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: dgxc-exporter
        app.kubernetes.io/name: dgxc-exporter
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      serviceAccount: dgxc-exporter
      imagePullSecrets:
        - name: {{ .Values.imagePullSecret | required ".Values.imagePullSecret" }}
      containers:
        - name: exporter
          image:  {{ .Values.dgxcController.image | required "dgxcController.image is required." | quote }}
          args:
            - exporter
            - --port={{ .Values.exporter.metricsPort }}
            - --zap-log-level=debug
          imagePullPolicy: Always
          {{- if eq .Values.cloudProviderSpec.type "oci" }}
          env:
          - name: OCI_RESOURCE_PRINCIPAL_VERSION
            value: {{ .Values.cloudProviderSpec.oci.resourcePrincipalVersion | quote }}
          - name: OCI_RESOURCE_PRINCIPAL_REGION
            value: {{ .Values.cloudProviderSpec.oci.region }}
          {{ end }}
          ports:
          - containerPort: {{ .Values.exporter.metricsPort }}
            protocol: TCP
      tolerations:
      - effect: NoSchedule
        key: "{{ .Values.systemTolerationKeyName }}"
        operator: Equal
        value: "{{ .Values.systemTolerationValueName }}"
      - effect: NoExecute
        key: "{{ .Values.systemTolerationKeyName }}"
        operator: Equal
        value: "{{ .Values.systemTolerationValueName }}"
{{ end }}
