How to use Minikube with Cisco AnyConnect VPN?

김영석
2 min readMay 18, 2021

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!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

김영석
김영석

Written by 김영석

I love problem solving and hate repetition of tedious tasks. I like automating, streamlining, optimizing, things.

Responses (2)

Write a response