apiVersion: apps/v1
kind: Deployment
metadata:
  name: udagram-feed-deployment
  labels:
    app: udagram-feed
spec:
  replicas: 1
  selector:
    matchLabels:
      app: udagram-feed
  template:
    metadata:
      labels:
        app: udagram-feed
    spec:
      containers:
      - name: udagram-feed
        image: vladflore/udagram-feed-api:latest
        env:
          - name: POSTGRES_USERNAME
            valueFrom:
              secretKeyRef:
                name: env-secret
                key: POSTGRES_USERNAME
          - name: POSTGRES_PASSWORD
            valueFrom:
              secretKeyRef:
                name: env-secret
                key: POSTGRES_PASSWORD
          - name: POSTGRES_HOST
            valueFrom:
              secretKeyRef:
                name: env-secret
                key: POSTGRES_HOST
          - name: POSTGRES_DB
            valueFrom:
              secretKeyRef:
                name: env-secret
                key: POSTGRES_DB
          - name: AWS_BUCKET
            valueFrom:
              secretKeyRef:
                name: env-secret
                key: AWS_BUCKET
          - name: AWS_REGION
            valueFrom:
              secretKeyRef:
                name: env-secret
                key: AWS_REGION
          - name: AWS_PROFILE
            valueFrom:
              secretKeyRef:
                name: env-secret
                key: AWS_PROFILE
          - name: JWT_SECRET
            valueFrom:
              secretKeyRef:
                name: env-secret
                key: JWT_SECRET
          - name: URL
            valueFrom:
              secretKeyRef:
                name: env-secret
                key: URL
        # imagePullPolicy: Always => by default
        ports:
        - containerPort: 8080
      # restartPolicy: Always => by default
        volumeMounts:
        - name: aws-credentials-volume
          mountPath: "/root/.aws/"
          readOnly: true
        - name: env-secret-volume
          mountPath: "/root/.config/"
          readOnly: true
      volumes:
      - name: aws-credentials-volume
        secret:
          secretName: aws-credentials-secret
      - name: env-secret-volume
        secret:
          secretName: env-secret
