kubelet: set user namespace options

Set the user namespace options to use for the pod.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
This commit is contained in:
Rodrigo Campos 2022-08-02 12:16:01 +02:00
parent 67b38ffe6e
commit 138e80819e

View File

@ -100,9 +100,15 @@ func PidNamespaceForPod(pod *v1.Pod) runtimeapi.NamespaceMode {
// namespacesForPod returns the runtimeapi.NamespaceOption for a given pod.
// An empty or nil pod can be used to get the namespace defaults for v1.Pod.
func NamespacesForPod(pod *v1.Pod, runtimeHelper kubecontainer.RuntimeHelper) (*runtimeapi.NamespaceOption, error) {
userNs, err := runtimeHelper.GetOrCreateUserNamespaceMappings(pod)
if err != nil {
return nil, err
}
return &runtimeapi.NamespaceOption{
Ipc: IpcNamespaceForPod(pod),
Network: NetworkNamespaceForPod(pod),
Pid: PidNamespaceForPod(pod),
Ipc: IpcNamespaceForPod(pod),
Network: NetworkNamespaceForPod(pod),
Pid: PidNamespaceForPod(pod),
UsernsOptions: userNs,
}, nil
}