Search code examples
kuberneteskubectlportforwardingpodman

Is there a kubectl port-forward equivalent in podman?


There are TCP ports that should not be exposed to the outside world, but are isolated between several containers in a network.

To access such a port for debugging purposes, kubectl port-forward can be used from outside the container network. E.g. for access to a non-exposed k8s database on a developer workstation: kubectl port-forward pods / app-dev-database-0 5432: 5432 -n app

Is there a Podman equivalent for kubectl port-forward to set up port forwarding from the Podman host to an existing and running container?


Solution

  • I do not think podman has such an option. There is a 'network' option available in podman. However, it is for creating container networks and not the purpose of port forwarding.

    To answer your question, I think socat is the only option

    # socat TCP4-LISTEN:5431 TCP4:10.89.1.10:5432
    

    Here anyone connects to 5431 port of the server will be redirected to a container IP and port 10.89.1.10:5432