apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "sm2-schemas.fullname" . }}
  labels:
{{ include "sm2-schemas.labels" . | indent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
  strategy:
    type: RollingUpdate
    rollingUpdate:
{{ toYaml .Values.rollingUpdate | indent 6 }}
  selector:
    matchLabels:
      name: {{ include "sm2-schemas.name" . }}
      instance: {{ .Release.Name }}
      branch: {{ .Values.labels.branch }}
      app: {{ .Values.labels.app }}
  template:
    metadata:
      labels:
        name: {{ include "sm2-schemas.name" . }}
        instance: {{ .Release.Name }}
        branch: {{ .Values.labels.branch }}
        app: {{ .Values.labels.app }}
    spec:
    {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      containers:
      - name: {{ .Chart.Name }}
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        ports:
        - name: http
          containerPort: 80
{{- if .Values.healthProbes }}
        livenessProbe:
          httpGet:
            path: "{{ default "" .Values.authUriPrefix }}/"
            port: http
          initialDelaySeconds: {{ default "" .Values.healthProbeLivenessInitialDelay }}
          periodSeconds: {{ default "" .Values.healthProbeLivenessPeriodSeconds }}
          timeoutSeconds: {{ default "" .Values.healthProbesLivenessTimeout }}
          failureThreshold: {{ default "" .Values.healthProbeLivenessFailureThreshold }}
        readinessProbe:
          httpGet:
            path: "{{ default "" .Values.authUriPrefix }}/"
            port: http
          initialDelaySeconds: {{ default "" .Values.healthProbeReadinessInitialDelay }}
          periodSeconds: {{ default "" .Values.healthProbeReadinessPeriodSeconds }}
          timeoutSeconds: {{ default "" .Values.healthProbesReadinessTimeout }}
          failureThreshold: {{ default "" .Values.healthProbeReadinessFailureThreshold }}
{{- end}}
        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 }}