<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>

Sticky
<p>Steps taken:
I ran </p>

<pre><code>kubectl port-forward pods/myappdeployment-5dff57cfb4-6c6bd 3000:3000
</code></pre>

<p>Then I visited <code>localhost:3000</code> and saw</p>

<pre><code>This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE
</code></pre>

<p>I figured the reason is more obvious in the logs so I ran </p>

<pre><code>kubectl logs pods/myappdeployment-5dff57cfb4-6c6bd 
</code></pre>

<p>and got</p>

<pre><code>Waiting for MySQL...
no destination
Waiting for MySQL...
no destination
Waiting for MySQL...
no destination
Waiting for MySQL...
no destination
...
</code></pre>

<p>Thus I reasoned that I was originally getting a 502 because all of the pods were not running due to no MySQL setup.</p>
