title: 502 bad gateway using Kubernetes with Ingress controller
body: <p>I have a Kubernetes setup on Minikube with this configuration:</p>
  
  <pre><code>---
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: myappdeployment
  spec:
    replicas: 5
    selector:
      matchLabels:
        app: myapp
    template:
      metadata:
        labels:
          app: myapp
      spec:
        containers:
          - name: myapp
            image: custom-docker-image:latest
            ports:
              - containerPort: 3000
  
  ---
  kind: Service
  apiVersion: v1
  metadata:
    name: example-service
  spec:
    selector:
      app: myapp
    ports:
      - protocol: "TCP"
        # Port accessible inside cluster
        port: 3000
        # Port to forward to inside the pod
        targetPort: 3000
    type: NodePort
  
  ---
  apiVersion: networking.k8s.io/v1beta1
  kind: Ingress
  metadata:
    name: example-ingress
    annotations:
      nginx.ingress.kubernetes.io/rewrite-target: /$1
  spec:
    - http:
        paths:
        - path: /
          backend:
            serviceName: example-service
            servicePort: 3000
  </code></pre>
  
  <p>I took a look at the solution to <a href="https://stackoverflow.com/questions/54783778/502-bad-gateway-with-kubernetes-ingress">this Stackoverflow post</a> and it seems my configuration is.. fine?</p>
  
  <p>What am I doing wrong to get 502 Bad Gateway when accessing <a href="http://192.xxx.xx.x" rel="nofollow noreferrer">http://192.xxx.xx.x</a>, my Minikube address? The <code>nginx-ingress-controller</code> logs say:</p>
  
  <pre><code>...
  Connection refused while connecting to upstream
  ...
  </code></pre>
  
  <p>Another odd piece of info, when I follow <a href="https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/" rel="nofollow noreferrer">this guide</a> to setting up the basic node service on Kubernetes, everything works and I see a "Hello world" page when I open up the Minikube add</p>