apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "form-submission-validation.fullname" . }}
  labels:
    {{- include "form-submission-validation.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      {{- include "form-submission-validation.selectorLabels" . | nindent 6 }}
  template:
    metadata:
    {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
    {{- end }}
      labels:
        collect.logs: "plain-text"
        {{- include "form-submission-validation.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "form-submission-validation.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.name }}:{{ .Values.image.version }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          livenessProbe:
            tcpSocket:
              port: http
          readinessProbe:
            tcpSocket:
              port: http
          env:
            - name: FORM_PROVIDER_BASE_URL
              value: {{ .Values.environmentJs.formSchemaProviderUrl }}
            - name: DATA_FACTORY_BASE_URL
              value: {{ .Values.environmentJs.dataFactoryUrl }}
          {{- if not .Values.global.disableRequestsLimits }}
          resources:
            limits:
              cpu: 800m
              memory: 600Mi
            requests:
              cpu: 800m
              memory: 600Mi
          {{- end }}
          volumeMounts:
            - name: form-submission-validation-environment-js
              mountPath: /app/environment.js
              subPath: environment.js
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      volumes:
        - name: form-submission-validation-environment-js
          configMap:
            name: form-submission-validation-environment-js
