apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    service: udagram-api-user
  name: udagram-api-user
spec:
  replicas: 2
  selector:
    matchLabels:
        service: udagram-api-user
  template:
    metadata:
      labels:
        service: udagram-api-user
    spec:
      containers:
      - image: rwilcox11/udagram-api-user:v1
        name: udagram-api-user
        imagePullPolicy: Always 
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "2048Mi"
            cpu: "500m"                 
        env:
        - name: URL
          valueFrom:
            configMapKeyRef:
              name: env-config
              key: URL
        - name: AWS_BUCKET
          valueFrom:
            configMapKeyRef:
              name: env-config
              key: AWS_BUCKET
        - name: AWS_PROFILE
          valueFrom:
            configMapKeyRef:
              name: env-config
              key: AWS_PROFILE
        - name: AWS_REGION
          valueFrom:
            configMapKeyRef:
              name: env-config
              key: AWS_REGION
        - name: JWT_SECRET
          valueFrom:
            configMapKeyRef:
              name: env-config
              key: JWT_SECRET
        - 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     
        volumeMounts:
        - name: aws-secret
          mountPath: "/root/.aws/"
          readOnly: true       
      restartPolicy: Always
      volumes:
      - name: aws-secret
        secret:
          secretName: aws-secret
