apiVersion: apps/v1
kind: Deployment
metadata:
  name: sapawarga-api
  namespace: sapawarga
  labels:
    app: sapawarga-api
spec:
  selector:
    matchLabels:
      app: sapawarga-api
  template:
    metadata:
      labels:
        app: sapawarga-api
    spec:
      automountServiceAccountToken: false
      containers:
        - name: api
          image: registry.gitlab.com/jdsteam/sapa-warga/sapawarga-app/sapawarga-backend-api:%VERSION%
          ports:
            - containerPort: 80
          readinessProbe:
            tcpSocket:
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 10
          livenessProbe:
            tcpSocket:
              port: 80
            initialDelaySeconds: 15
            periodSeconds: 20
          envFrom:
            - configMapRef:
                name: sapawarga-backend-config-env
            - secretRef:
                name: sapawarga-backend-secret
          resources:
            requests:
              memory: "64Mi"
              cpu: "50m"
            limits:
              memory: "1024Mi"
              cpu: "250m"
      imagePullSecrets:
        - name: regcred
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 1
            preference:
              matchExpressions:
              - key: kubernetes.io/hostname
                operator: In
                values:
                - staging-worker-sw01
                - staging-worker-sw02
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: beta.kubernetes.io/os
                operator: In
                values:
                - linux
