k8s: deny ingress to every pod by default
This commit is contained in:
parent
fbc670087a
commit
67218f4052
2 changed files with 241 additions and 27 deletions
|
|
@ -31,7 +31,9 @@ A service gets manifests on the host whose configuration deploys it:
|
|||
| `swarm-victorialogs` | Deployment | Service, NetworkPolicy, PersistentVolume and Claim |
|
||||
| `swarm-logs-auth` | Deployment | ServiceAccount, two Services, NetworkPolicy |
|
||||
|
||||
`namespace.yaml` holds the Namespace ([Pod Security](#pod-security)).
|
||||
`namespace.yaml` holds the Namespace ([Pod Security](#pod-security)), and
|
||||
`default-deny-ingress/networkpolicy.yaml` its default-deny ingress policy
|
||||
([Network](#pods)).
|
||||
|
||||
## One source: the unit
|
||||
|
||||
|
|
@ -129,16 +131,25 @@ credential directory.
|
|||
provider (`identity`), the queue's port (`queue`) and the hive collector's
|
||||
(`collector`). The policy allows its pod on the queue's port 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. A service with a listener and `egress` (`swarm-logs-auth`) has the one
|
||||
policy: it admits the node to the listener and nothing else, and allows the
|
||||
egress above.
|
||||
the host. A service with neither `egress` nor a listener has no policy of
|
||||
its own and relies on the namespace's `default-deny-ingress`, which selects
|
||||
every pod and admits nobody. The cluster's policy engine takes the union of
|
||||
the policies that select a pod and always admits the node's own addresses, so
|
||||
the node reaches a pod, and so does whatever its own policy names. A service with
|
||||
a listener and `egress` (`swarm-logs-auth`) has the one policy: it admits the
|
||||
node to the listener and nothing else, and allows the egress above.
|
||||
- **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
|
||||
them, with `SWARM_CONTROLLER_HEALTH_ADDR`. A third-party daemon with no health variable,
|
||||
`victoria-logs`, names a `probe` path instead (`/health`), which both probes
|
||||
request on its listener.
|
||||
request on its listener. The health port takes no credential, because the
|
||||
kubelet's probes carry none and the routes answer a status code with no body.
|
||||
Only the node reaches it, through the namespace's default-deny
|
||||
ingress policy and the pod's own policy, which admit no other pod and no
|
||||
client of the bridge. The port is an exception to mara's ruling ("if you can reach
|
||||
it, even just in the cluster, it needs auth"): the kubelet has no credential
|
||||
to send.
|
||||
- **Listener and init container:** a service with a TCP `listener`
|
||||
(`swarm-controller`, with `swarm.controller.tcp.enable`) publishes its port
|
||||
with a ClusterIP Service, admits only the node to it with a NetworkPolicy, and
|
||||
|
|
|
|||
|
|
@ -37,9 +37,12 @@ cluster of its own beyond that one main node, and it replicates no service.
|
|||
the addresses in `deploy.k8s.nodeAddresses` only, which is empty by default
|
||||
([Joining nodes](#joining-nodes)).
|
||||
- **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.
|
||||
NetworkPolicy objects; the node doesn't turn it off. The namespace has one
|
||||
policy, `default-deny-ingress`, that selects every pod and admits nobody, so
|
||||
the node's own addresses reach a pod, and so does whatever a policy of its
|
||||
own admits. Other pods and the bridge's agents don't reach a port a pod opens
|
||||
later until a policy names it. [The manifests](manifests.md#pods)
|
||||
say which pods have a policy of their own.
|
||||
- **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).
|
||||
|
|
|
|||
Loading…
Reference in a new issue