k3s custom CAs from OpenBao + pre-generated join token #11

Closed
opened 2026-11-05 16:59:32 +00:00 by ginjiruu · 5 comments
Owner

Part of lab/machine-configs#7.

Facts (docs.k3s.io/cli/certificate)

  • k3s accepts custom CAs placed before its first start: root -> intermediate -> per-purpose CAs (server-ca, client-ca, request-header-ca, etcd peer-ca/server-ca, all with keys) plus service.key.
  • A cluster started on custom CAs can rotate them non-disruptively as long as the root stays the same.
  • With custom CAs the full-format join token (CA hash pinned) can be used on the first server.

What

  • Mint each cluster's CA set from pki-k3s-<cluster> before first boot; deliver keys to server nodes via the OpenBao Agent.
  • Pre-generate the full-format k3s token and store it in OpenBao.
  • Rotation procedure (same root) documented.

Done when

  • A fresh cluster in the harness starts on OpenBao-issued CAs
  • k3s certificate check chains to the lab root
  • CA rotation rehearsed in the harness
Part of lab/machine-configs#7. ## Facts (docs.k3s.io/cli/certificate) - k3s accepts custom CAs placed before its **first** start: root -> intermediate -> per-purpose CAs (server-ca, client-ca, request-header-ca, etcd peer-ca/server-ca, all with keys) plus `service.key`. - A cluster started on custom CAs can rotate them non-disruptively as long as the root stays the same. - With custom CAs the full-format join token (CA hash pinned) can be used on the first server. ## What - Mint each cluster's CA set from `pki-k3s-<cluster>` before first boot; deliver keys to server nodes via the OpenBao Agent. - Pre-generate the full-format k3s token and store it in OpenBao. - Rotation procedure (same root) documented. ## Done when - [ ] A fresh cluster in the harness starts on OpenBao-issued CAs - [ ] `k3s certificate check` chains to the lab root - [ ] CA rotation rehearsed in the harness
Author
Owner

Naming: per mc#9 (rewritten 2026-11-11) the mount is pki-cluster-, not pki-k3s-. CA set generator: scripts/pki-ceremony-2.sh (cebf33c) writes client/server/request-header/etcd-peer/etcd-server CAs (pathlen 0, chain = CA + lab root, no k3s intermediate layer), root-ca.pem, service.key and a K10 full-format token to OpenBao KV infra/k3s/. Harness must confirm k3s accepts the set without intermediate-ca.*.

Naming: per mc#9 (rewritten 2026-11-11) the mount is pki-cluster-<cluster>, not pki-k3s-<cluster>. CA set generator: scripts/pki-ceremony-2.sh (cebf33c) writes client/server/request-header/etcd-peer/etcd-server CAs (pathlen 0, chain = CA + lab root, no k3s intermediate layer), root-ca.pem, service.key and a K10 full-format token to OpenBao KV infra/k3s/<cluster>. Harness must confirm k3s accepts the set without intermediate-ca.*.
Author
Owner

2026-11-11: the CA set generator is scripts/pki-cluster-ca.sh <cluster> (5c7cfd5). It writes OpenBao KV infra/k3s/<cluster> with k3s file names as keys: {client,server,request-header}-ca.{crt,key,pem}, etcd/{peer,server}-ca.{crt,key,pem}, root-ca.pem, service.key, token. CAs are signed by pki-issue (pathlen 0) with DNS name constraints from pki/clusters/<cluster>.domains. *.crt = CA + pki-issue + root. No k3s intermediate-ca layer.

Harness checklist added by this design:

  • k3s first start accepts the set without intermediate-ca.*
  • Every DNS SAN k3s issues (apiserver, supervisor, kubelet serving, etcd) is inside the constraint list. Check k3s certificate check plus a TLS handshake per component
  • Join token: the K10 hash pin (sha256 of server-ca.crt) matches what a joining node computes
  • The apiserver serves its chain, so a client trusting only the lab root validates it (the k8s-hub BackendTLSPolicy case)
  • Rotation rehearsal (same root)

Open, decide before minting think's set: name constraints pin node hostnames. A new node whose name isn't in think.domains fails validation, so adding one means rotating the cluster CAs. Recommended fix at the #14 rebuild: node names under the cluster zone (--node-name think-01.think.int.animeteamspeak.moe), so one think.int.animeteamspeak.moe constraint covers every future node.

2026-11-11: the CA set generator is `scripts/pki-cluster-ca.sh <cluster>` (5c7cfd5). It writes OpenBao KV `infra/k3s/<cluster>` with k3s file names as keys: `{client,server,request-header}-ca.{crt,key,pem}`, `etcd/{peer,server}-ca.{crt,key,pem}`, `root-ca.pem`, `service.key`, `token`. CAs are signed by pki-issue (pathlen 0) with DNS name constraints from `pki/clusters/<cluster>.domains`. `*.crt` = CA + pki-issue + root. No k3s intermediate-ca layer. Harness checklist added by this design: - [ ] k3s first start accepts the set without `intermediate-ca.*` - [ ] Every DNS SAN k3s issues (apiserver, supervisor, kubelet serving, etcd) is inside the constraint list. Check `k3s certificate check` plus a TLS handshake per component - [ ] Join token: the K10 hash pin (sha256 of server-ca.crt) matches what a joining node computes - [ ] The apiserver serves its chain, so a client trusting only the lab root validates it (the k8s-hub BackendTLSPolicy case) - [ ] Rotation rehearsal (same root) **Open, decide before minting think's set:** name constraints pin node hostnames. A new node whose name isn't in `think.domains` fails validation, so adding one means rotating the cluster CAs. Recommended fix at the #14 rebuild: node names under the cluster zone (`--node-name think-01.think.int.animeteamspeak.moe`), so one `think.int.animeteamspeak.moe` constraint covers every future node.
Author
Owner

2026-11-11: c1 CA set minted (scripts/pki-cluster-ca.sh c1) into OpenBao KV infra/k3s/c1, version 1. Verified from the stored certs: all five CAs pathlen 0, name constraints localhost / kubernetes / c1.caosh.int.animeteamspeak.moe, chain CA + pki-issue + root, Go verifies each against pki/root.crt. Token pin (sha256 of server-ca.crt): f1c089764e97f04d1f990c105741a33323ad2b564679160dfe5a25a353680f0c.

Note: the CAs expire 2031-11-10. OpenBao caps them at pki-issue's own expiry, so the requested 3700 days doesn't apply. Plan a same-root CA rotation before then; pki-issue renewal is a Nano session anyway.

2026-11-11: c1 CA set minted (scripts/pki-cluster-ca.sh c1) into OpenBao KV infra/k3s/c1, version 1. Verified from the stored certs: all five CAs pathlen 0, name constraints localhost / kubernetes / c1.caosh.int.animeteamspeak.moe, chain CA + pki-issue + root, Go verifies each against pki/root.crt. Token pin (sha256 of server-ca.crt): f1c089764e97f04d1f990c105741a33323ad2b564679160dfe5a25a353680f0c. Note: the CAs expire 2031-11-10. OpenBao caps them at pki-issue's own expiry, so the requested 3700 days doesn't apply. Plan a same-root CA rotation before then; pki-issue renewal is a Nano session anyway.
Author
Owner

2026-11-11: c1 CA set RE-MINTED (v1 deleted: it lacked kubernetes.default, kubernetes.default.svc, kine.sock and the bare hostnames, so k3s would have rejected its own certs).

Verified from the stored set:

  • all five CAs pathlen 0, with 13 permitted DNS names: localhost, kubernetes, kubernetes.default, kubernetes.default.svc, c1.caosh.int.animeteamspeak.moe, kine.sock, think-01..03, pi-01..04
  • Go (scripts/x509-verify.go) verifies each against pki/root.crt
  • expires 2031-11-10
  • token pin = sha256(server-ca.crt) = 10c58cdeff8321b233d555d31f22a605d9d09ec29003681b429ab3b50f0bde4f
  • infra/k3s/c1/join holds only token, identical to the main copy

A new node joining c1 must first be added to pki/clusters/c1.domains, followed by a same-root rotation (docs/k3s-ca-rotation.md).

2026-11-11: c1 CA set RE-MINTED (v1 deleted: it lacked `kubernetes.default`, `kubernetes.default.svc`, `kine.sock` and the bare hostnames, so k3s would have rejected its own certs). Verified from the stored set: - all five CAs pathlen 0, with 13 permitted DNS names: localhost, kubernetes, kubernetes.default, kubernetes.default.svc, c1.caosh.int.animeteamspeak.moe, kine.sock, think-01..03, pi-01..04 - Go (`scripts/x509-verify.go`) verifies each against `pki/root.crt` - expires 2031-11-10 - token pin = sha256(server-ca.crt) = `10c58cdeff8321b233d555d31f22a605d9d09ec29003681b429ab3b50f0bde4f` - `infra/k3s/c1/join` holds only `token`, identical to the main copy **A new node joining c1 must first be added to `pki/clusters/c1.domains`, followed by a same-root rotation** (`docs/k3s-ca-rotation.md`).
Author
Owner

Done 2026-11-11, on main (38d405a..c6ba316). Fleet hosts evaluate unchanged; c1 switches on at #14.

  • cluster.pki.fromOpenbao: the agent renders CAs, service.key and the token from KV infra/k3s/<c> (agents only /join); k3s seeds server/tls before its first start only.
  • cluster.zone (cluster-domain plus <host>.<zone> node names), cluster.clusterInit, read-only k3s.nodeName used by deploy-health/node-health.
  • Rotation: pki-cluster-ca.sh --rotate + scripts/k3s-rotate-ca.sh, docs/k3s-ca-rotation.md, rehearsed by vm:rotate-check (a pre-rotation service-account token still works).
  • cluster.registryMirror: Harbor pull-through from KV infra/harbor/node-pull (written by the harbor root, lab/iac #59/#60); registries.yaml is in the k3s fingerprint.
  • c1 CA set re-minted with the complete constraint list (k3s needs kubernetes.default(.svc), kine.sock and each bare hostname). A new node means a domains edit plus rotation.

Done-when:

  • fresh harness cluster starts on OpenBao-issued CAs (vm:check: seeded set in use, token pin, all 6 ports and kubectl verify to the root only, Go verifies every leaf)
  • k3s certificate check chains to the lab root
  • CA rotation rehearsed in the harness

Harness evidence: every stage green on fresh installs across runs; the last run (vm:e2e:quick on 57fb558) passed vm:check, vm:watchdog-check and vm:reboot-check. c6ba316 (fingerprint) gets its harness proof on the next fresh vm:e2e.

Follow-ups: #22 (flux-operator, blocks #14), #23 (hand-made harbor-config-openbao, state hygiene), #14 comment (hostname vs node-name call sites).

Done 2026-11-11, on main (38d405a..c6ba316). Fleet hosts evaluate unchanged; c1 switches on at #14. - `cluster.pki.fromOpenbao`: the agent renders CAs, service.key and the token from KV `infra/k3s/<c>` (agents only `/join`); k3s seeds `server/tls` before its first start only. - `cluster.zone` (cluster-domain plus `<host>.<zone>` node names), `cluster.clusterInit`, read-only `k3s.nodeName` used by deploy-health/node-health. - Rotation: `pki-cluster-ca.sh --rotate` + `scripts/k3s-rotate-ca.sh`, docs/k3s-ca-rotation.md, rehearsed by `vm:rotate-check` (a pre-rotation service-account token still works). - `cluster.registryMirror`: Harbor pull-through from KV `infra/harbor/node-pull` (written by the harbor root, lab/iac #59/#60); registries.yaml is in the k3s fingerprint. - c1 CA set re-minted with the complete constraint list (k3s needs `kubernetes.default(.svc)`, `kine.sock` and each bare hostname). A new node means a domains edit plus rotation. Done-when: - [x] fresh harness cluster starts on OpenBao-issued CAs (vm:check: seeded set in use, token pin, all 6 ports and kubectl verify to the root only, Go verifies every leaf) - [x] `k3s certificate check` chains to the lab root - [x] CA rotation rehearsed in the harness Harness evidence: every stage green on fresh installs across runs; the last run (vm:e2e:quick on 57fb558) passed vm:check, vm:watchdog-check and vm:reboot-check. c6ba316 (fingerprint) gets its harness proof on the next fresh vm:e2e. Follow-ups: #22 (flux-operator, blocks #14), #23 (hand-made harbor-config-openbao, state hygiene), #14 comment (hostname vs node-name call sites).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/machine-configs#11
No description provided.