Question

How to configure nginx-ingress and Digital ocean Load balancer to accept TCP traffic and route to pod

Posted October 22, 2021 118 views
NginxLoad BalancingKubernetesDigitalOcean Managed Kubernetes

I have a digital ocean kubernetes and an ingress controller routing traffic. but one of the pods needs to accept TCP traffic; so i would like to make the ingress to accept the TCP traffic and route to the pod. i followed this

https://minikube.sigs.k8s.io/docs/tutorials/nginx_tcp_udp_ingress/

and

https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/

after following, i still cannot connect to the port.

Below is what i have:

Load. balancer:

kind: Service
apiVersion: v1
metadata:
  name:  ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  selector:
    # app:  speed-transmission-app
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  type:  LoadBalancer
  ports:
  - name: http
    port: 80
    targetPort: 80
    protocol: TCP
  - name: https
    port: 443
    targetPort: 443
    protocol: TCP
  - name:  transmission-port
    port:  9000
    targetPort:  8998
    protocol: TCP

config map


apiVersion: v1
kind: ConfigMap
metadata:
  name: tcp-services
  namespace: ingress-nginx
data:
  9000: "staging/speed-transmission-service:9000"

Now when i try to connect to the load balancer external IP at port 9000, i get connection lost.

I will really appreciate help on how to configure this. thanks.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @olalekanadebari!

Can you further triage at what point the connection is failing?
Do you know if it is failing to connect at the LB or the ingress-controller?

I think you may want to look into the service annotations for the loadbalancer service to set the appropriate protocols on the DO LB.

You can find the full list of valid annotations here: https://github.com/digitalocean/digitalocean-cloud-controller-manager/blob/master/docs/controllers/services/annotations.md#service-annotations

That should allow you to set protocols for the appropriate ports at the LB section.

Further reading that may be of assistance:

https://kubernetes.io/docs/concepts/services-networking/ingress/
https://docs.digitalocean.com/products/kubernetes/how-to/configure-load-balancers/

Narrowing down where the actual failure is happening will help you figure out which component is breaking the connection. I hope this helps!

Hope this helps!

John

  • Hi @jkwiatkoski thanks, i think it was failing at the ingress-controller level as there was no rules to tell it how to handle tcp connection to a port other than the standard http port 80 and 443. this is what am searching for. i want to know how to configure additional ports on the ingress-load balancer service and it will get routed to the corresponding services.