English
Troubleshooting DNS and Proxy Configuration When Running Kubernetes (K3s) on macOS with Colima

1. Background
On macOS, Colima provides a lightweight way to create Linux virtual machines and run Kubernetes inside them.
Colima supports multiple container runtimes and can also deploy lightweight Kubernetes clusters using K3s. This makes it a practical solution for local Kubernetes development, testing, and learning, with relatively low resource consumption, simple deployment, and environment isolation.
This article documents an issue encountered while setting up a single-node K3s cluster on macOS with Colima:
- The Kubernetes Node reported a healthy status, but system Pods remained in
ContainerCreatingfor an extended period. - System components such as CoreDNS, Traefik, and local-path-provisioner could not start normally.
- Pod sandbox creation failed because the
registry.k8s.io/pauseimage could not be pulled. - DNS resolution initially failed. Even after fixing DNS, image pulls continued to fail because HTTPS connections timed out.
After investigating the issue step by step, two independent problems were identified:
- Incorrect DNS configuration inside the Colima VM.
- The containerd service was missing HTTP/HTTPS proxy configuration.
This article walks through the environment setup, observed symptoms, root cause analysis, and final fixes. It also verifies the recovery through the actual runtime status of Kubernetes system Pods.
2. Environment
The environment used in this troubleshooting session is as follows:
| Component | Configuration |
|---|---|
| Host operating system | macOS |
| Virtualization environment | Colima |
| VM operating system | Ubuntu 24.04.4 LTS |
| Kubernetes distribution | K3s |
| Kubernetes version | v1.28.5+k3s1 |
| Container runtime | containerd |
| CPU | 4 cores |
| Memory | 12 GB |
| Image registry access | HTTP Proxy |
| Proxy address | 192.168.5.2:7890 |
2.1 Creating the Colima Kubernetes Environment
Create the Kubernetes development environment with the following command:
bash
colima start k8s \
--runtime containerd \
--cpu 4 \
--memory 12 \
--kubernetes \
--kubernetes-version="v1.28.5+k3s1" \
--env HTTP_PROXY=http://localhost:7890 \
--env HTTPS_PROXY=http://localhost:7890The main options are:
--runtime containerd: Use containerd as the container runtime.--kubernetes: Enable Kubernetes.--kubernetes-version: Specify the Kubernetes version used by K3s.--cpu: Allocate 4 CPU cores.--memory: Allocate 12 GB of memory.
One important detail: the Colima VM and the macOS host operate in separate network environments.
Therefore, localhost:7890 on the macOS host is not the same as localhost:7890 inside the Colima VM. To access a proxy running on the host from inside the VM, you must use an address that is reachable from the VM.
In this environment, the proxy is accessible from the VM at:
text
192.168.5.2:78903. Observed Symptoms
After creating the cluster, first check the Kubernetes Nodes:
bash
kubectl get nodesExample output:
text
NAME STATUS ROLES AGE VERSION
colima-k8s Ready control-plane,master 3d v1.28.5+k3s1The Node reports Ready, indicating that the Kubernetes control plane has started.
However, checking the system Pods:
bash
kubectl get pods -n kube-systemreveals that multiple system components remain in ContainerCreating, for example:
text
NAME READY STATUS
coredns-... 0/1 ContainerCreating
metrics-server-... 0/1 ContainerCreating
local-path-provisioner-... 0/1 ContainerCreating
traefik-... 0/1 ContainerCreatingInspect one of the affected Pods:
bash
kubectl describe pod <pod-name> -n kube-systemThe Events section shows an error similar to:
text
FailedCreatePodSandBox
failed to pull image "registry.k8s.io/pause:3.10.2"
failed to resolve image
lookup registry.k8s.io on [::1]:53
read udp [::1]:...->[::1]:53: read: connection refusedAn important clue is:
text
lookup registry.k8s.io on [::1]:53This indicates that the container runtime is attempting to resolve the registry hostname through a DNS service listening on the local IPv6 loopback address ::1, but the DNS request is being refused.
The first step is therefore to investigate DNS configuration inside the Colima VM.
4. Issue 1: Incorrect DNS Configuration Inside the Colima VM
4.1 Inspecting DNS Configuration
Connect to the Colima VM:
bash
colima ssh --profile k8sInspect the DNS configuration:
bash
cat /etc/resolv.confCheck the file itself:
bash
ls -l /etc/resolv.confThe output shows:
text
/etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.confIn other words, /etc/resolv.conf is a symbolic link pointing to:
text
/run/systemd/resolve/stub-resolv.confHowever, further inspection reveals that the target directory does not exist:
bash
ls -l /run/systemd/resolve/Also check the status of systemd-resolved:
bash
sudo systemctl status systemd-resolvedThe corresponding service is not present.
This means the current DNS configuration depends on a stub resolver file that is not available. As a result, the system cannot successfully resolve domain names through its configured local DNS resolver.
4.2 Inspecting the VM Network
Check the default route:
bash
ip routeExample output:
text
default via 192.168.5.2 dev eth0 proto dhcp src 192.168.5.1 metric 200This shows that:
- The Colima VM network interface is
eth0. - The VM IP address is
192.168.5.1. - The default gateway is
192.168.5.2.
In this environment, 192.168.5.2 is also the address through which the host proxy service can be reached.
4.3 Fixing DNS Configuration
Since /etc/resolv.conf points to a target file that does not exist, replace it with a valid DNS configuration.
Run:
bash
sudo tee /etc/resolv.conf <<'EOF'
nameserver 192.168.5.2
options timeout:2 attempts:2
EOFThis configures 192.168.5.2 as the DNS server.
Note: Whether this address can act as a DNS server depends on the current Colima network environment and the host's DNS forwarding configuration. In this particular environment, domain name resolution worked after applying this change.
Verify the result:
bash
getent hosts registry.k8s.ioIf the command returns the corresponding IP address, DNS resolution is working again.
4.4 A New Problem After Fixing DNS
Check the Pod Events again.
The original DNS error is no longer the latest failure. A new error appears:
text
failed to do request:
Head "https://us-west2-docker.pkg.dev/v2/k8s-artifacts-prod/images/pause/manifests/3.10.2":
dial tcp 64.233.189.82:443: i/o timeoutThis indicates that:
registry.k8s.iocan now be resolved.- The registry request is being redirected.
- The final HTTPS connection to Google Artifact Registry is timing out.
At this point, the DNS issue has been resolved, but image pulls are still failing.
The next step is to investigate proxy configuration.
5. Issue 2: containerd Is Not Configured to Use the HTTP/HTTPS Proxy
5.1 Verifying Host Proxy Connectivity
First, inspect the proxy environment variables inside the Colima VM:
bash
env | grep -i proxyExample output:
text
https_proxy=http://192.168.5.2:7890
HTTPS_PROXY=http://192.168.5.2:7890
HTTP_PROXY=http://192.168.5.2:7890
http_proxy=http://192.168.5.2:7890This confirms that the current shell environment already has proxy variables configured.
Next, test the proxy port:
bash
curl -v --connect-timeout 5 \
http://host.lima.internal:7890The response in this environment is:
text
Connected to 192.168.5.2 (192.168.5.2) port 7890
HTTP/1.1 502 Bad GatewayThe 502 response occurs because the proxy port is being accessed as an ordinary HTTP destination. It does not, by itself, indicate that the proxy is unavailable. The important detail is that the TCP connection was successfully established.
To test the proxy correctly, use curl's -x option:
bash
curl -x http://host.lima.internal:7890 \
-I --connect-timeout 10 \
https://registry.k8s.io/v2/The response is:
text
HTTP/1.1 200 Connection established
HTTP/2 401
content-type: text/plain; charset=utf-8
www-authenticate: Bearer realm="https://registry.k8s.io/token"The 401 Unauthorized response is expected when accessing the Registry API without providing authentication credentials.
This confirms that:
- The VM can reach the host proxy.
- The proxy can establish an HTTPS CONNECT tunnel.
registry.k8s.iocan be accessed through the proxy.
Therefore, the host proxy itself is working.
5.2 Inspecting K3s Proxy Configuration
Inspect the K3s systemd service:
bash
sudo systemctl cat k3sThe service uses the following runtime endpoint:
ini
ExecStart=/usr/local/bin/k3s \
server \
...
'--container-runtime-endpoint' \
'unix:///run/containerd/containerd.sock'This indicates that K3s is using a separately running containerd service.
Check the environment variables configured for K3s:
bash
sudo systemctl show k3s --property=EnvironmentThe output is:
text
Environment=This indicates that proxy variables have not been configured through the K3s systemd Environment= property.
5.3 Configuring the Proxy for K3s
Inspect the K3s service definition:
bash
sudo systemctl cat k3sThe service contains:
ini
EnvironmentFile=-/etc/systemd/system/k3s.service.envTherefore, the proxy configuration can be added through this file:
bash
sudo tee /etc/systemd/system/k3s.service.env <<'EOF'
HTTP_PROXY=http://192.168.5.2:7890
HTTPS_PROXY=http://192.168.5.2:7890
http_proxy=http://192.168.5.2:7890
https_proxy=http://192.168.5.2:7890
NO_PROXY=localhost,127.0.0.1,::1,192.168.5.0/24,10.42.0.0/16,10.43.0.0/16,.svc,.cluster.local
no_proxy=localhost,127.0.0.1,::1,192.168.5.0/24,10.42.0.0/16,10.43.0.0/16,.svc,.cluster.local
EOFReload the systemd configuration and restart K3s:
bash
sudo systemctl daemon-reload
sudo systemctl restart k3sVerify that the service has loaded the proxy variables:
bash
PID=$(systemctl show k3s -p MainPID --value)
sudo sh -c "tr '\0' '\n' < /proc/$PID/environ" | grep -i proxyThe proxy variables are now successfully loaded by the K3s process.
However, running the following command again:
bash
sudo k3s crictl pull registry.k8s.io/pause:3.10.2still produces an error:
text
dial tcp 74.125.203.82:443: i/o timeoutThis shows that configuring the proxy for K3s alone is not sufficient.
5.4 Identifying containerd as the Actual Image Pulling Component
Inspect the containerd service:
bash
sudo systemctl status containerd --no-pagerThe output shows:
text
containerd.service
Active: active (running)
Main PID: 946 (containerd)Next, inspect its environment variables:
bash
sudo systemctl show containerd \
-p MainPID \
-p EnvironmentThe result is:
text
MainPID=946
Environment=Check the actual process environment:
bash
PID=$(systemctl show containerd -p MainPID --value)
sudo sh -c "tr '\0' '\n' < /proc/$PID/environ" | grep -i proxyThere is no output.
This reveals the key problem:
The K3s main process has proxy configuration, but the independently running containerd service does not.
Kubernetes image pulls are performed by the container runtime. In this environment, containerd is the component responsible for pulling images, not the K3s main process.
Therefore, containerd must be configured to use the proxy separately.
6. Fixing containerd Proxy Configuration
6.1 Inspecting the containerd systemd Service
Run:
bash
sudo systemctl cat containerdThe service file in this environment is:
text
/usr/local/lib/systemd/system/containerd.serviceIts main configuration is:
ini
[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5Check whether any systemd Drop-in configuration already exists:
bash
sudo systemctl show containerd \
-p FragmentPath \
-p DropInPathsThe result is:
text
FragmentPath=/usr/local/lib/systemd/system/containerd.service
DropInPaths=There is currently no additional systemd override.
Rather than directly modifying the original service file managed by Colima, use a systemd Drop-in configuration to add the proxy settings.
6.2 Creating a systemd Override
Create the configuration directory:
bash
sudo mkdir -p /etc/systemd/system/containerd.service.dCreate the proxy configuration:
bash
sudo tee /etc/systemd/system/containerd.service.d/proxy.conf <<'EOF'
[Service]
Environment="HTTP_PROXY=http://192.168.5.2:7890"
Environment="HTTPS_PROXY=http://192.168.5.2:7890"
Environment="http_proxy=http://192.168.5.2:7890"
Environment="https_proxy=http://192.168.5.2:7890"
Environment="NO_PROXY=localhost,127.0.0.1,::1,192.168.5.0/24,10.42.0.0/16,10.43.0.0/16,.svc,.cluster.local"
Environment="no_proxy=localhost,127.0.0.1,::1,192.168.5.0/24,10.42.0.0/16,10.43.0.0/16,.svc,.cluster.local"
EOFThe environment variables serve the following purposes:
| Variable | Purpose |
|---|---|
| HTTP_PROXY | Proxy for HTTP requests |
| HTTPS_PROXY | Proxy for HTTPS requests |
| http_proxy | Lowercase compatibility for the HTTP proxy |
| https_proxy | Lowercase compatibility for the HTTPS proxy |
| NO_PROXY | Addresses that should bypass the proxy |
| no_proxy | Lowercase compatibility for the proxy exclusion list |
The NO_PROXY configuration includes:
localhostand loopback addresses.- The Colima VM network.
- The K3s Pod CIDR:
10.42.0.0/16. - The K3s Service CIDR:
10.43.0.0/16. - Internal Kubernetes service domains.
Note: These CIDR ranges reflect the network configuration used in this environment. If your cluster uses different Pod or Service CIDRs, adjust the values accordingly.
6.3 Restarting containerd
Reload the systemd configuration:
bash
sudo systemctl daemon-reloadRestart containerd:
bash
sudo systemctl restart containerdCheck the service status:
bash
sudo systemctl status containerd --no-pagerConfirm that the service is running and the Drop-in configuration has been loaded:
text
Drop-In: /etc/systemd/system/containerd.service.d
└── proxy.conf
Active: active (running)6.4 Verifying containerd Proxy Environment Variables
Get the containerd process ID:
bash
PID=$(systemctl show containerd -p MainPID --value)Inspect its environment variables:
bash
sudo sh -c "tr '\0' '\n' < /proc/$PID/environ" | grep -i proxyThe verification result is:
text
HTTP_PROXY=http://192.168.5.2:7890
HTTPS_PROXY=http://192.168.5.2:7890
http_proxy=http://192.168.5.2:7890
https_proxy=http://192.168.5.2:7890
NO_PROXY=localhost,127.0.0.1,::1,192.168.5.0/24,10.42.0.0/16,10.43.0.0/16,.svc,.cluster.local
no_proxy=localhost,127.0.0.1,::1,192.168.5.0/24,10.42.0.0/16,10.43.0.0/16,.svc,.cluster.localThis confirms that containerd has successfully loaded the proxy environment variables.
6.5 Verifying Image Pulls
Use the crictl bundled with K3s to verify image pulling:
bash
sudo k3s crictl pull registry.k8s.io/pause:3.10.2The final result is:
text
Image is up to date for sha256:3884a337192318652b28de0de1aeb07f446a14f220feb5066f03e93f23ea3b60Image pull successful!
At this point, containerd can access Kubernetes image registries through the configured proxy.
7. Verifying the Kubernetes Cluster
After fixing DNS and containerd proxy configuration, verify that the Kubernetes system components have recovered.
First, check the Node status:
bash
kubectl get nodesThe Node should report Ready.
Next, inspect Pods across all namespaces:
bash
kubectl get pods -AThe actual verification result is:
text
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system svclb-traefik-b9ec4db5-dfsmz 2/2 Running 2 (14m ago) 10h
kube-system traefik-f4564c4f4-g77n8 1/1 Running 1 (14m ago) 10h
kube-system helm-install-traefik-n9kbv 0/1 Completed 0 10m
kube-system helm-install-traefik-crd-rj6p6 0/1 Completed 0 10m
kube-system local-path-provisioner-84db5d44d9-vlnfm 1/1 Running 2 (10m ago) 3d11h
kube-system coredns-6799fbcd5-7rx2j 1/1 Running 1 (14m ago) 3d11h
kube-system metrics-server-74b54d65cc-xxd2k 1/1 Running 2 (9m40s ago) 11hThe results confirm that the main Kubernetes system components are running normally:
| Component | Status | Description |
|---|---|---|
| CoreDNS | Running | Cluster DNS service is operational |
| Traefik | Running | Ingress controller is operational |
| ServiceLB | Running | LoadBalancer service components are operational |
| local-path-provisioner | Running | Local persistent volume provisioning is operational |
| Metrics Server | Running | Cluster resource metrics collection is operational |
| Helm installation Jobs | Completed | Traefik and its CRDs have been installed successfully |
The two Helm installation Pods showing Completed is expected. They are one-time installation Jobs, not long-running services.
All listed Kubernetes system components have reached their expected states.
In particular, CoreDNS, Traefik, ServiceLB, local-path-provisioner, and Metrics Server are all running. This confirms that the previous image-pulling failures have been resolved and the cluster's main system components have recovered.
You can also inspect the APIService resources:
bash
kubectl get apiservicesPay particular attention to whether the Metrics Server APIService reports Available=True. This verifies that the resource metrics API is being served successfully.
8. Conclusion
The issue encountered in this troubleshooting session was not caused by a K3s version problem or a failure of the Kubernetes control plane itself. Instead, image pulling failed because of a combination of network configuration problems inside the Colima VM and missing proxy configuration in containerd.
The troubleshooting process can be divided into two stages.
8.1 Incorrect DNS Configuration
The initial error was:
text
lookup registry.k8s.io on [::1]:53
read: connection refusedThe root cause was that /etc/resolv.conf pointed to a systemd-resolved stub file that did not exist.
Replacing /etc/resolv.conf with a valid DNS configuration restored domain name resolution inside the VM.
8.2 Missing Proxy Configuration in containerd
After DNS resolution was fixed, the error changed to:
text
dial tcp <Google Registry IP>:443: i/o timeoutThe root cause was that K3s and containerd were running as separate systemd services.
Configuring a proxy for the K3s service does not mean that containerd automatically inherits the same environment variables.
The problem was ultimately resolved by configuring the proxy separately for both services:
text
/etc/systemd/system/k3s.service.env
/etc/systemd/system/containerd.service.d/proxy.confThis resolved the proxy configuration issues for K3s and containerd.
8.3 Final Configuration Architecture
The final configuration structure is:
text
macOS
│
├── HTTP Proxy
│ └── 192.168.5.2:7890
│
└── Colima VM
│
├── /etc/resolv.conf
│ └── nameserver 192.168.5.2
│
├── k3s.service
│ └── /etc/systemd/system/k3s.service.env
│
└── containerd.service
└── /etc/systemd/system/containerd.service.d/
└── proxy.confThe final image pulling request flow is:
8.4 Lessons Learned
Several practical lessons can be drawn from this troubleshooting process:
- Do not treat the Colima VM and the macOS host as the same network environment. Their
localhostaddresses are different. - Successful DNS resolution does not guarantee registry connectivity. A registry request may be redirected, so the final destination must also be reachable.
- K3s and containerd are independent services. Configuring a proxy for the K3s process does not automatically configure the proxy for containerd.
- Use
crictlto troubleshoot image pulling directly.sudo k3s crictl pullallows you to verify the container runtime's image pulling capability without involving other Pod scheduling steps. - Prefer systemd Drop-in configurations when modifying service settings. Compared with directly editing the original service files managed by Colima, this approach is easier to maintain and avoids overwriting the original startup configuration.
When using Colima to build a local Kubernetes development environment on macOS, it is worth checking three things:
- DNS configuration inside the VM.
- Connectivity between the VM and the host proxy.
- Proxy environment variables loaded by both K3s and containerd.
All three need to be configured correctly to ensure that Kubernetes system components and application Pods can pull container images successfully.