AKS icon indicating copy to clipboard operation
AKS copied to clipboard

Question: Using NodePort service instead of LoadBalancer

Open kblooie opened this issue 8 years ago • 3 comments

I'd like to know if it would be possible to expose NodePort services to the internet. I understand that there is not an automated solution for this, but would like to see what would be required to get a solution in place.

We have a requirement that hundreds of our pods each need a dedicated port to receive TCP traffic from other systems external to our network. We started by using a LoadBalancer service, but quickly found that it was not a viable solution due to cost & public IP limits.

We've also considered using an ingress controller (HAProxy), but found found that exposing new ports for TCP traffic over time was hard and not as decoupled as configuring HTTP routing.

NodePort services seem to be the ideal solution, but I've read in multiple places that it's not supported in AKS. At first look, it seems like the only reason for this is because the kubernetes nodes do not have public IPs, and therefore we'd need to setup all the load balancing rules.

Would it be possible to expose NodePort services from a public IP if we manually managed the LoadBalancer rules and security group incoming rules? Are there any technical limitations that prevent the use of exposing NodePort services publically?

Thanks in advance

kblooie avatar Jul 10 '18 19:07 kblooie

For the ingress controller consider using --set controller.publishService.pathOverride="namespace/name"
--set controller.service.type="NodePort"
--set controller.publishService.enabled=true \

This will allow ingress controller to update the ip address for the ingress, and the you can use external dns to register the fqdn ..hope this helps, General links https://github.com/helm/charts/tree/master/stable/nginx-ingress https://github.com/kubernetes/ingress-nginx

rite2nikhil avatar Aug 07 '18 19:08 rite2nikhil

Exposing a node port to internet is not feasible yet, however you have several options that could allow you to accomplish your goal. Some of them are:

HTTP application routing https://docs.microsoft.com/en-us/azure/aks/http-application-routing

Create an HTTPS ingress controller on Azure Kubernetes Service (AKS) https://docs.microsoft.com/en-us/azure/aks/ingress-tls

Create an application gateway with an internal load balancer (ILB) https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-ilb-arm

Application Gateway Ingress Controller + aks nodes. https://github.com/Azure/application-gateway-kubernetes-ingress

Internal Load balancer https://docs.microsoft.com/en-us/azure/aks/internal-lb

External load balancer https://docs.microsoft.com/en-us/azure/aks/static-ip

Kudos for Rafael Duarte for helping with this.

porrascarlos802018 avatar Jul 30 '19 16:07 porrascarlos802018

@porrascarlos802018 but it's documented https://docs.microsoft.com/en-us/azure/aks/concepts-network. I was wondering why it is present in the document but not feasible as you've said.

frbimo avatar Jul 31 '19 08:07 frbimo