kind: Deployment
apiVersion: apps/v1
metadata:
  name:  {{ .Release.Name }}-maintenance
  labels:
    app.kubernetes.io/name:       "{{ .Chart.Name }}"
    app.kubernetes.io/instance:   "{{ .Release.Name }}"
    app.kubernetes.io/version:    "{{ .Chart.AppVersion }}"
    app.kubernetes.io/component:  "deployment-maintenance"
    app.kubernetes.io/part-of:    "{{ .Chart.Name }}"
    app.kubernetes.io/managed-by: "{{ .Release.Service }}"
    helm.sh/chart:                "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
  revisionHistoryLimit: {{ .Values.MAINTENANCE.REVISIONS_HISTORY_LIMIT }}
  strategy:
    rollingUpdate:
      maxUnavailable: 1
  selector:
    matchLabels:
      app: {{ .Release.Name }}-maintenance
  template:
    metadata:
      labels:
        app: {{ .Release.Name }}-maintenance
        # make sure the pod is redeployed
        rollme: {{ randAlphaNum 5 | quote }}
    spec:
      containers:
      - name: container-{{ .Release.Name }}-maintenance
        image: "{{ .Values.MAINTENANCE.DOCKER_IMAGE_REPO }}:{{ .Chart.AppVersion }}"
        imagePullPolicy: {{ .Values.MAINTENANCE.DOCKER_IMAGE_PULL_POLICY }}
        envFrom:
          - configMapRef:
              name: configmap-{{ .Release.Name }}-webapp
          - secretRef:
              name: secret-{{ .Release.Name }}-webapp
        ports:
          - containerPort: 80
      restartPolicy: {{ .Values.MAINTENANCE.CONTAINER_RESTART_POLICY }}
      terminationGracePeriodSeconds: {{ .Values.MAINTENANCE.CONTAINER_TERMINATION_GRACE_PERIOD_SECONDS }}
