Files
hapi/docs/adr/0015-cluster-hardening-baseline.md
2026-11-27 16:05:30 -05:00

5.1 KiB

Cluster hardening baseline: deny-by-default network, restricted pods, audit logs; signing deferred

v1 hardens the cluster with built-in mechanisms only. That means default-deny CiliumNetworkPolicies in every namespace we own, Pod Security restricted wherever it fits, two ValidatingAdmissionPolicies (in-apiserver CEL rules), Kubernetes audit logging, and a written upgrade runbook with a fixed cadence. Commit signature verification and cosign image signing are deferred. We chose this because each measure here closes a real gap without adding a controller to run. Signing would only move trust onto keys held by the same Gitea and runner it's meant to protect against.

Considered Options

  • Flux commit verification plus cosign signing with admission-time verification, in v1. Rejected for now. CI commits the digest bump to main (ADR-0007), so HEAD is usually a CI commit, and CI would need its own signing key. There's no keyless identity for Gitea, so the cosign key would be key-based too. Both keys would live in Gitea Actions secrets or on the runner, where an attacker who controls Gitea can run a workflow that uses them. Signed tags from a hardware key would break "every green merge deploys". Flux image automation would need git write credentials in the cluster.
  • Kyverno (or sigstore policy-controller) for admission. Rejected for two rules. It adds a controller, a webhook that can fail open or closed, and more upgrades to keep up with. Revisit when signing returns.
  • Moving monitoring to privileged as a whole. Rejected in favour of isolating the node agents in their own namespace.
  • Keeping ops reminders out of hAPI (a personal calendar), since hAPI can't remind you to fix hAPI while it's down. Rejected: these are recurring upkeep, which is what Maintenance Tasks are for, and Kuma covers the outage case. The glossary's Maintenance now includes the Household's digital systems.

Consequences

  • NetworkPolicy: every namespace we own (hapi, bots, gateway, envoy-gateway-system, monitoring, monitoring-node, cert-manager, flux-system) is default-deny for ingress and egress. Each component's allows sit next to its manifests in deploy/. Rules that name hosts are CiliumNetworkPolicy, using toFQDNs for ntfy, Linode Object Storage, the Linode API, SimpleFIN, Kuma and Let's Encrypt, and toCIDR for the Managed DB's VPC address. This includes the allows already promised by ADR-0009, ADR-0011, ADR-0013 and ADR-0014. kube-system (Cilium, CCM and CoreDNS, installed by Tofu) stays open.

  • Pod Security: the cluster default stays at Talos's baseline. Every namespace we own enforces restricted, except monitoring-node, which is privileged and holds only the Vector and node-exporter DaemonSets. This amends ADR-0009.

  • Admission (ValidatingAdmissionPolicy, Deny from day one, delivered by Flux):

    1. Images must come from Gitea's registry, or carry an @sha256: digest. Applies everywhere except kube-system.
    2. Pods in hapi and bots must set readOnlyRootFilesystem: true and automountServiceAccountToken: false.
  • Audit logging: the apiserver audit policy is set in Talos machine config at Metadata level. It keeps every write and every access to secrets, pods/exec, pods/portforward and serviceaccounts/token, and drops controllers' and Flux's reads, health endpoints and Events. Vector in monitoring-node ships the control-plane node's audit file to VictoriaLogs, where it's kept 1 year and included in ADR-0014's daily audit/ export. A pods/exec or a Secret read by a human sends an alert to the ntfy ops topic. Dial the policy back if it's too noisy.

  • Upgrades: Talos, Kubernetes, Cilium and CCM versions are pinned in infra/. Renovate opens PRs for them and never auto-merges. Security patches go in within 14 days; minor versions after their .1, staying within upstream support. The procedure goes in docs/runbooks/cluster-upgrade.md, written during the build:

    1. Take a throwaway local talosctl etcd snapshot, never stored (ADR-0014's no-etcd-backups rule still holds).
    2. Upgrade and drain the workers one at a time.
    3. Upgrade the control plane, accepting a few minutes without the API.
    4. Run talosctl health and check that Flux reconciles.

    The reminder is a monthly Household Maintenance Task, "Upgrade the cluster", on a "hAPI cluster" Asset. ADR-0014's "Rehearse disaster recovery" Task hangs off the same Asset.

  • Supply chain in v1: images stay digest-pinned (ADR-0007), admission rule 1 limits where images come from, CI's Trivy scan stays, and main has branch protection in Gitea. Revisit signing once CI has an identity a compromised Gitea can't use.

  • Deferred to v2: runtime detection (Tetragon/Falco), in-cluster vulnerability scanning (Trivy Operator), CIS scanning, the Cilium host firewall (the Linode Cloud Firewall already covers nodes), least-privilege kubeconfigs (the Owner keeps Talos's admin kubeconfig, used only over the tailnet), and any CI check of policy coverage. etcd secret encryption needs no decision: Talos enables it by default.