<p>I tried to deploy the Kafka-UI in my local Kubernetes cluster, but ingress-nginx gives 502 error (Bad Gateway). I used the following configurations:</p>
<p><strong>Deployment:</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka-ui-deployment
  labels:
    app: kafka-ui
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kafka-ui
  template:
    metadata:
      labels:
        app: kafka-ui
    spec:
      containers:
      - name: kafka-ui
        image: provectuslabs/kafka-ui:latest
        env:
        - name: KAFKA_CLUSTERS_0_NAME
          value: "K8 Kafka Cluster"
        - name: KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS
          value: kafka-svc:9093
        imagePullPolicy: Always
        resources:
          requests:
            memory: "256Mi"
            cpu: "100m"
          limits:
            memory: "1024Mi"
            cpu: "1000m"
        ports:
        - containerPort: 8088
          protocol: TCP</code></pre>
</div>
</div>
</p>
<p><strong>Service:</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: kafka-ui-service
spec:
  selector:
    app: kafka-ui
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8088</code></pre>
</div>
</div>
</p>
<p><strong>Ingress:</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>      ingressClassName: public
      rules:
      - host: "localhost"
        http:
          paths:
          - path: /kafka-ui
            pathType: Prefix
            backend:
              service:
                name: kafka-ui-service
                port:
                  number: 80</code></pre>
</div>
</div>
</p>
<p>Port-forward the targetport got following error:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>Forwarding from 127.0.0.1:8088 -&gt; 8088
Forwarding from [::1]:8088 -&gt; 8088
channel 9: open failed: connect failed: Connection refused
Handling connection for 8088
Handling connection for 8088
E0623 09:18:20.768161   33100 portforward.go:406] an error occurred forwarding 8088 -&gt; 8088: error forwarding port 8088 to pod 75353d54479df5f235c03db1899367dc77e82877986be849761eba6193ca72c0, uid : failed to execute portforward in network namespace "/var/run/netns/cni-a5ed0994-0456-6b6c-5a79-90e582ef09b3": failed to connect to localhost:8088 inside namespace "75353d54479df5f235c03db1899367dc77e82877986be849761eba6193ca72c0", IPv4: dial tcp4 127.0.0.1:8088: connect: connection refused IPv6 dial tcp6: address localhost: no suitable address found
E0623 09:18:20.768994   33100 portforward.go:234] lost connection to pod</code></pre>
</div>
</div>
</p>
<p>Any suggestions will be appreciated.
Thanks for your help!</p>

Haoyuan
<p>The main error was the port. The right port is 8080. This yaml works fine for me.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka-ui-deployment
  labels:
    app: kafka-ui
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kafka-ui
  template:
    metadata:
      labels:
        app: kafka-ui
    spec:
      containers:
      - name: kafka-ui
        image: provectuslabs/kafka-ui:latest
        env:
        - name: KAFKA_CLUSTERS_0_NAME
          value: "K8 Kafka Cluster"
        - name: KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS
          value: kafka-kafka-bootstrap.kafka:9092 # &lt;- service-name.namespace:9092
        imagePullPolicy: Always
        resources:
          requests:
            memory: "256Mi"
            cpu: "100m"
          limits:
            memory: "1024Mi"
            cpu: "1000m"
        ports:
        - containerPort: 8080 # &lt;- Rectify the port
          protocol: TCP</code></pre>
</div>
</div>
</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>apiVersion: v1
kind: Service
metadata:
  name: kafka-ui-service
  namespace: kafka
spec:
  selector:
app: kafka-ui
  ports:
- protocol: TCP
  port: 8080
  targetPort: 8080 # &lt;- Rectify the port.</code></pre>
</div>
</div>
</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>      ingressClassName: public
      rules:
      - host: "localhost"
        http:
          paths:
          - path: /kafka-ui
            pathType: Prefix
            backend:
              service:
                name: kafka-ui-service
                port:
                  number: 8080</code></pre>
</div>
</div>
</p>
