kind: Deployment
apiVersion: apps/v1
metadata:
  name: {{ include "cni-metrics-helper.fullname" . }}
  namespace: {{ .Release.Namespace }}
  labels:
    k8s-app: cni-metrics-helper
{{ include "cni-metrics-helper.labels" . | indent 4 }}
spec:
{{- if .Values.updateStrategy }}
  strategy: {{ toYaml .Values.updateStrategy | nindent 4 }}
{{- end }}
  revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
  selector:
    matchLabels:
      k8s-app: cni-metrics-helper
  template:
    metadata:
      {{- if .Values.podAnnotations }}
      annotations:
      {{- range $key, $value := .Values.podAnnotations }}
        {{ $key }}: {{ $value | quote }}
      {{- end }}
      {{- end }}
      labels:
        app.kubernetes.io/name: {{ include "cni-metrics-helper.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
        k8s-app: cni-metrics-helper
    spec:
      containers:
      - env:
{{- range $key, $value := .Values.env }}
        - name: {{ $key }}
          value: {{ $value | quote }}
{{- end }}
{{- if .Values.resources }}
        resources: {{ toYaml .Values.resources | nindent 10 }}
{{- end }}
{{- if .Values.containerSecurityContext }}
        securityContext: {{ toYaml .Values.containerSecurityContext | nindent 10 }}
{{- end }}
        name: cni-metrics-helper
        image: "{{- if .Values.image.override }}{{- .Values.image.override }}{{- else }}{{- .Values.image.account }}.dkr.ecr.{{- .Values.image.region }}.{{- .Values.image.domain }}/cni-metrics-helper:{{- .Values.image.tag }}{{- end}}"
{{- if eq (get .Values.env "USE_PROMETHEUS") "true" }}
        ports:
        - containerPort: 61681
          name: metrics
{{- end }}
      serviceAccountName: {{ template "cni-metrics-helper.serviceAccountName" . }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.podSecurityContext }}
      securityContext: {{ toYaml .Values.podSecurityContext | nindent 8 }}
      {{- end }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}