Environments
- minikube : v1.19.0
- VBox: -v6.1.22r144080
- OS: Mac OS X 10.15.7
Root Cause for not being able to connect to Minikube and VPN in the first place is
VPN is routing all traffics ( even including those ones coming to Minikube API )
Where is the k8s running?
yeongseokkim@YEONGSEOKKIMs-MacBook-Pro ~ % k cluster-info
Kubernetes control plane is running at https://192.168.99.103:8443
CoreDNS is running at https://192.168.99.103:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
the Kubernetes cluster is running at CIDR range of 192.168.0.0./16.
and VPN is intervening all traffics for that IP range. That’s why we are in trouble with Minikube.
As an workaround to overcome this,
Step1. Set port-forwarding for the minikube vm to forward port 8443 on 127.0.0.1 to port 8443 in the VM.
Port Forward Command Line
VBoxManage controlvm minikube natpf1 k8s-apiserver,tcp,127.0.0.1,8443,,8443
Step2. Create a new kubectl context and use it when on VPN.
Port Forward Command Line
kubectl config set-cluster minikube-vpn --server=https://127.0.0.1:8443 --insecure-skip-tls-verify
kubectl config set-context minikube-vpn --cluster=minikube-vpn --user=minikube
Step3. Switch back to the normal minikube context when off VPN.
Port Forward Command Line
kubectl config use-context minikube
Check the result.
yeongseokkim@YEONGSEOKKIMs-MacBook-Pro ~ % k cluster-info
Kubernetes control plane is running at http://127.0.0.1:63436/2eb45476-fae6-40d1-bacb-79f00f70cede
CoreDNS is running at http://127.0.0.1:63436/2eb45476-fae6-40d1-bacb-79f00f70cede/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Additional Steps. In case you need to mount “host file system” to your Minikube node.
according to this doc, https://minikube.sigs.k8s.io/docs/handbook/mount/
some hypervisors have built-in host folder sharing.
In my case, for macOS, VirtualBox environment, I am able to take advantage of this feature natively
Thanks!