apiVersion: apps/v1
kind: Deployment
metadata:
  name: worker-deploy
  namespace: voting-app-stack
  labels:
    name:  worker-deploy
spec:
  replicas: 1
  
  selector:
    matchLabels:
      name: worker-pod

  template:
    metadata:
      labels:
        name: worker-pod
    spec:
      initContainers:
      - name: waiting-for-postgres
        image: postgres:latest
        command: ['sh', '-c', 
          'until pg_isready -h postgres -p 5432; 
          do echo waiting for database; sleep 2; done;']
      - name: waiting-for-redis
        image: redis:latest
        command: ['sh', '-c', 
          'until redis-cli -h redis -p 6379; 
          do echo waiting for redis; sleep 2; done;']
      containers:
      - name: worker-app
        imagePullPolicy: Always
        image: ghcr.io/hbollon/k8s-voting-app-aws/worker:main
        resources:
          limits:
            memory: "128Mi"
            cpu: "100m"

