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
18a0e80a
Commit
18a0e80a
authored
Jan 29, 2018
by
Lantao Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pod sandbox privilege.
Signed-off-by:
Lantao Liu
<
lantaol@google.com
>
parent
03b3d599
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
helpers.go
pkg/kubelet/container/helpers.go
+1
-1
helpers_test.go
pkg/kubelet/container/helpers_test.go
+14
-0
No files found.
pkg/kubelet/container/helpers.go
View file @
18a0e80a
...
...
@@ -302,7 +302,7 @@ func GetContainerSpec(pod *v1.Pod, containerName string) *v1.Container {
// HasPrivilegedContainer returns true if any of the containers in the pod are privileged.
func
HasPrivilegedContainer
(
pod
*
v1
.
Pod
)
bool
{
for
_
,
c
:=
range
pod
.
Spec
.
Containers
{
for
_
,
c
:=
range
append
(
pod
.
Spec
.
Containers
,
pod
.
Spec
.
InitContainers
...
)
{
if
c
.
SecurityContext
!=
nil
&&
c
.
SecurityContext
.
Privileged
!=
nil
&&
*
c
.
SecurityContext
.
Privileged
{
...
...
pkg/kubelet/container/helpers_test.go
View file @
18a0e80a
...
...
@@ -254,6 +254,20 @@ func TestHasPrivilegedContainer(t *testing.T) {
t
.
Errorf
(
"%s expected %t but got %t"
,
k
,
v
.
expected
,
actual
)
}
}
// Test init containers as well.
for
k
,
v
:=
range
tests
{
pod
:=
&
v1
.
Pod
{
Spec
:
v1
.
PodSpec
{
InitContainers
:
[]
v1
.
Container
{
{
SecurityContext
:
v
.
securityContext
},
},
},
}
actual
:=
HasPrivilegedContainer
(
pod
)
if
actual
!=
v
.
expected
{
t
.
Errorf
(
"%s expected %t but got %t"
,
k
,
v
.
expected
,
actual
)
}
}
}
func
TestMakePortMappings
(
t
*
testing
.
T
)
{
...
...
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