'Kafka connect - Failed to connect to localhost port 8083: Connection refused

I have an application that relies on a kafka service.

With Kafka connect, I'm getting an error when trying to curl localhost:8083, on the Linux VM that's running the kubernetes pod for Kafka connect.

curl -v localhost:8083 gives:

  • Rebuilt URL to: localhost:8083/
  • Trying 127.0.0.1...
  • connect to 127.0.0.1 port 8083 failed: Connection refused
  • Failed to connect to localhost port 8083: Connection refused
  • Closing connection 0 curl: (7) Failed to connect to localhost port 8083: Connection refused

kubectl get po -o wide for my kubernetes namespace gives:

enter image description here

When I check open ports using sudo lsof -i -P -n | grep LISTEN I don't see 8083 listed. The kafka connect pod is running and there's nothing suspicious in the logs for the pod.

There's a kubernetes manifest that I think was probably used to set up the Kafka connect service, these are the relevant parts. I'd really appreciate any advice about how to figure out why I can't curl localhost:8083

apiVersion: apps/v1
kind: Deployment
metadata:
   name: kafka-connect
   namespace: my-namespace
spec:

   ...

   template:
     metadata:
       labels:
         app: connect
     spec:
        containers:
          - name: kafka-connect
            image: confluentinc/cp-kafka-connect:3.0.1
            ports:
              - containerPort: 8083

            env:
              
              - name: CONNECT_REST_PORT
                value: "8083"
              - name: CONNECT_REST_ADVERTISED_HOST_NAME
                value: "kafka-connect"

        volumes:
          - name: connect-plugins
            persistentVolumeClaim:
                claimName: pvc-connect-plugin
          - name: connect-helpers          
            secret:
              secretName: my-kafka-connect-config
---
apiVersion: v1
kind: Service
metadata:
  name: kafka-connect
  namespace: my-namespace
  labels:
    app: connect  
spec:
  ports:
    - port: 8083
  selector:
    app: connect


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source