TECHIES WORLD

For Techs.... Techniques.... Technologies....

BashLinux

How to forward Kubernetes port to bind on 0.0.0.0

Kubernetes provides the feature to port forward an application which is running in the internal network through the Kubernetes client host. By default it binds to the 127.0.0.1 and it won’t accept requests from external hosts.

But there is an option to bind the port listen on 0.0.0.0 so that it can accept requests from external hosts.

#kubectl port-forward svc/[SERVICE] -n [NAMESPACE] [EXTERNAL-PORT]:[INTERNAL-PORT] --address='0.0.0.0'

Where SERVICE, NAMESPACE, EXTERNAL-PORT and INTERNAL-PORT need to be replaced with the appropriate values.

That's all…