Access corporate resources from Minikube

4/18/2020

I am using a VPN connection to access corporate resources from my Laptop. However, I am unable to access these resources from the VM created by Minikube.

I want to be able to do exactly this but the address of the external resource is unreachable from the cluster.

Any ideas how I can do this with Minikube?

-- Andrew Schultz
kubernetes
minikube
networking
vpn

2 Answers

4/27/2020

I was actually able to access the corporate network from the VM by downloading the latest version of virtualbox and using that as the --vm-driver for minikube while connected to the VPN on my laptop. (Was using hyperkit before)

minikube start --vm-driver=virtualbox
-- Andrew Schultz
Source: StackOverflow

4/27/2020

You need to make sure you have correctly defined endpoints and services. That way Kubernetes will redirect requests from inside the pod to the desired outside IP. It is well described in this answer which I am posting as a community wiki here:

Create Endpoints that will forward traffic to your desire external IP address (your local machine). You can directly connect using Endpoints but according to Google Cloud best practice (doc) is to access it through a Service

enter image description here

Create your Endpoints

kind: Endpoints
apiVersion: v1
metadata:
 name: local-ip
subsets:
 - addresses:
     - ip: 10.240.0.4  # IP of your desire end point
   ports:
     - port: 27017     # Port that you want to access Then create you `Service`

kind: Service
apiVersion: v1
metadata:
 name: local-ip
Spec:
 type: ClusterIP
 ports:
 - port: 27017
   targetPort: 27017

Now you can call external http service using the Service name. In this case loal-ip like any other internal service of minikube.

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow