title: "host not found in upstream ..." when using 'kubectl apply -f' but works in 'docker-compose up'
body: <p>I have four images in docker which are two services, a frontend and a reverseproxy.</p>
  
  <p>When I was using <code>docker-compose up</code>, it works and the services were running.</p>
  
  <p>But when I want to use <code>kubectl apply -f</code> to run in pod. There are <strong>[emerg] 1#1: host not found in upstream "backend-user:8080" in /etc/nginx/nginx.conf:11</strong> in logs. I have no idea about this.</p>
  
  <p>Here is my <strong>images</strong>:</p>
  
  <pre><code>bmjlearntocode/reverseproxy           latest
  bmjlearntocode/udacity-frontend       local
  bmjlearntocode/udacity-restapi-user   latest
  bmjlearntocode/udacity-restapi-feed   latest
  </code></pre>
  
  <p>Here is the <strong>docker-compose.yaml</strong></p>
  
  <pre><code>version: "3"
  services:
    reverseproxy:
        image: bmjlearntocode/reverseproxy
        ports:
          - 8080:8080
        restart: always
        depends_on:
          - backend-user
          - backend-feed
    backend-user:
      image: bmjlearntocode/udacity-restapi-user
      volumes:
        - $HOME/.aws:/root/.aws
      environment:
        POSTGRESS_USERNAME: $POSTGRESS_USERNAME
        POSTGRESS_PASSWORD: $POSTGRESS_PASSWORD 
        POSTGRESS_DB: $POSTGRESS_DB 
        POSTGRESS_HOST: $POSTGRESS_HOST 
        AWS_REGION: $AWS_REGION 
        AWS_PROFILE: $AWS_PROFILE 
        AWS_BUCKET: $AWS_BUCKET
        JWT_SECRET: $JWT_SECRET
        URL: "http://localhost:8100"
    backend-feed:
      image: bmjlearntocode/udacity-restapi-feed
      volumes:
        - $HOME/.aws:/root/.aws
      environment:
        POSTGRESS_USERNAME: $POSTGRESS_USERNAME
        POSTGRESS_PASSWORD: $POSTGRESS_PASSWORD 
        POSTGRESS_DB: $POSTGRESS_DB 
        POSTGRESS_HOST: $POSTGRESS_HOST 
        AWS_REGION: $AWS_REGION 
        AWS_PROFILE: $AWS_PROFILE 
        AWS_BUCKET: $AWS_BUCKET
        JWT_SECRET: $JWT_SECRET
        URL: "http://localhost:8100"
    frontend:
      image: bmjlearntocode/udacity-frontend:local
      ports:
        - "8100:80"
  </code></pre>
  
  <p>Here is the <strong>nginx.conf</strong></p>
  
  <pre><code>worker_processes 1;
  
  events { worker_connections 1024; }
  error_log /dev/stdout debug;
  
  http {
  
      sendfile on;
  
      upstream user {
          server backend-user:8080;
      }
  
      upstream feed {
          server backend-feed:8080;
      }
  
      proxy_set_header   Host $host;
      proxy_set_header   X-Real-IP $remote_addr;
      proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header   X-Forwarded-Host $server_name;
  
      server {
          listen 8080;
  
          location /api/v0/feed {
              proxy_pass         http://feed;
          }
          location /api/v0/users {
              proxy_pass         http://user;
          }
      }
  
  }
  
  </code></pre>
  
  <p>When I use <code>docker-compose up</code>, it works.</p>
  
  <p>Here is the <strong>reverseproxy-deployment.ymal</strong></p>
  
  <pre><code>apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    labels:
      service: reverseproxy
    name: reverseproxy
  spec:
    replicas: 2
    template:
      metadata:
        labels:
          service: reverseproxy
      spec:
        containers:
        - image: bmjlearntocode/reverseproxy
          name: reverseproxy
          imagePullPolicy: Always          
          resources:
            requests:
              memory: "64Mi"
              cpu: "250m"
            limits:
              memory: "1024Mi"
              cpu: "500m"       
          ports:
          - containerPort: 8080
        restartPolicy: Always
  </code></pre>
  
  <p>I am not sure about why the nginx can not find the 'back-end' when the pod start, but can run in <code>docker-compose up</code></p>