DEV Community

Cover image for How to forward a port in K8s
Maxime Guilbert
Maxime Guilbert

Posted on • Edited on

2 1

How to forward a port in K8s

This is a simple thing that I've discover recently, it's not a revolution or something really hidden, but I think it's cool to share it!

So to forward a service port in Kubernetes, you just have to do

kubectl port-forward element to expose [local port:]pod/service/deploy... port

examples

# Expose port 80 of the service on the local port 80
kubectl port-forward svc/example-service 80

# Expose port 80 of the pod on the local port 36000
kubectl port-forward pod/pod-test 36000:80

# Expose port 27017 of the deployment on a random free local port
kubectl port-forward deployment/mongo :27017
Enter fullscreen mode Exit fullscreen mode

Links


I hope it will help you!

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more