k8s: stt's pod gets a network policy: dns and four host ports out, nothing in
This commit is contained in:
parent
4ea3b0e10d
commit
02cc38d89e
3 changed files with 262 additions and 22 deletions
|
|
@ -23,7 +23,7 @@ A service gets manifests on the host whose configuration deploys it:
|
|||
| ------------------------- | ---------- | ------------------------------------------------------------------------------------------------ |
|
||||
| `swarm-controller` | Deployment | ServiceAccount, PersistentVolumeClaim `swarm-controller-state`, ConfigMap `swarm-controller-etc` |
|
||||
| `swarm-notify-router` | Deployment | ServiceAccount |
|
||||
| `swarm-stt` | Deployment | ServiceAccount |
|
||||
| `swarm-stt` | Deployment | ServiceAccount, NetworkPolicy `swarm-stt` |
|
||||
| `swarm-review-classifier` | Deployment | ServiceAccount |
|
||||
| `swarm-claude-login` | Deployment | ServiceAccount |
|
||||
| `swarm-ci-metrics` | CronJob | ServiceAccount, PersistentVolumeClaim `swarm-ci-metrics-state` |
|
||||
|
|
@ -113,6 +113,16 @@ credential directory.
|
|||
renderer drops it. The unit's sandbox settings
|
||||
(`MemoryDenyWriteExecute`, `SystemCallFilter`, `PrivateUsers` and the rest)
|
||||
stay on the host: the pod has the security shape above and no other.
|
||||
- **Network:** a service whose entry has `egress` (`swarm-stt`) gets a
|
||||
NetworkPolicy named after it, selecting its pods for ingress and egress. It
|
||||
allows no ingress; its egress is cluster DNS (the CoreDNS pod, port 53) and,
|
||||
on the hive bridge's address, one TCP port per host service the entry names:
|
||||
the store's pod listener (`store`), the gateway's 443 for the identity
|
||||
provider (`identity`), the queue's port (`queue`) and the hive collector's
|
||||
(`collector`). Where the queue runs in the cluster, its pod on its port is
|
||||
allowed too. The node trusts the pod network's interfaces, so without the
|
||||
policy a pod reaches every port of the host. A service without `egress` has no
|
||||
policy.
|
||||
- **Probes:** a service with an opt-in health listener gets its variable set to
|
||||
`0.0.0.0:8080`, with liveness on `/healthz` and readiness on `/readyz`
|
||||
(see [Readiness checks](../swarm/readiness.md)). `swarm-controller` is one of
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ service images loaded and no service's objects applied.
|
|||
bridge's default subnet.
|
||||
- **Firewall:** the pod network's interfaces, `cni0` and `flannel.1`, are
|
||||
trusted, so the node reaches its pods.
|
||||
- **NetworkPolicy:** k3s's own controller (kube-router, iptables) enforces
|
||||
NetworkPolicy objects; the node doesn't turn it off. A pod no policy selects
|
||||
reaches whatever it can route to. [The manifests](manifests.md#pods) say which
|
||||
pods have one.
|
||||
- **Secret store:** the store gets a second listener and an auth mount for the
|
||||
pods' ServiceAccount tokens, described under
|
||||
[Logging in to the secret store](#logging-in-to-the-secret-store).
|
||||
|
|
|
|||
|
|
@ -92,9 +92,10 @@ Job:
|
|||
cluster doesn't apply it again. The rename also records what remains to
|
||||
delete. With no link, nothing went in, so the unit does nothing and needs no
|
||||
cluster.
|
||||
2. Wait for the cluster's API, then delete the service's Deployment, CronJob and
|
||||
ServiceAccount (selected by `app.kubernetes.io/name`), and wait until its pods
|
||||
have gone. A pod exits 0 within its termination grace period.
|
||||
2. Wait for the cluster's API, then delete the service's Deployment, CronJob,
|
||||
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.
|
||||
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.
|
||||
|
||||
|
|
@ -274,12 +275,20 @@ The pod takes the unit's `MemoryMax` and `CPUQuota` as its container's limits
|
|||
([manifests](manifests.md#pods)), so `swarm-stt` keeps its 3 GiB and four-core
|
||||
ceilings. The pod requests nothing (memory `0`, cpu `0`, as the unit sets no
|
||||
`MemoryMin` or `MemoryLow`), so the node reserves nothing for it and the pod is
|
||||
Burstable. `TasksMax` has no pod counterpart, so the renderer drops it. The systemd sandbox
|
||||
(`MemoryDenyWriteExecute`, `SystemCallFilter`, `PrivateUsers`, the read-only
|
||||
`ProtectSystem` and the rest) stays on the host. The pod is a non-root user with
|
||||
a read-only root filesystem, every capability dropped, the runtime's default
|
||||
seccomp profile and no API token, which is its whole sandbox. Neither side
|
||||
restricts the network.
|
||||
Burstable. `TasksMax` has no pod counterpart, so the renderer drops it. The
|
||||
systemd sandbox (`MemoryDenyWriteExecute`, `SystemCallFilter`, `PrivateUsers`,
|
||||
the read-only `ProtectSystem` and the rest) stays on the host. The pod is a
|
||||
non-root user with a read-only root filesystem, every capability dropped, the
|
||||
runtime's default seccomp profile and no API token. The host unit doesn't
|
||||
restrict the network. The pod has a NetworkPolicy (`swarm-stt`, rendered with
|
||||
the pod): it may reach cluster DNS, and on the node's bridge address the store's
|
||||
pod listener, the 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.
|
||||
|
||||
## Telemetry and credentials of the poller
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue