Container domain names (name.krane.local) #15
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
OrbStack gives each container a name like
name.orb.local(with HTTPS). On Linux container IPs are already reachable, so Krane could add names without a VM.What (to discuss before building)
<container>.krane.localand<service>.<project>.krane.localto container IPs, e.g. by registering with systemd-resolved over D-Bus (per-link DNS domain) or a tiny local DNS responder.Notes
Design research for this issue (by Nye, our reviewer, tested on a real Debian 13 box with systemd-resolved). Building waits on the three calls at the end.
Tested on Debian 13, systemd 257, resolved active, nss-mdns active, Docker local.
Prototype responder (40 lines, stdlib) is in the collapsed block at the bottom.
What I proved on a real box
krane0),registered with resolved via SetLinkDNSEx (port supported) + SetLinkDomains(~krane.local, ~krane.internal)
getent/resolvectlresolve web.krane.local, api.shop.krane.local,web.krane.internal; unknown names NXDOMAIN; normal DNS untouched.
mdns4_minimal [NOTFOUND=return], yet 3-label .local names still reached resolved(nss-mdns >= 0.14 only claims 2-label names). So
<c>.krane.localworks; old nss-mdns could break it.set-dns-servers / set-domains = auth_admin_keep for active sessions -> password prompt every login).
so compose-network containers would not resolve. Use a dummy link instead.
Options
(a) Krane registers per-link DNS over D-Bus (zbus, already in Cargo.lock via ksni) at every start.
Runtime: create/find link, call SetLinkDNSEx/Domains. Needs: root to create the dummy link AND
polkit auth each login (or a polkit rule installed once, which can't be scoped to one link).
Breaks: autostart (prompt at login). Code: small, but privilege story is bad.
(b) One-time privileged setup + unprivileged responder (RECOMMENDED).
Setup (pkexec, from a Settings button, once): install
krane-dns.service(oneshot, root) that runsip link add krane0 type dummy; ip addr add 10.253.53.1/32 dev krane0; ip link set krane0 up; resolvectl dns krane0 10.253.53.1:5380; resolvectl domain krane0 '~krane.local'; resolvectl default-route krane0 false, plus NetworkManagerunmanaged-devices=interface-name:krane0.Runtime: Krane binds UDP+TCP 10.253.53.1:5380 (no privilege), answers A/AAAA from the bollard
container list + events (
<name>.krane.local, compose labels -><service>.<project>.krane.local),NXDOMAIN otherwise, TTL ~5s. Krane down -> names fail fast, nothing else affected.
Needs: systemd-resolved. Without it (Debian desktop default, Arch unless enabled, Alpine/musl):
Settings shows "needs systemd-resolved" and the feature stays off; no resolv.conf edits.
Code: responder ~200 lines on
hickory-proto(well used) orsimple-dns(small) for parsing;name map from existing engine data; setup script ~30 lines; zbus read-only check of
org.freedesktop.resolve1 Link "krane0" DNS to show enabled/disabled. About half a day for Dev.
(c) Simpler alternatives, rejected: /etc/hosts (root on every change); NSS module (root install,
C ABI, skipped by apps that use their own resolver); dnsmasq/NM-dnsmasq drop-ins (distro-specific,
not on by default). Running the responder in a container on a Krane bridge network avoids the
dummy link but needs an image pull and a docker.sock mount; not worth it.
Recommendation and v1.0 scope
Go with (b). v1.0 scope:
<container>.krane.localand<service>.<project>.krane.local(A, AAAA if IPv6 IP).Out of scope: HTTPS/local CA/reverse proxy, port-less URLs, non-resolved distros.
Calls for Jeremy
.krane.local(matches the issue/OrbStack; worked here) vs.krane.internal(ICANN-reserved for private use in 2024; no mDNS edge cases). Lean: .krane.local, both work.
Not tried
NetworkManager-managed host (does NM leave krane0's resolved config alone without the unmanaged
drop-in?), Fedora/Ubuntu, Firefox/Chrome with DoH on, IPv6.
Calls needed from @jfro
.krane.localor.krane.internal?10.253.53.1/32or169.254.53.53?Prototype responder (issue15-proto-dns.py)