Skip to content

Commit

Permalink
kubelet: set user namespace options
Browse files Browse the repository at this point in the history
Set the user namespace options to use for the pod.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
  • Loading branch information
rata committed Aug 3, 2022
1 parent 67b38ff commit 138e808
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/kubelet/kuberuntime/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 138e808

Please sign in to comment.