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