apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "endpoint-copier-operator.fullname" . }}
  labels:
    {{- include "endpoint-copier-operator.labels" . | nindent 4 }}
spec:
  selector:
    matchLabels:
      {{- include "endpoint-copier-operator.selectorLabels" . | nindent 6 }}
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "endpoint-copier-operator.selectorLabels" . | nindent 8 }}
    spec:
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
      - command:
        - /manager
        args:
        - --leader-elect
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
        name: manager
        securityContext:
          {{- toYaml .Values.securityContext | nindent 10 }}
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8081
          initialDelaySeconds: 15
          periodSeconds: 20
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8081
          initialDelaySeconds: 5
          periodSeconds: 10
        resources:
          {{- toYaml .Values.resources | nindent 10 }}
      serviceAccountName: {{ include "endpoint-copier-operator.serviceAccountName" . }}
      terminationGracePeriodSeconds: 10