apiVersion: apps/v1
kind: Deployment
metadata:
  name: url-shortener-backend
  labels:
    deployment: url-shortener-backend
spec:
  replicas: 3
  selector:
    matchLabels:
      pod: url-shortener-backend
  template:
    metadata:
      labels:
        name: url-shortener-backend
        pod: url-shortener-backend
    spec:
      containers:
      - name: url-shortener-backend
        image: IMAGE_NAME
        env:
          - name: REDIS_IP
            valueFrom:
              configMapKeyRef:
                name: backend-config
                key: REDIS_IP
          - name: POSTGRESQL_IP
            valueFrom:
              configMapKeyRef:
                name: backend-config
                key: POSTGRESQL_IP
          - name: DATABASE_NAME
            valueFrom:
              configMapKeyRef:
                name: backend-config
                key: DATABASE_NAME
          - name: POSTGRESQL_PORT_NUMBER
            valueFrom:
              configMapKeyRef:
                name: backend-config
                key: POSTGRESQL_PORT_NUMBER
          - name: REDIS_PORT_NUMBER
            valueFrom:
              configMapKeyRef:
                name: backend-config
                key: REDIS_PORT_NUMBER
          - name: SERVER_HOST
            valueFrom:
              configMapKeyRef:
                name: backend-config
                key: SERVER_HOST

          - name: SQL_USER
            valueFrom:
              configMapKeyRef:
                name: backend-secret
                key: SQL_USER
          - name: SQL_PASSWORD
            valueFrom:
              configMapKeyRef:
                name: backend-secret
                key: SQL_PASSWORD
        ports:
        - containerPort: 8080
