apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "k8s-metacollector.fullname" . }}
  namespace: {{ include "k8s-metacollector.namespace" . }}
  labels:
    {{- include "k8s-metacollector.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      {{- include "k8s-metacollector.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "k8s-metacollector.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.image.pullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "k8s-metacollector.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.containerSecurityContext | nindent 12 }}
          image: {{ include "k8s-metacollector.image" . }}
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          command:
            - /meta-collector
          args:
            - run
          ports:
            {{- include "k8s-metacollector.containerPorts" . | indent 12}}
          {{- with .Values.healthChecks.livenessProbe }}
          livenessProbe:
            {{- toYaml . | nindent 12}}
          {{- end }}
          {{- with .Values.healthChecks.readinessProbe }}
          readinessProbe:
             {{- toYaml . | nindent 12}}
          {{- end }}
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
