k8s: the queue's client port is a loadbalancer service
The queue's client port was a hostPort on 0.0.0.0, which Pod Security baseline and restricted forbid. It is a LoadBalancer Service now, which k3s's service load balancer binds on every address of the node with a hostPort of its own in kube-system, so hives on other hosts keep their URL. No node port is allocated. The stt policy allows the load balancer's pods in place of the queue's, and the prune unit waits for them to go before the host unit starts. The egress published-port rule and the raw-table rules apply to the load balancer's hostPort as to the pod's.
This commit is contained in:
parent
c2d57df7f5
commit
796fd6201f
2 changed files with 200 additions and 75 deletions
|
|
@ -95,7 +95,10 @@ Job:
|
|||
2. Wait for the cluster's API, then delete the service's Deployment, CronJob,
|
||||
Service, NetworkPolicy and ServiceAccount (selected by
|
||||
`app.kubernetes.io/name`), and wait until its pods have gone. A pod exits 0
|
||||
within its termination grace period.
|
||||
within its termination grace period. Then wait until the pods that the
|
||||
service load balancer bound the service's Services' ports with, in
|
||||
`kube-system`, have gone too: the rule that forwards a port to one stays
|
||||
until the pod does.
|
||||
3. Delete the cluster's AddOn for the file, so that a later switch to `"k8s"`
|
||||
applies the same manifest again. Then remove the renamed link.
|
||||
|
||||
|
|
@ -218,21 +221,27 @@ holds the container back until the pod has gone.
|
|||
loopback, so the responder dials the server by the name its leaf carries and
|
||||
verifies it, with no traffic leaving the pod. Every other client reaches the
|
||||
queue by the same name as before: the node's CoreDNS and the bridge's
|
||||
resolver answer it with the bridge's address, and the published port forwards
|
||||
it to the pod.
|
||||
- **The client port.** The server's port is a `hostPort` on `0.0.0.0`, the
|
||||
addresses the container's server listens on, so hives on other hosts keep
|
||||
their URL. A `hostPort` is a DNAT rule, and the firewall's INPUT rules, the
|
||||
ones `deploy.nats.openFirewall` and the bridge's port list write, never see
|
||||
what it rewrites. The module therefore adds rules to the raw table, which is
|
||||
read before the DNAT: a packet for the node's address and the client port is
|
||||
resolver answer it with the bridge's address, and the load balancer's port
|
||||
forwards it to the pod.
|
||||
- **The client port.** The server's port is a `LoadBalancer` Service,
|
||||
`swarm-nats`, with no `hostPort` on the pod. k3s's service load balancer
|
||||
(servicelb, on by default) binds the port on `0.0.0.0` of the node with a
|
||||
`hostPort` of its own, in a pod of `kube-system`, and forwards it to the pod
|
||||
through the Service, so hives on other hosts keep their URL. The Service
|
||||
allocates no node port: the forwarding uses the Service's cluster address,
|
||||
and a node port would be a second way in that the raw-table rules don't name.
|
||||
The server sees the load balancer's pod as the client, not the client's
|
||||
address. A `hostPort` is a DNAT rule, and the firewall's INPUT rules, the ones
|
||||
`deploy.nats.openFirewall` and the bridge's port list write, never see what it
|
||||
rewrites. The module therefore adds rules to the raw table, which the kernel
|
||||
reads before the DNAT: a packet for the node's address and the client port is
|
||||
dropped unless it arrives on the host's loopback, the hive bridge or a pod
|
||||
interface, or unless `deploy.nats.openFirewall` is on. The container's port
|
||||
has that reach. The hostPort sends the bridge's agents to the cluster, which a
|
||||
host with the egress intercept on refuses, so the module also adds the port to
|
||||
`egress.publishedPorts`
|
||||
has that reach. The `hostPort` sends the bridge's agents to the cluster, which
|
||||
a host with the egress intercept on refuses, so the module also adds the port
|
||||
to `egress.publishedPorts`
|
||||
([the egress chain](../networking/network.md#agent-bridge-egress-log)): agents
|
||||
reach the pod through the published port and no other way.
|
||||
reach the queue through the published port and no other way.
|
||||
- **The exporter's port.** The exporter's port has no `hostPort`: a ClusterIP
|
||||
Service, `swarm-nats-metrics`, fronts it, and the gateway's `/metrics`
|
||||
location on the host dials the Service's name through nginx's `resolver` (the
|
||||
|
|
@ -306,9 +315,9 @@ identity provider, the queue and the hive collector, each on its one port. It
|
|||
admits no ingress. The kubelet's probes still reach the pod, because the node's
|
||||
own traffic to a pod is always admitted, and the pod doesn't serve anything
|
||||
else: requests reach it as queue messages, over the connection it opens. Where
|
||||
the queue runs in the cluster, the policy also allows the queue's pod on its
|
||||
port, because the node forwards the queue's `hostPort` to the pod before the
|
||||
policy sees the packet.
|
||||
the queue runs in the cluster, the policy also allows the pods of the queue's
|
||||
load balancer, in `kube-system`, on the queue's port, because the node forwards
|
||||
the `hostPort` they bind to them before the policy sees the packet.
|
||||
|
||||
## Telemetry and credentials of the poller
|
||||
|
||||
|
|
@ -382,28 +391,31 @@ that `claude` with `HOME` in the volume writes its config there, as the
|
|||
minter's real login step does, while `claude` with `HOME` on the root leaves
|
||||
nothing there.
|
||||
|
||||
The VM test `k8s-nats-switch` moves the queue against the real secret store. A
|
||||
sampler counts servers and responders every 200 ms and sees at most one of
|
||||
each, and the container and the pod never together. The pod is Ready by its
|
||||
exec probe and has the init containers, the `hostPort`s and the volumes the
|
||||
module renders, and its leaf's volume is a tmpfs. A client on the bridge
|
||||
reaches the queue by name, and a second node outside the node reaches the
|
||||
control port and not the queue's, as with the container; with `openFirewall`
|
||||
it dials the pod by name and verifies the name, and the responder in the pod
|
||||
admits it. A key written on the host before the switch is the pod's to read, a
|
||||
key the pod writes is the host server's after the switch back, and a stream
|
||||
written before a pod delete survives it: the replacement pod reads it from the
|
||||
same directory. The exporter answers the host's own processes through its
|
||||
Service and no pod or bridge client, and the switch back removes the pod before
|
||||
The VM test `k8s-nats-switch` moves the queue against the real secret store,
|
||||
with the egress intercept on. A sampler counts servers and responders every
|
||||
200 ms and sees at most one of each, and the container and the pod never
|
||||
together. The pod is Ready by its exec probe and has the init containers, the
|
||||
volumes and the Services the module renders and no `hostPort`, and its leaf's
|
||||
volume is a tmpfs. The load balancer binds the client port from `kube-system`
|
||||
and the Service has no node port. A client on the bridge reaches the queue by
|
||||
name and through the published port only, not by the pod's address or the
|
||||
node's, and a second node outside the node reaches the control port and not the
|
||||
queue's, as with the container; with `openFirewall` it dials the pod by name and
|
||||
verifies the name, and the responder in the pod admits it. A key written on the
|
||||
host before the switch is the pod's to read, a key the pod writes is the host
|
||||
server's after the switch back, and a stream written before a pod delete
|
||||
survives it: the replacement pod reads it from the same directory. The exporter
|
||||
answers the host's own processes through its Service and no pod or bridge
|
||||
client, and the switch back removes the pod and the load balancer's pod before
|
||||
the container starts.
|
||||
|
||||
The VM test `k8s-controller-switch` moves the controller. It asserts one copy at
|
||||
each step by the switch's own timestamps and by a sampler, that the pod is Ready
|
||||
on `/readyz` with the `hostPort` and the volumes the module renders and no
|
||||
Secret, that its listener's leaf is the one its init container issued, valid as
|
||||
the listener's name against the hive's root, that the volume holding its key is
|
||||
a tmpfs, and that the listener refuses a client with no leaf. It runs the
|
||||
gateway's own controller location, from the module's text for each runtime,
|
||||
against the host unit and the pod: both answer an unsigned webhook 401. A
|
||||
changed rev rolls the Deployment onto a new pod and keeps the state volume, and
|
||||
the switch back deletes the pod and its AddOn before the unit starts.
|
||||
on `/readyz` with the volumes the module renders and no Secret, that its
|
||||
listener's leaf is the one its init container issued, valid as the listener's
|
||||
name against the hive's root, that the volume holding its key is a tmpfs, and
|
||||
that the listener refuses a client with no leaf. It runs the gateway's own
|
||||
controller location, from the module's text for each runtime, against the host
|
||||
unit and the pod: both answer an unsigned webhook 401. A changed rev rolls the
|
||||
Deployment onto a new pod and keeps the state volume, and the switch back
|
||||
deletes the pod and its AddOn before the unit starts.
|
||||
|
|
|
|||
|
|
@ -763,12 +763,12 @@ also refuses the flow.
|
|||
`services.hyperhive.deploy.hive-controller.egress.publishedPorts`, in both
|
||||
modes, so such a flow leaves no count and no line. A module that publishes a
|
||||
port adds it: the queue in the cluster adds its client port, because the
|
||||
pod's `hostPort` rewrites the destination to the pod and the packet then
|
||||
leaves the bridge for the cluster. An agent dials the queue's name, which the
|
||||
hive's resolver answers with the bridge's address. A flow to the pod's own
|
||||
address has no redirect, and one to the node's address has another original
|
||||
destination, so both stay refused. The set is empty, and the chain has no
|
||||
such rule, while no module publishes a port.
|
||||
`hostPort` of the cluster's load balancer rewrites the destination, and the
|
||||
packet then leaves the bridge for the cluster. An agent dials the queue's
|
||||
name, which the hive's resolver answers with the bridge's address. A flow to
|
||||
the pod's own address has no redirect, and one to the node's address has
|
||||
another original destination, so both stay refused. The set is empty, and the
|
||||
chain has no such rule, while no module publishes a port.
|
||||
- **What `reject` refuses.** Everything from the bridge to the uplink that the
|
||||
chain didn't exempt or allow, whether a flow is new or not: TCP on any port
|
||||
but the 80 and 443 that squid takes, UDP (DNS to an outside resolver, QUIC
|
||||
|
|
|
|||
Loading…
Reference in a new issue