Openshift Port Forwarding

Access OpenShift forwarded ports from remote host

you can find decent discussion on port-forward listen addresses and few temporary solutions on https://github.com/kubernetes/kubernetes/issues/43962 and https://github.com/kubernetes/kubernetes/pull/46517.

Afer the PR is merged, relased in upstream kubernetes and openshift updates to that version, you will have an easy way to achieve this (I would guess minimum half a year since now). For now you're stuck with workarounds.

oc-command to forward local-ports to remote debug ports based on service-name instead of pod-name

Your going to need the pod name in order to port forward but of course you can fetch that programatically consistantly so you don't need to update in place every time.

There are a number of ways you can do this, via jsonpath, go template, bash etc. An example would be to use the following, replacing your app name as required:

oc get pod -l app=replace-me -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'

How do I stop an existing open shift Port Forward

You should be able to stop oc port-forward by using Ctrl-C (confirmed here).

If the port is still stuck open, then you can use sudo netstat -lnp to find the PID keeping it open. For example:

$ sudo netstat -lnp | grep 5555
tcp 0 0 127.0.0.1:5555 0.0.0.0:* LISTEN 302867/oc
tcp6 0 0 ::1:5555 :::* LISTEN 302867/oc

Once you have the PID (which is the number here : 302867/oc), you can use sudo kill -9 <PID> to end the process, and that should free up that port.

Openshift Port forwarding

You are probably using the beta version of the net-ssh gem. You need to install version net-ssh (2.9.2), and remove 2.9.3-beta1.

You can see what version of the net-ssh gem you are using with the following command:

gem list net-ssh

The results should look like this:

$gem list net-ssh

*** LOCAL GEMS ***

net-ssh (2.9.2)
net-ssh-gateway (1.2.0)
net-ssh-multi (1.2.0)


Related Topics



Leave a reply



Submit