mirror of
https://github.com/dsx-ai-factory/nvke.git
synced 2026-12-07 04:35:58 +08:00
Scan the clusters the CAPD and bootstrap e2e lanes build with kube-bench, and fail the lane on any FAIL or WARN the exception register does not cover, or on an entry for a check kube-bench does not report. The scan runs the kube-bench v0.16.0 image as published, with cis-1.12, the newest benchmark it ships. The release maps no Kubernetes version after 1.34, so the scan names the benchmark rather than rely on kube-bench falling back to it. A scan runs the policies checks first and alone, in a pod that takes nothing from the host but the admin kubeconfig and runs as a service account that mounts no token, so section 5 does not report the scan itself. It then runs one pod per node, reads each report from its log, and deletes everything it created. A policies report whose audits returned no rows is an error, not a list of findings. NVKE now sets kube-controller-manager's --terminated-pod-gc-threshold to 12500, Kubernetes' own default, on every cluster it creates. The scan's check 1.3.1 looks for the flag; setting the default explicitly satisfies it without changing how many finished pods a cluster keeps. Existing clusters keep the configuration they were created with. Like the other flags NVKE sets, a cluster-create request cannot override it through extraArgs. The register, exceptions.yaml, lists each accepted check by ID, with a title and a reason in our own words. An entry applies on every node of every cluster. One whose check passed on every node is listed as unneeded, since the other kind of cluster may still need it. The CAPD lane scans "CAPD core" on pull requests and "CAPD with etcd encryption" on full runs, once their nodes are ready, and copies the results out with its diagnostics, as the local entrypoint runner now does too. Both create encrypted clusters, so the scan checks the encryption configuration NVKE renders; CAPD core now creates one. The bootstrap lane scans the site cluster in stage 4d of run.sh; a scan that failed or never reached a verdict fails the run after the teardown, and the workflow uploads the results on every provisioned run. The substrate now mounts its etcd tmpfs with mode 0700, the mode kubeadm gives the directory it creates, instead of tmpfs's default 1777. The CAPD node image, which the bootstrap image builds on, now creates the etcd user and, at every boot, gives it /var/lib/etcd, as the production node image does; the node containers mount a root-owned tmpfs there. The scan pods mount each host's /etc/passwd and /etc/group, so kube-bench names the directory's owner as the host does: its own image has no etcd user and reported UNKNOWN:UNKNOWN. Check 1.1.12 then passes on the CI clusters and on production nodes. Signed-off-by: Abhay Krishna Arunachalam <abhaykrishna@nvidia.com>
18 lines
707 B
Desktop File
18 lines
707 B
Desktop File
# Own the etcd data directory as etcd:etcd, as the production node image does
|
|
# (os-image/packer/scripts/provision.sh, CIS 1.1.12). Node containers mount a
|
|
# tmpfs at /var/lib/etcd, which starts out root-owned on every boot, so the
|
|
# owner is set here, before `nvke-agent` can run kubeadm. kubeadm reuses an
|
|
# existing data directory and leaves its owner alone. etcd runs as root in its
|
|
# static pod either way, so this changes what the node reports, not what etcd
|
|
# can do.
|
|
[Unit]
|
|
Description=Own the etcd data directory as etcd:etcd
|
|
Before=kubelet.service nvke-agent.service
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=/usr/bin/install -d -m 0700 -o etcd -g etcd /var/lib/etcd
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|