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
b02f1f2c
Commit
b02f1f2c
authored
Feb 28, 2018
by
Lee Verberne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add node-e2e test for ShareProcessNamespace
parent
e99ec245
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
41 deletions
+75
-41
BUILD
test/e2e_node/BUILD
+1
-0
docker_test.go
test/e2e_node/docker_test.go
+0
-40
security_context_test.go
test/e2e_node/security_context_test.go
+74
-0
kubelet.go
test/e2e_node/services/kubelet.go
+0
-1
No files found.
test/e2e_node/BUILD
View file @
b02f1f2c
...
@@ -166,6 +166,7 @@ go_test(
...
@@ -166,6 +166,7 @@ go_test(
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
] + select({
] + select({
"@io_bazel_rules_go//go/platform:linux": [
"@io_bazel_rules_go//go/platform:linux": [
...
...
test/e2e_node/docker_test.go
View file @
b02f1f2c
...
@@ -37,46 +37,6 @@ var _ = framework.KubeDescribe("Docker features [Feature:Docker]", func() {
...
@@ -37,46 +37,6 @@ var _ = framework.KubeDescribe("Docker features [Feature:Docker]", func() {
framework
.
RunIfContainerRuntimeIs
(
"docker"
)
framework
.
RunIfContainerRuntimeIs
(
"docker"
)
})
})
Context
(
"when shared PID namespace is enabled"
,
func
()
{
It
(
"processes in different containers of the same pod should be able to see each other"
,
func
()
{
// TODO(yguo0905): Change this test to run unless the runtime is
// Docker and its version is <1.13.
By
(
"Check whether shared PID namespace is supported."
)
isEnabled
,
err
:=
isSharedPIDNamespaceSupported
()
framework
.
ExpectNoError
(
err
)
if
!
isEnabled
{
framework
.
Skipf
(
"Skipped because shared PID namespace is not supported by this docker version."
)
}
By
(
"Create a pod with two containers."
)
f
.
PodClient
()
.
CreateSync
(
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"shared-pid-ns-test-pod"
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Name
:
"test-container-1"
,
Image
:
"busybox"
,
Command
:
[]
string
{
"/bin/top"
},
},
{
Name
:
"test-container-2"
,
Image
:
"busybox"
,
Command
:
[]
string
{
"/bin/sleep"
},
Args
:
[]
string
{
"10000"
},
},
},
},
})
By
(
"Check if the process in one container is visible to the process in the other."
)
pid1
:=
f
.
ExecCommandInContainer
(
"shared-pid-ns-test-pod"
,
"test-container-1"
,
"/bin/pidof"
,
"top"
)
pid2
:=
f
.
ExecCommandInContainer
(
"shared-pid-ns-test-pod"
,
"test-container-2"
,
"/bin/pidof"
,
"top"
)
if
pid1
!=
pid2
{
framework
.
Failf
(
"PIDs are not the same in different containers: test-container-1=%v, test-container-2=%v"
,
pid1
,
pid2
)
}
})
})
Context
(
"when live-restore is enabled [Serial] [Slow] [Disruptive]"
,
func
()
{
Context
(
"when live-restore is enabled [Serial] [Slow] [Disruptive]"
,
func
()
{
It
(
"containers should not be disrupted when the daemon shuts down and restarts"
,
func
()
{
It
(
"containers should not be disrupted when the daemon shuts down and restarts"
,
func
()
{
const
(
const
(
...
...
test/e2e_node/security_context_test.go
View file @
b02f1f2c
...
@@ -26,6 +26,8 @@ import (
...
@@ -26,6 +26,8 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/apimachinery/pkg/util/uuid"
utilfeature
"k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/test/e2e/framework"
"k8s.io/kubernetes/test/e2e/framework"
.
"github.com/onsi/ginkgo"
.
"github.com/onsi/ginkgo"
...
@@ -39,6 +41,78 @@ var _ = framework.KubeDescribe("Security Context", func() {
...
@@ -39,6 +41,78 @@ var _ = framework.KubeDescribe("Security Context", func() {
podClient
=
f
.
PodClient
()
podClient
=
f
.
PodClient
()
})
})
Context
(
"when pod PID namespace is configurable [Feature:ShareProcessNamespace]"
,
func
()
{
It
(
"containers in pods using isolated PID namespaces should all receive PID 1"
,
func
()
{
By
(
"Create a pod with isolated PID namespaces."
)
f
.
PodClient
()
.
CreateSync
(
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"isolated-pid-ns-test-pod"
},
Spec
:
v1
.
PodSpec
{
Containers
:
[]
v1
.
Container
{
{
Name
:
"test-container-1"
,
Image
:
"busybox"
,
Command
:
[]
string
{
"/bin/top"
},
},
{
Name
:
"test-container-2"
,
Image
:
"busybox"
,
Command
:
[]
string
{
"/bin/sleep"
},
Args
:
[]
string
{
"10000"
},
},
},
},
})
By
(
"Check if both containers receive PID 1."
)
pid1
:=
f
.
ExecCommandInContainer
(
"isolated-pid-ns-test-pod"
,
"test-container-1"
,
"/bin/pidof"
,
"top"
)
pid2
:=
f
.
ExecCommandInContainer
(
"isolated-pid-ns-test-pod"
,
"test-container-2"
,
"/bin/pidof"
,
"sleep"
)
if
pid1
!=
"1"
||
pid2
!=
"1"
{
framework
.
Failf
(
"PIDs of different containers are not all 1: test-container-1=%v, test-container-2=%v"
,
pid1
,
pid2
)
}
})
It
(
"processes in containers sharing a pod namespace should be able to see each other [Alpha]"
,
func
()
{
By
(
"Check whether shared PID namespace is supported."
)
isEnabled
,
err
:=
isSharedPIDNamespaceSupported
()
framework
.
ExpectNoError
(
err
)
if
!
isEnabled
{
framework
.
Skipf
(
"Skipped because shared PID namespace is not supported by this docker version."
)
}
// It's not enough to set this flag in the kubelet because the apiserver needs it too
if
!
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
PodShareProcessNamespace
)
{
framework
.
Skipf
(
"run test with --feature-gates=PodShareProcessNamespace=true to test PID namespace sharing"
)
}
By
(
"Create a pod with shared PID namespace."
)
f
.
PodClient
()
.
CreateSync
(
&
v1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"shared-pid-ns-test-pod"
},
Spec
:
v1
.
PodSpec
{
ShareProcessNamespace
:
&
[]
bool
{
true
}[
0
],
Containers
:
[]
v1
.
Container
{
{
Name
:
"test-container-1"
,
Image
:
"busybox"
,
Command
:
[]
string
{
"/bin/top"
},
},
{
Name
:
"test-container-2"
,
Image
:
"busybox"
,
Command
:
[]
string
{
"/bin/sleep"
},
Args
:
[]
string
{
"10000"
},
},
},
},
})
By
(
"Check if the process in one container is visible to the process in the other."
)
pid1
:=
f
.
ExecCommandInContainer
(
"shared-pid-ns-test-pod"
,
"test-container-1"
,
"/bin/pidof"
,
"top"
)
pid2
:=
f
.
ExecCommandInContainer
(
"shared-pid-ns-test-pod"
,
"test-container-2"
,
"/bin/pidof"
,
"top"
)
if
pid1
!=
pid2
{
framework
.
Failf
(
"PIDs are not the same in different containers: test-container-1=%v, test-container-2=%v"
,
pid1
,
pid2
)
}
})
})
Context
(
"when creating a pod in the host PID namespace"
,
func
()
{
Context
(
"when creating a pod in the host PID namespace"
,
func
()
{
makeHostPidPod
:=
func
(
podName
,
image
string
,
command
[]
string
,
hostPID
bool
)
*
v1
.
Pod
{
makeHostPidPod
:=
func
(
podName
,
image
string
,
command
[]
string
,
hostPID
bool
)
*
v1
.
Pod
{
return
&
v1
.
Pod
{
return
&
v1
.
Pod
{
...
...
test/e2e_node/services/kubelet.go
View file @
b02f1f2c
...
@@ -258,7 +258,6 @@ func (e *E2EServices) startKubelet() (*server, error) {
...
@@ -258,7 +258,6 @@ func (e *E2EServices) startKubelet() (*server, error) {
cmdArgs
=
append
(
cmdArgs
,
cmdArgs
=
append
(
cmdArgs
,
"--kubeconfig"
,
kubeconfigPath
,
"--kubeconfig"
,
kubeconfigPath
,
"--root-dir"
,
KubeletRootDirectory
,
"--root-dir"
,
KubeletRootDirectory
,
"--docker-disable-shared-pid=false"
,
"--v"
,
LOG_VERBOSITY_LEVEL
,
"--logtostderr"
,
"--v"
,
LOG_VERBOSITY_LEVEL
,
"--logtostderr"
,
"--allow-privileged"
,
"true"
,
"--allow-privileged"
,
"true"
,
)
)
...
...
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