apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-deployment
  labels:
    name: api
spec:
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
      maxSurge: 1
  replicas: 2
  selector:
    matchLabels:
      component: api
  template:
    metadata:
      labels:
        component: api
    spec:
      containers:
        - image: $IMAGE_NAME
          name: api
          ports:
            - containerPort: 8080
              name: api
          imagePullPolicy: Always
          command: ["yarn", "start"]
          livenessProbe:
            httpGet:
              path: /api/health
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 5
          env:
            - name: NODE_ENV
              value: production
            - name: PORT
              value: "8080"
            - name: MONGO_URL
              valueFrom:
                secretKeyRef:
                  name: api-envs
                  key: mongo_url
            - name: JWT_SECRET
              valueFrom:
                secretKeyRef:
                  name: api-envs
                  key: jwt_secret
            - name: COOKIE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: api-envs
                  key: cookie_password
            - name: SWAGGER
              value: "true"
            - name: ADMIN
              value: "true"
