apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}
spec:
  replicas: {{ .Values.app.replicas }}
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Release.Name }}
          imagePullPolicy: Always
          image: {{ .Values.app.image }}
          {{ if .Values.app.cron }}
          command: ["node", "./build/cron.cjs"]
          {{ else }}
          livenessProbe:
            httpGet:
              path: /healthcheck
              port: {{ .Values.app.port }}
            initialDelaySeconds: 60
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /healthcheck
              port: {{ .Values.app.port }}
            initialDelaySeconds: 5
            periodSeconds: 10
          ports:
            - containerPort: {{ .Values.app.port }}
              name: http
          {{ end }}
          envFrom:
          - configMapRef:
              name: {{ .Chart.Name }}