Watch
0
0
Fork
You've already forked hyperhive
0

k8s: the controller's listener is a ClusterIP service the host dials by name

The controller's api port was a hostPort on the node, which Pod Security baseline and restricted forbid. It is a ClusterIP Service now, behind a NetworkPolicy that admits only the node. The host's resolver (the hive's dnsmasq) forwards cluster.local to CoreDNS, and the gateway dials the Service by name through nginx's resolver. tcp.hostAddress goes.
This commit is contained in:
atlas 2026-11-23 17:20:22 +01:00 • committed by maia
commit 3cf89f25f1

View file

@ -69,6 +69,31 @@ these listeners without a firewall rule per port. Each service still
authenticates its callers: every listener of the secret store but its pods'
one refuses a connection without a client certificate.
## Reaching the cluster from the host
The host's resolver, the hive's dnsmasq (the host's own `/etc/resolv.conf`
names it), forwards the cluster's domain to CoreDNS. `deploy.k8s.clusterDomain`
is `cluster.local` and `deploy.k8s.clusterDns`, the tenth address of
`deploy.k8s.serviceCidr`, is the address k3s gives CoreDNS: the node passes
both as flags (`--cluster-domain`, `--cluster-dns`) and the resolver's
`server=/cluster.local/<address>` line reads the same values. A process on the
host, nginx included, so reaches a Service as
`<name>.<namespace>.svc.cluster.local`. The node doesn't set the line without
`gateway.dns.enable`, the option that runs that resolver.
A ClusterIP answers the host because kube-proxy (k3s runs it in `iptables`
mode) rewrites a host process's connection to the Service's address into the
pod's, and the firewall trusts the pod network's interfaces. The bridge's
agents ask the same resolver, so they get the same names. A name is no route:
the hive's egress rules decide whether the host forwards their traffic to the
cluster's addresses, and a pod's NetworkPolicy refuses what it forwards.
A pod that serves the host, such as the controller's, has a NetworkPolicy that
selects it for ingress and allows nothing. kube-router, the policy engine, adds
a rule at the top of every pod's chain that admits traffic from any address of
the node (`-m addrtype --src-type LOCAL`, commented "from local node"), so the
host reaches the pod and no other pod does.
## Logging in to the secret store
A pod holds no client certificate. It logs in to the secret store with a