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
9c2309b7
Commit
9c2309b7
authored
May 25, 2017
by
Dong Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add os dependent getSecurityOpts helper method.
parent
33c34f0a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
5 deletions
+52
-5
docker_container.go
pkg/kubelet/dockershim/docker_container.go
+3
-4
docker_sandbox.go
pkg/kubelet/dockershim/docker_sandbox.go
+1
-1
helpers_linux.go
pkg/kubelet/dockershim/helpers_linux.go
+16
-0
helpers_unsupported.go
pkg/kubelet/dockershim/helpers_unsupported.go
+10
-0
helpers_windows.go
pkg/kubelet/dockershim/helpers_windows.go
+22
-0
No files found.
pkg/kubelet/dockershim/docker_container.go
View file @
9c2309b7
...
...
@@ -184,13 +184,12 @@ func (ds *dockerService) CreateContainer(podSandboxID string, config *runtimeapi
}
hc
.
Resources
.
Devices
=
devices
// Apply seccomp options.
seccompSecurityOpts
,
err
:=
getSeccompSecurityOpts
(
config
.
Metadata
.
Name
,
sandboxConfig
,
ds
.
seccompProfileRoot
,
securityOptSep
)
securityOpts
,
err
:=
ds
.
getSecurityOpts
(
config
.
Metadata
.
Name
,
sandboxConfig
,
securityOptSep
)
if
err
!=
nil
{
return
""
,
fmt
.
Errorf
(
"failed to generate sec
comp sec
urity options for container %q: %v"
,
config
.
Metadata
.
Name
,
err
)
return
""
,
fmt
.
Errorf
(
"failed to generate security options for container %q: %v"
,
config
.
Metadata
.
Name
,
err
)
}
hc
.
SecurityOpt
=
append
(
hc
.
SecurityOpt
,
seccompSecurityOpts
...
)
hc
.
SecurityOpt
=
append
(
hc
.
SecurityOpt
,
securityOpts
...
)
createConfig
.
HostConfig
=
hc
createResp
,
err
:=
ds
.
client
.
CreateContainer
(
createConfig
)
if
err
!=
nil
{
...
...
pkg/kubelet/dockershim/docker_sandbox.go
View file @
9c2309b7
...
...
@@ -537,7 +537,7 @@ func (ds *dockerService) makeSandboxDockerConfig(c *runtimeapi.PodSandboxConfig,
}
// Set security options.
securityOpts
,
err
:=
getSeccompSecurityOpts
(
sandboxContainerName
,
c
,
ds
.
seccompProfileRoot
,
securityOptSep
)
securityOpts
,
err
:=
ds
.
getSecurityOpts
(
sandboxContainerName
,
c
,
securityOptSep
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to generate sandbox security options for sandbox %q: %v"
,
c
.
Metadata
.
Name
,
err
)
}
...
...
pkg/kubelet/dockershim/helpers_linux.go
View file @
9c2309b7
...
...
@@ -18,6 +18,22 @@ limitations under the License.
package
dockershim
import
(
"fmt"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1"
)
func
DefaultMemorySwap
()
int64
{
return
0
}
func
(
ds
*
dockerService
)
getSecurityOpts
(
containerName
string
,
sandboxConfig
*
runtimeapi
.
PodSandboxConfig
,
separator
rune
)
([]
string
,
error
)
{
// Apply seccomp options.
seccompSecurityOpts
,
err
:=
getSeccompSecurityOpts
(
containerName
,
sandboxConfig
,
ds
.
seccompProfileRoot
,
separator
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to generate seccomp security options for container %q: %v"
,
containerName
,
err
)
}
return
seccompSecurityOpts
,
nil
}
pkg/kubelet/dockershim/helpers_unsupported.go
View file @
9c2309b7
...
...
@@ -18,6 +18,16 @@ limitations under the License.
package
dockershim
import
(
"github.com/golang/glog"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1"
)
func
DefaultMemorySwap
()
int64
{
return
-
1
}
func
(
ds
*
dockerService
)
getSecurityOpts
(
containerName
string
,
sandboxConfig
*
runtimeapi
.
PodSandboxConfig
,
separator
rune
)
([]
string
,
error
)
{
glog
.
Warningf
(
"getSecurityOpts is unsupported in this build"
)
return
nil
,
nil
}
pkg/kubelet/dockershim/helpers_windows.go
View file @
9c2309b7
...
...
@@ -18,6 +18,28 @@ limitations under the License.
package
dockershim
import
(
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/api/v1"
runtimeapi
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1"
)
func
DefaultMemorySwap
()
int64
{
return
0
}
func
(
ds
*
dockerService
)
getSecurityOpts
(
containerName
string
,
sandboxConfig
*
runtimeapi
.
PodSandboxConfig
,
separator
rune
)
([]
string
,
error
)
{
hasSeccompSetting
:=
false
annotations
:=
sandboxConfig
.
GetAnnotations
()
if
_
,
ok
:=
annotations
[
v1
.
SeccompContainerAnnotationKeyPrefix
+
containerName
];
!
ok
{
_
,
hasSeccompSetting
=
annotations
[
v1
.
SeccompPodAnnotationKey
]
}
else
{
hasSeccompSetting
=
true
}
if
hasSeccompSetting
{
glog
.
Warningf
(
"seccomp annotations found, but it is not supported on windows"
)
}
return
nil
,
nil
}
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