Kubernetes proxy connection to external service

If you need to connect to service with type: ExternalName, you need to build a tunnel, because not possible to use proxy directly to service.

How it should be?

For example Postgres with port 5432

kubectl -n prod run pg-tunnel -it --image=alpine/socat --tty --rm --expose=true --port=5432 tcp-listen:5432,fork,reuseaddr tcp-connect:yourdatabasehost:5432
kubectl -n prod port-forward svc/pg-tunnel 5432:5432

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Design a site like this with WordPress.com
Get started