fix: grant API the dedicated node-control socket group

This commit is contained in:
Lemon-miaow committed 2026-10-07 12:37:15 +08:00
1 parent 3327c13429
commit 1b49b4df06
2 files changed
+14

No files matched your search

+10
View File
@@ -75,8 +75,18 @@ func TestNodeControlSocketIsAPIOnly(t *testing.T) {
}
}
if d.Name != SAAPI {
if len(d.Spec.Template.Spec.SecurityContext.SupplementalGroups) != 0 {
t.Fatal("host socket group leaked to", d.Name)
}
continue
}
groups := d.Spec.Template.Spec.SecurityContext.SupplementalGroups
if len(groups) != 1 || groups[0] != 65532 {
t.Fatal("API lacks host socket group", groups)
}
if *d.Spec.Template.Spec.SecurityContext.RunAsUser != nonRootUID || *d.Spec.Template.Spec.SecurityContext.RunAsGroup != nonRootUID {
t.Fatal("API identity changed")
}
if d.Spec.Template.Spec.NodeSelector["kubernetes.io/hostname"] != "controller" {
t.Fatal("API can run away from socket")
}