Access an ip address on the host network inside kubernetes pod

8/20/2019

How can I access a service on an IP address in my host's network?

Basically, I have 5 or 6 VMS on the same network and 3 of these VMS are used to create a Kubernetes cluster. One of these VMs hosts a private npm registry external to Kubernetes (192.168.2.x). I am using a gitlab runner that runs in the Kubernetes cluster. While doing an npm install during a build phase of a ci pipeline I get a time-out as the pod running as the gitlab build runner cannot access the private npm registry which is on host network via 192.168.2.x and not inside the Kubernetes cluster.

Is there a way to be able to access a service inside the same host network but not inside the Kubernetes cluster?

Here is an example of the error msg inside the runner:

$ npm install npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/@angular/compiler-cli/node_modules/fsevents): npm WARN network SKIPPING OPTIONAL DEPENDENCY: request to https://devops.internal.ideam.co.za/repository/npm-group/fsevents failed, reason: connect ETIMEDOUT 192.168.2.6:443

npm ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! network request to > https://devops.internal.ideam.co.za/repository/npm-group/source-map failed, reason: connect ETIMEDOUT 192.168.2.6:443 npm ERR! network This is a problem related to network connectivity.

As you can see once the FQDN that is protected via a trusted cert is resolved to the internal IP address this the host IP address of the npm registry is not accessible from inside the pod. I have made sure the external FQDN does resolve using busybox and nslookup command in the Kubernetes cluster in a debug pod.

I have provided an explanatory diagram to illustrate:

enter image description here

Is this a network configuration issue? Does anybody know if this is possible or how to get this to work?

-- Keith
kubernetes
kubernetes-networking

0 Answers