apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-chamados
spec:
  replicas: 1
  minReadySeconds: 30
  strategy:
    rollingUpdate:
      maxSurge: 3
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: api-chamados
  selector:
    matchLabels:
      app: api-chamados
  template:
    metadata:
      labels:
        app: api-chamados
    spec:
      containers:
      - name: api-chamados
        image: rjorge/api-chamados:8
        command: ["npm", "run", "startContainer"]
        ports:
        - name: nodejs-port
          containerPort: 8080
        resources:
          requests:
            cpu: 100m
        env:
          - name: DB_HOST
            value: postgres
          - name: DB_USER
            valueFrom:
              secretKeyRef:
                name: api-chamados-secrets
                key: DB_USER
          - name: DB_PASS
            valueFrom:
              secretKeyRef:
                name: api-chamados-secrets
                key: DB_PASS
          - name: DB_NAME
            valueFrom:
              configMapKeyRef:
                name: postgres-config
                key: DB_NAME
          - name: DB_DIALECT
            valueFrom:
              configMapKeyRef:
                name: postgres-config
                key: DB_DIALECT
        livenessProbe:
          httpGet:
            path: /users
            port: nodejs-port
          initialDelaySeconds: 10
          timeoutSeconds: 30
        readinessProbe:
          httpGet:
            path: /users
            port: nodejs-port
          initialDelaySeconds: 15
          timeoutSeconds: 30