This repository was archived by the owner on Feb 23, 2026. It is now read-only.
forked from containerd/cri
-
Notifications
You must be signed in to change notification settings - Fork 2
[1.3] Implement user namespaces #1
Draft
alban
wants to merge
14
commits into
release/1.3
Choose a base branch
from
alban/userns
base: release/1.3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1fc856f
Add new CRI API, GetRuntimeConfigInfo() and a new LinuxNamepsaceOptio…
alban 6b1955c
Implement GetRuntimeConfigInfo()
alban cb14152
Fix typo on RunPodSandbox
alban e4c50b8
Statically define a userns config
alban 2abe26c
Implement sandbox with user namespaces
alban 717f607
User namespaces: use the correct snapshotter
alban b4163dd
User namespaces: fix ownership of netns
alban 986c403
User namespace: restrict mount options for sandbox /dev/shm (tmpfs)
alban bc3308f
User namespaces: use the correct snapshotter
alban a5983e6
User namespaces: add SupplementaryGroups=0 in systemd units
alban 27aa195
User namespaces: make ID mapping configurable
alban 023ad1e
User namespaces: implement NamespaceMode NODE and POD
alban 53f33c2
Tests for user namespaces
alban 3a93079
Fixup move userns options together
alban File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| Copyright 2017-2020 The Kubernetes Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package server | ||
|
|
||
| import ( | ||
| "golang.org/x/net/context" | ||
|
|
||
| runtimespec "github.com/opencontainers/runtime-spec/specs-go" | ||
| runtime "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" | ||
| ) | ||
|
|
||
| var UsernsMapping = &runtimespec.LinuxIDMapping{ | ||
| ContainerID: uint32(0), | ||
| HostID: uint32(100000), | ||
| Size: uint32(65535), | ||
| } | ||
|
|
||
| func (c *criService) GetRuntimeConfigInfo(_ context.Context, r *runtime.GetRuntimeConfigInfoRequest) (res *runtime.GetRuntimeConfigInfoResponse, err error) { | ||
| // Mapping used when we just use the host user namespace | ||
| // See /proc/self/uid_map on the host | ||
| //hostMapping := &runtime.LinuxIDMapping{ | ||
| // ContainerId: uint32(0), | ||
| // HostId: uint32(0), | ||
| // Size_: uint32(4294967295), | ||
| //} | ||
|
|
||
| // Example of mapping we can use in containers | ||
| linuxConfig := &runtime.LinuxUserNamespaceConfig{ | ||
| UidMappings: []*runtime.LinuxIDMapping{ | ||
| &runtime.LinuxIDMapping{ | ||
| ContainerId: uint32(0), | ||
| HostId: uint32(100000), | ||
| Size_: uint32(65535), | ||
| }, | ||
| }, | ||
| GidMappings: []*runtime.LinuxIDMapping{ | ||
| &runtime.LinuxIDMapping{ | ||
| ContainerId: uint32(0), | ||
| HostId: uint32(100000), | ||
| Size_: uint32(65535), | ||
| }, | ||
| }, | ||
| } | ||
| activeRuntimeConfig := &runtime.ActiveRuntimeConfig{UserNamespaceConfig: linuxConfig} | ||
| return &runtime.GetRuntimeConfigInfoResponse{RuntimeConfig: activeRuntimeConfig}, nil | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.