How do you expose non-HTTP services (TCP, UDP) from Kubernetes?
IntermediateProductionKubernetes & Service Networking in Production
Answer
A Service of type LoadBalancer using an NLB (annotation service.beta.kubernetes.io/aws-load-balancer-type: external with the AWS Load Balancer Controller), or TCPRoute/UDPRoute in the Gateway API, or ingress-nginx TCP services ConfigMap.
Mind security groups on nodes and pods, health check settings and source IP preservation. For UDP also consider conntrack and idle timeouts (NLB UDP idle timeout is 120 seconds).
More on Kubernetes & Service Networking in Production
How do you expose an application on Kubernetes to the internet in production?BeginnerALB IP mode versus instance mode on EKS: which should you use?IntermediateHow do you achieve graceful pod shutdown with no dropped requests?AdvancedHow do readiness, liveness and startup probes interact with traffic?BeginnerHow do you design default-deny NetworkPolicies without breaking DNS?IntermediateHow do you debug "pod cannot reach service" in Kubernetes?Advanced