How to know k8s node name and external port in before.sh.erb?

In a kubernetes cluster job, is it possible to get the #{host} and #{port} as known in view.html.erb?These should be pod’s host name (k8s node) not pod’s name and external port (in pod’s host).

From view.html.erb:
<%-
base_url = “/rnode/#{host}/#{port}” ← This works
%>

To serve static (base_url/static) files for jupyter-lab ideally I set the config in before.sh.erb:
c.ServerApp.base_url = ‘/rnode/${host}/${port}’

If not set, $host in the before.sh.erb is the pod’s name, and $port is not set. (OOD version 4.1.4)

I used kubectl to get them:
PORT_CFG=$(kubectl --kubeconfig=$KUBECONFIG get services $(hostname)-service -o jsonpath=“{.spec.ports[0].nodePort}”)
HOST_CFG=$(kubectl --kubeconfig=$KUBECONFIG get pod $HOSTNAME -o jsonpath=“{.spec.nodeName}” | cut -d’.’ -f1)

and set
c.NotebookApp.base_url = ‘/node/${HOST_CFG}/${PORT_CFG}/’
c.ServerApp.base_url = ‘’