kubectl unable to connect minikube on VPN


I installed minikube in my Mac, and I noticed that kubectl is unable to connect to it while my Mac in on VPN (Cisco Anyconnect).

$ kubectl cluster-info
Kubernetes master is running at https://192.168.99.100:8443


To further debug and diagnose cluster problems, use ‘kubectl cluster-info dump’.
Unable to connect to the server: dial tcp 192.168.99.100:8443: i/o timeout

Here are the specs:

$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.6
BuildVersion: 17G3025


$ minikube version
minikube version: v0.30.0


$ VBoxManage -v
5.2.22r126460

After a quick troubleshooting, I think it is caused by the VPN routing – It is configured as the gateway for everything.

Thanks to this solution that I found online. 

# Set port forwarding for the minikube vm to forward port 8443 on 127.0.0.1 to port 8443 in the VM.

VBoxManage controlvm minikube natpf1 k8s-apiserver,tcp,127.0.0.1,8443,,8443

# Create a new kubectl context and use it when on VPN.

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

# Switch back to the normal minikube context when off VPN.

kubectl config use-context minikube

Now let me try again.

$ kubectl cluster-info
Kubernetes master is running at https://127.0.0.1:8443
CoreDNS is running at https://127.0.0.1:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy


To further debug and diagnose cluster problems, use ‘kubectl cluster-info dump’.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s