Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b9e8a8a6
Commit
b9e8a8a6
authored
Feb 08, 2018
by
Lee Verberne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set shared PID namespace mode based on PodSpec
parent
f3314347
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
2 deletions
+74
-2
helpers.go
pkg/kubelet/kuberuntime/helpers.go
+5
-1
helpers_test.go
pkg/kubelet/kuberuntime/helpers_test.go
+69
-1
No files found.
pkg/kubelet/kuberuntime/helpers.go
View file @
b9e8a8a6
...
...
@@ -25,7 +25,9 @@ import (
"github.com/golang/glog"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
v1helper
"k8s.io/kubernetes/pkg/apis/core/v1/helper"
"k8s.io/kubernetes/pkg/features"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
)
...
...
@@ -298,7 +300,9 @@ func pidNamespaceForPod(pod *v1.Pod) runtimeapi.NamespaceMode {
if
pod
.
Spec
.
HostPID
{
return
runtimeapi
.
NamespaceMode_NODE
}
// TODO(verb): set NamespaceMode_POD based on ShareProcessNamespace after #58716 is merged
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
PodShareProcessNamespace
)
&&
pod
.
Spec
.
ShareProcessNamespace
!=
nil
&&
*
pod
.
Spec
.
ShareProcessNamespace
{
return
runtimeapi
.
NamespaceMode_POD
}
}
// Note that PID does not default to the zero value for v1.Pod
return
runtimeapi
.
NamespaceMode_CONTAINER
...
...
pkg/kubelet/kuberuntime/helpers_test.go
View file @
b9e8a8a6
...
...
@@ -346,7 +346,75 @@ func TestNamespacesForPod(t *testing.T) {
Pid
:
runtimeapi
.
NamespaceMode_NODE
,
},
},
// TODO(verb): add test cases for ShareProcessNamespace true (after #58716 is merged)
"Shared Process Namespace (feature enabled)"
:
{
&
v1
.
Pod
{
Spec
:
v1
.
PodSpec
{
ShareProcessNamespace
:
&
[]
bool
{
true
}[
0
],
},
},
&
runtimeapi
.
NamespaceOption
{
Ipc
:
runtimeapi
.
NamespaceMode_POD
,
Network
:
runtimeapi
.
NamespaceMode_POD
,
Pid
:
runtimeapi
.
NamespaceMode_POD
,
},
},
"Shared Process Namespace, redundant flag (feature enabled)"
:
{
&
v1
.
Pod
{
Spec
:
v1
.
PodSpec
{
ShareProcessNamespace
:
&
[]
bool
{
false
}[
0
],
},
},
&
runtimeapi
.
NamespaceOption
{
Ipc
:
runtimeapi
.
NamespaceMode_POD
,
Network
:
runtimeapi
.
NamespaceMode_POD
,
Pid
:
runtimeapi
.
NamespaceMode_CONTAINER
,
},
},
}
{
t
.
Logf
(
"TestCase: %s"
,
desc
)
actual
:=
namespacesForPod
(
test
.
input
)
assert
.
Equal
(
t
,
test
.
expected
,
actual
)
}
// Test ShareProcessNamespace feature disabled, feature gate restored by previous defer
utilfeaturetesting
.
SetFeatureGateDuringTest
(
t
,
utilfeature
.
DefaultFeatureGate
,
features
.
PodShareProcessNamespace
,
false
)
for
desc
,
test
:=
range
map
[
string
]
struct
{
input
*
v1
.
Pod
expected
*
runtimeapi
.
NamespaceOption
}{
"v1.Pod default namespaces"
:
{
&
v1
.
Pod
{},
&
runtimeapi
.
NamespaceOption
{
Ipc
:
runtimeapi
.
NamespaceMode_POD
,
Network
:
runtimeapi
.
NamespaceMode_POD
,
Pid
:
runtimeapi
.
NamespaceMode_CONTAINER
,
},
},
"Shared Process Namespace (feature disabled)"
:
{
&
v1
.
Pod
{
Spec
:
v1
.
PodSpec
{
ShareProcessNamespace
:
&
[]
bool
{
true
}[
0
],
},
},
&
runtimeapi
.
NamespaceOption
{
Ipc
:
runtimeapi
.
NamespaceMode_POD
,
Network
:
runtimeapi
.
NamespaceMode_POD
,
Pid
:
runtimeapi
.
NamespaceMode_CONTAINER
,
},
},
"Shared Process Namespace, redundant flag (feature disabled)"
:
{
&
v1
.
Pod
{
Spec
:
v1
.
PodSpec
{
ShareProcessNamespace
:
&
[]
bool
{
false
}[
0
],
},
},
&
runtimeapi
.
NamespaceOption
{
Ipc
:
runtimeapi
.
NamespaceMode_POD
,
Network
:
runtimeapi
.
NamespaceMode_POD
,
Pid
:
runtimeapi
.
NamespaceMode_CONTAINER
,
},
},
}
{
t
.
Logf
(
"TestCase: %s"
,
desc
)
actual
:=
namespacesForPod
(
test
.
input
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment