{{- if eq .Values.global.deploymentMode "development" }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "wiremock.fullname" . }}
  labels:
    app.kubernetes.io/name: {{ include "wiremock.name" . }}
    helm.sh/chart: {{ include "wiremock.chart" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "wiremock.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      annotations:
        backup.velero.io/backup-volumes: root-dir
      labels:
        app.kubernetes.io/name: {{ include "wiremock.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      securityContext:
        runAsUser: 1000
        fsGroup: 1000
      serviceAccountName: {{ .Release.Name }}
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.name }}:{{ .Values.image.version }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          {{- if .Values.env }}
          env:
          {{- end }}
          {{- range $key, $value := .Values.env }}
          - name: {{ $key }}
            value: {{ tpl $value $ | quote }}
          {{- end }}
          ports:
            - containerPort: {{ .Values.service.internalPort }}
              protocol: TCP
            - containerPort: {{ .Values.jvmMetrics.port }}
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /__admin/webapp
              port: {{ .Values.service.internalPort }}
              scheme: {{ .Values.scheme }}
          readinessProbe:
            httpGet:
              path: /__admin/webapp
              port: {{ .Values.service.internalPort }}
              scheme: {{ .Values.scheme }}
          resources:
{{ toYaml .Values.resources | indent 12 }}
          volumeMounts:
            - mountPath: /home/wiremock/storage
              name: root-dir
    {{- with .Values.nodeSelector }}
      nodeSelector:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.affinity }}
      affinity:
{{ toYaml . | indent 8 }}
    {{- end }}
    {{- with .Values.tolerations }}
      tolerations:
{{ toYaml . | indent 8 }}
    {{- end }}
      volumes:
        - name: root-dir
          persistentVolumeClaim:
            claimName: {{ .Values.wiremock.volume.claimName }}
  {{- end }}
