Unable to connect kubernetes JupyterHub to a DataBase


I am currently trying to connect my Jupyterhub on kubernetes with a locally running instance of an IRIS Database. Currently when I try to do so I keep getting a connection error. However, when I use DBeaver or a locally running Jupyterhub to connect to the same IRIS Database I have no issues. I am not sure why Jupyterhub on kubernetes is having this issue. Please advice thanks. I am using a JDBC driver to connect and everytime I run my code I get a connection refused error for a Jupyterhub on kubernetes whilst the same code has no problem when run locally.

What does “locally running” mean relative to the user session in JupyterHub? I suspect you are encountering the JupyterHub network policies, which limit what each component can talk to. If it’s another service within the cluster, you can allow single-user pods to connect to other internal cluster resources:

      privateIPs: true

Yup thanks! I needed to disable the network Policy and set the PrivateIPs to true before I was to communicate to pods outside the namespace by jupyterhub was in.

Is there any setting that allows the jupyterhub within my k8s cluster to connect to databases that are running locally on my machine?

Is the k8s cluster also running on your local machine? If not, your local machine needs a public address in order to be connectable from across the network (in general, not specific to Jupyter). Assuming your machine isn’t a public server, one relatively lightweight way to do this is with an SSH tunnel to a machine that is:

  • connectable from your local machine via ssh, and
  • connectable from the cluster

For example, another VM in the same private network as the cluster.