apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "layer2_exporter_service.fullname" . }}
  namespace: {{ .Release.Namespace  }}
  labels:
{{ include "layer2_exporter_service.labels" . | indent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
{{ include "layer2_exporter_service.labels" . | indent 6 }}
  template:
    metadata:
      labels:
{{ include "layer2_exporter_service.labels" . | indent 8 }}
    spec:
    {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      containers:
        - name: {{ .Chart.Name }}
          image: {{ template "layer2_exporter_service.image" . }}
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          envFrom:
          - configMapRef:
              name: mservice
          - configMapRef:
              name: proxy
          - configMapRef:
              name: globalenvvar
          - configMapRef:
              name: serviceexporterconfig
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /metrics
              port: http
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /metrics
              port: http
            periodSeconds: 10
          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 }}
