fix(k3d): resolve cluster hostnames inside the cluster
What does this merge request do and why?
Makes cluster.network.hostname and additional_hostnames resolve inside a k3d cluster, not just on the host.
On Linux the k3d driver only wrote the hostnames to the host's /etc/hosts, so pods (and mirrord sessions, which resolve DNS in-cluster) got NXDOMAIN for gitlab.caproni.test. With the ai-gateway fragment that meant the AI Gateway pod couldn't fetch JWKS from GitLab, and the edit-mode Duo Workflow Service timed out waiting for GitLab. macOS/Colima was never affected because the VM's resolver forwards to the host.
The driver now writes a coredns-custom ConfigMap manifest (a CoreDNS rewrite from each hostname to the k3s Traefik service) into the profile's data directory and bind-mounts it into k3s's manifests directory at cluster create, the same way registries.yaml is handled. k3s applies it before CoreDNS starts and re-applies it whenever the file changes, so hostname edits reach a running cluster on the next caproni up. Skipped when cluster.k3d.k3s.disable includes traefik.
Two things worth knowing:
- caproni now owns
coredns-customon k3d (k3s CoreDNS only reads that one name). Rigs that added their own copy as a workaround should drop it. - Clusters created before this change don't have the bind mount and need one
caproni destroy && caproni up.
References
Closes #299 (closed)
How to set up and validate locally
- On Linux with the k3d driver, use a rig with
cluster.network.hostnameset (e.g.gitlab-org/gitlab-caproniwithfragments/caproni.ai-gateway.yamlenabled). caproni destroy && caproni upwith this branch's binary.caproni kubectl get cm -n kube-system coredns-custom -o yamlshows arewrite stopblock for each configured hostname.caproni kubectl run dns-check --rm -i --restart=Never --image=busybox:1.36 -- nslookup <hostname>answers with thetraefikClusterIP (caproni kubectl get svc -n kube-system traefik).- Once GitLab is up,
caproni kubectl run curl -n ai-gateway --rm -i --restart=Never --image=curlimages/curl -- curl -s -o /dev/null -w '%{http_code}' http://<hostname>/oauth/discovery/keysreturns200, andcaproni kubectl logs -n ai-gateway deploy/ai-gatewayhas noNameResolutionError. - Add an entry to
cluster.network.additional_hostnames,caproni upagain (no recreate), and repeat step 4 for the new name.