apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: face-check
  name: backend
  namespace: face-check
spec:
  replicas: 2
  selector:
    matchLabels:
      app: face-check-backend
  template:
    metadata:
      name: face-check-backend
      labels:
        app: face-check-backend
    spec:
      volumes:
        - name: static-volume
          emptyDir: {}
      imagePullSecrets:
        - name: registry-blacklibrary
      initContainers:
        - name: init
          image: registry.blacklibrary.ru/face-check:dev
          imagePullPolicy: Always
          command:
            - /bin/sh
            - -c
            - STATIC_ROOT=/static/ site-manage collectstatic --noinput
              && site-manage migrate --noinput

          envFrom:
            - configMapRef:
                name: "face-check"
            - secretRef:
                name: "face-check"
          volumeMounts:
            - mountPath: /static
              name: static-volume
              readOnly: false
      containers:
        - name: application
          image: registry.blacklibrary.ru/face-check:dev
          imagePullPolicy: Always
          envFrom:
            - configMapRef:
                name: "face-check"
            - secretRef:
                name: "face-check"
          volumeMounts:
            - mountPath: /static/
              name: static-volume
              readOnly: true
          resources:
            limits:
              cpu: 200m
              memory: 128Mi
          #: health section
          readinessProbe:
            httpGet:
              port: 8000
              path: /status/
            failureThreshold: 3
            initialDelaySeconds: 2
            successThreshold: 1
            periodSeconds: 5
            timeoutSeconds: 2
          livenessProbe:
            httpGet:
              port: 8000
              path: /healthz/
            initialDelaySeconds: 2
            timeoutSeconds: 2
            periodSeconds: 5
