Search code examples
networkingservicekubernetesports

Kubernetes services with multiple ports


I have a problem with multi-port services. I try to expose two ports, the first one works, the other does not. I am testing this with telnet (amongst others), and I always get "connection refused" for the second port.

This is the part about the ports in the service's yaml:

spec:
 clusterIP: 10.97.153.249
 externalTrafficPolicy: Cluster
 ports:
 - name: port-1
   nodePort: 32714
   port: 8080
   protocol: TCP
   targetPort: 8080
 - name: port-2
   nodePort: 32715
   port: 17176
   protocol: TCP
   targetPort: 17176

Solution

  • I would first confirm that kubectl get svc shows the two NodePorts. If that is the case, then it is highly likely that the destination port in the pods are not working. Could you check in the pods if the ports are listening correctly? Then, I would also advise you to check the access using the ClusterIP as well.