apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    service: backend-user
  name: backend-user
spec:
  replicas: 2
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 25%
  selector:
    matchLabels:
      service: backend-user
  template:
    metadata:
      labels:
        service: backend-user
    spec:
      containers:
      - image: noiffion/udacity-restapi-user
        name: backend-user
        imagePullPolicy: Always
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "1024Mi"
            cpu: "500m"
        env:
        - name: FRONT_URL
          valueFrom:
            configMapKeyRef:
              name: env-config
              key: FRONT_URL
        - name: POSTGRES_DB
          valueFrom:
            configMapKeyRef:
              name: env-config
              key: POSTGRES_DB
        - name: POSTGRES_HOST
          valueFrom:
            configMapKeyRef:
              name: env-config
              key: POSTGRES_HOST
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: env-secret
              key: POSTGRES_PASSWORD
        - name: POSTGRES_USERNAME
          valueFrom:
            secretKeyRef:
              name: env-secret
              key: POSTGRES_USERNAME
        - name: JWT_SECRET
          valueFrom:
            secretKeyRef:
              name: env-secret
              key: JWT_SECRET
      restartPolicy: Always


