apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: backend-user
  name: backend-user
spec:
  replicas: 1
  selector:
          matchLabels:
                  app: backend-user
  template:
    metadata:
      labels:
        app: backend-user
    spec:
      volumes:
      - name: configmap-volume
        configMap:
            name: env-config
      containers:
      - image: ahmedabdelkarim1/udagram-api-user
        name: backend-user 
        imagePullPolicy: Always
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "1024Mi"
            cpu: "500m"
        env:
        - name: URL
          valueFrom:
            configMapKeyRef:
              name: env-config
              key: URL
        - name: JWT_SECRET
          valueFrom:
            configMapKeyRef:
              name: env-config
              key: JWT_TOKEN
        - 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
      restartPolicy: Always
