# The .spec.selector field defines how the Deployment finds which Pods to manage.
# The .spec.template fiels is where the label is defined with containers details (Pod template) 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: news-visualizer-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: news-visualizer
  template:
    metadata:
      labels:
        app: news-visualizer
    spec:
      containers: 
      - name: visualizer
        image: mesmerai/visualizer
        resources:
          limits:
            cpu: 1
            memory: 2Gi
          requests:
            cpu: 1
            memory: 2Gi
        ports:
          - containerPort: 8080    
        env:
          - name: DB_HOST
            value: news-postgres-service
          - name: NEWS_API_KEY
            valueFrom:
              secretKeyRef: 
                name: news-secrets
                key: apikey
          - name: DB_PASSWORD
            valueFrom:
              secretKeyRef: 
                name: news-secrets
                key: dbpassword

   

