How to route TCP traffic from outside to a Service inside a Kubernetes cluster? How to route TCP traffic from outside to a Service inside a Kubernetes cluster? kubernetes kubernetes

How to route TCP traffic from outside to a Service inside a Kubernetes cluster?


You can use both the service of type Loadbalancer ( I assume AKS supports that) , or you can just use the node port.

kubectl expose deployment hello-world --type=LoadBalancer --name=my-servicekubectl get services my-service

The output is similar to this:

NAME         TYPE        CLUSTER-IP     EXTERNAL-IP      PORT(S)    AGEmy-service   ClusterIP   10.3.245.137   104.198.205.71   8080/TCP   54s

Reference here

kubectl expose usage:

Usage$ expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP|SCTP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type]

You can make use of --port= 2424 --target-port= 2424 options for correct ports in the kubectl expose command above