mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
Merge pull request #90949 from pjbgf/seccomp-least-priv-kuberuntime
Add seccomp least privilege for kuberuntime
This commit is contained in:
commit
428b500c5a
@ -148,8 +148,11 @@ func (m *kubeGenericRuntimeManager) generatePodSandboxLinuxConfig(pod *v1.Pod) (
|
|||||||
lc := &runtimeapi.LinuxPodSandboxConfig{
|
lc := &runtimeapi.LinuxPodSandboxConfig{
|
||||||
CgroupParent: cgroupParent,
|
CgroupParent: cgroupParent,
|
||||||
SecurityContext: &runtimeapi.LinuxSandboxSecurityContext{
|
SecurityContext: &runtimeapi.LinuxSandboxSecurityContext{
|
||||||
Privileged: kubecontainer.HasPrivilegedContainer(pod),
|
Privileged: kubecontainer.HasPrivilegedContainer(pod),
|
||||||
SeccompProfilePath: m.getSeccompProfile(pod.Annotations, "", pod.Spec.SecurityContext, nil),
|
|
||||||
|
// Forcing sandbox to run as `runtime/default` allow users to
|
||||||
|
// use least privileged seccomp profiles at pod level. Issue #84623
|
||||||
|
SeccompProfilePath: v1.SeccompProfileRuntimeDefault,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,37 +67,29 @@ func TestGeneratePodSandboxLinuxConfigSeccomp(t *testing.T) {
|
|||||||
expectedProfile string
|
expectedProfile string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
description: "no seccomp defined at pod level should return empty",
|
description: "no seccomp defined at pod level should return runtime/default",
|
||||||
pod: newSeccompPod(nil, nil, "", ""),
|
pod: newSeccompPod(nil, nil, "", "runtime/default"),
|
||||||
expectedProfile: "",
|
expectedProfile: "runtime/default",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "seccomp field defined at pod level should be honoured",
|
description: "seccomp field defined at pod level should not be honoured",
|
||||||
pod: newSeccompPod(&v1.SeccompProfile{Type: v1.SeccompProfileTypeRuntimeDefault}, nil, "", ""),
|
pod: newSeccompPod(&v1.SeccompProfile{Type: v1.SeccompProfileTypeUnconfined}, nil, "", ""),
|
||||||
expectedProfile: "runtime/default",
|
expectedProfile: "runtime/default",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "seccomp field defined at container level should not be honoured",
|
description: "seccomp field defined at container level should not be honoured",
|
||||||
pod: newSeccompPod(nil, &v1.SeccompProfile{Type: v1.SeccompProfileTypeRuntimeDefault}, "", ""),
|
pod: newSeccompPod(nil, &v1.SeccompProfile{Type: v1.SeccompProfileTypeUnconfined}, "", ""),
|
||||||
expectedProfile: "",
|
expectedProfile: "runtime/default",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "seccomp annotation defined at pod level should be honoured",
|
description: "seccomp annotation defined at pod level should not be honoured",
|
||||||
pod: newSeccompPod(nil, nil, v1.SeccompProfileRuntimeDefault, ""),
|
pod: newSeccompPod(nil, nil, "unconfined", ""),
|
||||||
expectedProfile: "runtime/default",
|
expectedProfile: "runtime/default",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "seccomp annotation defined at container level should not be honoured",
|
description: "seccomp annotation defined at container level should not be honoured",
|
||||||
pod: newSeccompPod(nil, nil, "", v1.SeccompProfileRuntimeDefault),
|
pod: newSeccompPod(nil, nil, "", "unconfined"),
|
||||||
expectedProfile: "",
|
expectedProfile: "runtime/default",
|
||||||
},
|
|
||||||
{
|
|
||||||
description: "prioritise pod field over pod annotation",
|
|
||||||
pod: newSeccompPod(&v1.SeccompProfile{
|
|
||||||
Type: v1.SeccompProfileTypeLocalhost,
|
|
||||||
LocalhostProfile: pointer.StringPtr("pod-field"),
|
|
||||||
}, nil, "localhost/pod-annotation", ""),
|
|
||||||
expectedProfile: "localhost/" + filepath.Join(fakeSeccompProfileRoot, "pod-field"),
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user