# helm_charts_backup-operator-deployment.yaml
{{- if .Values.deployments.backupOperator }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "etcd-backup-operator.fullname" . }}
  labels:
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    app: {{ template "etcd-backup-operator.name" . }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
spec:
  selector:
    matchLabels:
      app: {{ template "etcd-backup-operator.fullname" . }}
      release: {{ .Release.Name }}
  replicas: {{ .Values.backupOperator.replicaCount }}
  template:
    metadata:
      name: {{ template "etcd-backup-operator.fullname" . }}
      labels:
        app: {{ template "etcd-backup-operator.fullname" . }}
        release: {{ .Release.Name }}
    spec:
      {{- if .Values.backupOperator.priorityClassName }}
      priorityClassName: {{ .Values.backupOperator.priorityClassName }}
      {{- end }}
      serviceAccountName: {{ template "etcd-operator.serviceAccountName" . }}
      containers:
      - name: {{ .Values.backupOperator.name }}
        image: "{{ .Values.backupOperator.image.repository }}:{{ .Values.backupOperator.image.tag }}"
        imagePullPolicy: {{ .Values.backupOperator.image.pullPolicy }}
        command:
        - etcd-backup-operator
{{- range $key, $value := .Values.backupOperator.commandArgs }}
        - "--{{ $key }}={{ $value }}"
{{- end }}
        env:
        - name: MY_POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: MY_POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        resources:
          limits:
            cpu: {{ .Values.backupOperator.resources.cpu }}
            memory: {{ .Values.backupOperator.resources.memory }}
          requests:
            cpu: {{ .Values.backupOperator.resources.cpu }}
            memory: {{ .Values.backupOperator.resources.memory }}
    {{- if .Values.backupOperator.nodeSelector }}
      nodeSelector: {{ toYaml .Values.backupOperator.nodeSelector | nindent 8 }}
    {{- end }}
    {{- if .Values.backupOperator.securityContext }}
      securityContext: {{ toYaml .Values.backupOperator.securityContext | nindent 8 }}
    {{- end }}
    {{- if .Values.backupOperator.tolerations }}
      tolerations: {{ toYaml .Values.backupOperator.tolerations | nindent 8 }}
    {{- end }}
{{- end }}