Minikube can be a pain when your machine is behind a corporate proxy, but it’s not the network itself that’s the problem, it’s how Minikube’s internal components talk to each other and the outside world.
Let’s see Minikube’s Docker daemon, which is essentially running inside a VM, trying to pull an image:
# First, let's start minikube without any proxy config
minikube start --driver=docker
# Now, try to deploy something that needs an external image
kubectl create deployment nginx-test --image=nginx:latest
You’ll likely see ImagePullBackOff or ErrImagePull in kubectl get pods. This is because the Docker daemon inside Minikube’s VM can’t reach Docker Hub.
The core issue is that Minikube, by default, doesn’t know about your local machine’s proxy settings. The Docker daemon running within the Minikube virtual machine needs explicit instructions on how to route its HTTP and HTTPS traffic.
Here are the common culprits and how to fix them:
-
Minikube VM’s Docker Daemon Proxy Settings: This is the most frequent offender. The Docker daemon inside the Minikube VM needs its proxy configured.
- Diagnosis: SSH into the Minikube VM and check the Docker daemon’s configuration.
If this file is missing or incorrect, that’s your problem.minikube ssh # Inside the VM: sudo cat /etc/systemd/system/docker.service.d/http-proxy.conf - Fix: You need to set environment variables for the Docker daemon. The easiest way is to tell
minikube startto do this for you.
This injects these variables into the Docker daemon’s systemd service.# Replace with your actual proxy details export HTTP_PROXY="http://your_proxy_host:proxy_port" export HTTPS_PROXY="http://your_proxy_host:proxy_port" export NO_PROXY="localhost,127.0.0.1,10.96.0.0/12,192.168.0.0/16,192.168.49.0/24,192.168.64.0/24" # Add any other internal IPs/domains minikube delete # Clean up previous attempt minikube start --driver=docker --env HTTP_PROXY=$HTTP_PROXY --env HTTPS_PROXY=$HTTPS_PROXY --env NO_PROXY=$NO_PROXY - Why it works: This configures the Docker daemon within the Minikube VM to use your specified proxy for pulling images and communicating with external registries.
NO_PROXYis crucial for internal cluster communication.
- Diagnosis: SSH into the Minikube VM and check the Docker daemon’s configuration.
-
Kubernetes Node Proxy Settings: Even if Docker pulls images, Pods themselves might need proxy settings to reach external services.
- Diagnosis: After Minikube starts with the Docker proxy configured, check if Pods can reach the internet.
If this fails, the Kubernetes nodes (Minikube VM) need proxy settings.minikube start --driver=docker --env HTTP_PROXY=$HTTP_PROXY --env HTTPS_PROXY=$HTTPS_PROXY --env NO_PROXY=$NO_PROXY kubectl run net-check --image=busybox --command -- sleep 3600 kubectl exec net-check -- wget -qO- http://example.com - Fix: You can configure the
kubeletandkube-proxyto use proxy settings. This is often done by setting environment variables for thekubeletservice on the Minikube VM.
Then restart your deployments or# Ensure minikube is running with the Docker proxy settings from step 1. # Then, update the kubelet service. minikube ssh # Inside the VM: sudo systemctl stop kubelet sudo mkdir -p /etc/systemd/system/kubelet.service.d sudo tee /etc/systemd/system/kubelet.service.d/http-proxy.conf <<EOF [Service] Environment="HTTP_PROXY=$HTTP_PROXY" Environment="HTTPS_PROXY=$HTTPS_PROXY" Environment="NO_PROXY=$NO_PROXY" EOF sudo systemctl daemon-reload sudo systemctl start kubelet exitkubectl delete pod <pod-name>for them to be recreated on the updated node. - Why it works: This configures the
kubeletprocess, which manages Pods on the node, to use the proxy for any outbound requests it makes on behalf of Pods that don’t have their own proxy settings.
- Diagnosis: After Minikube starts with the Docker proxy configured, check if Pods can reach the internet.
-
Docker Daemon Configuration File: Sometimes, the systemd override isn’t enough, or you need more granular control for the Docker daemon.
- Diagnosis: Check the
docker.servicefile directly for any conflicting or missing proxy directives.
Look forminikube ssh # Inside the VM: sudo cat /lib/systemd/system/docker.serviceEnvironment=lines orExecStart=that might override settings. - Fix: Manually create or edit the
http-proxy.conffile within thedocker.service.ddirectory.minikube ssh # Inside the VM: sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf <<EOF [Service] Environment="HTTP_PROXY=$HTTP_PROXY" Environment="HTTPS_PROXY=$HTTPS_PROXY" Environment="NO_PROXY=$NO_PROXY" EOF sudo systemctl daemon-reload sudo systemctl restart docker exit - Why it works: This ensures the Docker daemon is explicitly launched with the correct proxy environment variables, overriding any defaults or inherited settings.
- Diagnosis: Check the
-
Pod-level Proxy Configuration: For specific applications running inside Pods that need to respect proxy settings, you can set environment variables directly in your Deployment or Pod definition.
- Diagnosis: An application within a Pod fails to reach an external API.
- Fix: Add environment variables to your Pod spec.
apiVersion: v1 kind: Pod metadata: name: my-app-with-proxy spec: containers: - name: my-app image: my-app-image env: - name: HTTP_PROXY value: "http://your_proxy_host:proxy_port" - name: HTTPS_PROXY value: "http://your_proxy_host:proxy_port" - name: NO_PROXY value: "localhost,127.0.0.1,10.96.0.0/12,192.168.0.0/16,192.168.49.0/24,192.168.64.0/24" - Why it works: Many applications are written to automatically pick up
HTTP_PROXY,HTTPS_PROXY, andNO_PROXYenvironment variables for their outbound requests.
-
Client-side
kubectlProxy: While less common for Minikube itself, your localkubectlcommand might need proxy settings if it needs to communicate through a proxy to reach the Kubernetes API server (though Minikube usually binds it locally).- Diagnosis:
kubectlcommands fail with connection refused or timeouts even though Minikube is running. - Fix: Set proxy environment variables in your local shell before running
kubectl.export HTTP_PROXY="http://your_proxy_host:proxy_port" export HTTPS_PROXY="http://your_proxy_host:proxy_port" export NO_PROXY="localhost,127.0.0.1,$(minikube ip)" # Add minikube IP - Why it works: This ensures your local
kubectlclient can reach the Minikube API server if it’s exposed through a proxy. For Minikube, this is usually only relevant if you’re tunneling or have a very unusual setup.
- Diagnosis:
-
Git Proxy Settings (if building images within Minikube): If your build process involves
git cloneoperations within a Docker build, Git itself needs to know about the proxy.- Diagnosis:
docker buildcommands fail with Git clone errors. - Fix: Configure Git within the Minikube VM.
minikube ssh # Inside the VM: git config --global http.proxy "$HTTP_PROXY" git config --global https.proxy "$HTTPS_PROXY" # You might also need to configure Git's proxy for specific repos or globally for credentials. exit - Why it works: This tells the Git client, which is executed during a
docker buildstep, how to connect to remote repositories.
- Diagnosis:
After applying the correct proxy settings, you’ll likely encounter issues with DNS resolution within Pods if your NO_PROXY list is too restrictive or your proxy server doesn’t handle internal DNS requests properly.