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
87257985
Unverified
Commit
87257985
authored
Feb 28, 2020
by
Erik Wilson
Committed by
GitHub
Feb 28, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1464 from erikwilson/selinux-update
Simplify SELinux detection and add --disable-selinux flag
parents
2abd8a51
a3cb9ee1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
7 deletions
+29
-7
config.go
pkg/agent/config/config.go
+2
-0
containerd.go
pkg/agent/containerd/containerd.go
+12
-2
selinux.go
pkg/agent/containerd/selinux.go
+5
-5
agent.go
pkg/cli/cmds/agent.go
+8
-0
server.go
pkg/cli/cmds/server.go
+1
-0
types.go
pkg/daemons/config/types.go
+1
-0
No files found.
pkg/agent/config/config.go
View file @
87257985
...
@@ -397,6 +397,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
...
@@ -397,6 +397,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
nodeConfig
:=
&
config
.
Node
{
nodeConfig
:=
&
config
.
Node
{
Docker
:
envInfo
.
Docker
,
Docker
:
envInfo
.
Docker
,
DisableSELinux
:
envInfo
.
DisableSELinux
,
ContainerRuntimeEndpoint
:
envInfo
.
ContainerRuntimeEndpoint
,
ContainerRuntimeEndpoint
:
envInfo
.
ContainerRuntimeEndpoint
,
FlannelBackend
:
controlConfig
.
FlannelBackend
,
FlannelBackend
:
controlConfig
.
FlannelBackend
,
}
}
...
@@ -474,6 +475,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
...
@@ -474,6 +475,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
nodeConfig
.
AgentConfig
.
DisableCCM
=
controlConfig
.
DisableCCM
nodeConfig
.
AgentConfig
.
DisableCCM
=
controlConfig
.
DisableCCM
nodeConfig
.
AgentConfig
.
DisableNPC
=
controlConfig
.
DisableNPC
nodeConfig
.
AgentConfig
.
DisableNPC
=
controlConfig
.
DisableNPC
nodeConfig
.
AgentConfig
.
Rootless
=
envInfo
.
Rootless
nodeConfig
.
AgentConfig
.
Rootless
=
envInfo
.
Rootless
nodeConfig
.
DisableSELinux
=
envInfo
.
DisableSELinux
return
nodeConfig
,
nil
return
nodeConfig
,
nil
}
}
...
...
pkg/agent/containerd/containerd.go
View file @
87257985
...
@@ -168,11 +168,21 @@ func setupContainerdConfig(ctx context.Context, cfg *config.Node) error {
...
@@ -168,11 +168,21 @@ func setupContainerdConfig(ctx context.Context, cfg *config.Node) error {
PrivateRegistryConfig
:
privRegistries
,
PrivateRegistryConfig
:
privRegistries
,
}
}
sel
inux
,
err
:=
selinuxEnabled
()
sel
Enabled
,
selConfigured
,
err
:=
selinuxStatus
()
if
err
!=
nil
{
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to detect selinux"
)
return
errors
.
Wrap
(
err
,
"failed to detect selinux"
)
}
}
containerdConfig
.
SELinuxEnabled
=
selinux
if
cfg
.
DisableSELinux
{
containerdConfig
.
SELinuxEnabled
=
false
if
selEnabled
{
logrus
.
Warn
(
"SELinux is enabled for system but has been disabled for containerd by override"
)
}
}
else
{
containerdConfig
.
SELinuxEnabled
=
selEnabled
}
if
containerdConfig
.
SELinuxEnabled
&&
!
selConfigured
{
logrus
.
Warnf
(
"SELinux is enabled for k3s but process is not running in context '%s', k3s-selinux policy may need to be applied"
,
SELinuxContextType
)
}
containerdTemplateBytes
,
err
:=
ioutil
.
ReadFile
(
cfg
.
Containerd
.
Template
)
containerdTemplateBytes
,
err
:=
ioutil
.
ReadFile
(
cfg
.
Containerd
.
Template
)
if
err
==
nil
{
if
err
==
nil
{
...
...
pkg/agent/containerd/selinux.go
View file @
87257985
...
@@ -8,20 +8,20 @@ const (
...
@@ -8,20 +8,20 @@ const (
SELinuxContextType
=
"container_runtime_t"
SELinuxContextType
=
"container_runtime_t"
)
)
func
selinux
Enabled
()
(
bool
,
error
)
{
func
selinux
Status
()
(
bool
,
bool
,
error
)
{
if
!
selinux
.
GetEnabled
()
{
if
!
selinux
.
GetEnabled
()
{
return
false
,
nil
return
false
,
false
,
nil
}
}
label
,
err
:=
selinux
.
CurrentLabel
()
label
,
err
:=
selinux
.
CurrentLabel
()
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
true
,
false
,
err
}
}
ctx
,
err
:=
selinux
.
NewContext
(
label
)
ctx
,
err
:=
selinux
.
NewContext
(
label
)
if
err
!=
nil
{
if
err
!=
nil
{
return
false
,
err
return
true
,
false
,
err
}
}
return
ctx
[
"type"
]
==
SELinuxContextType
,
nil
return
true
,
ctx
[
"type"
]
==
SELinuxContextType
,
nil
}
}
pkg/cli/cmds/agent.go
View file @
87257985
...
@@ -28,6 +28,7 @@ type Agent struct {
...
@@ -28,6 +28,7 @@ type Agent struct {
Rootless
bool
Rootless
bool
RootlessAlreadyUnshared
bool
RootlessAlreadyUnshared
bool
WithNodeID
bool
WithNodeID
bool
DisableSELinux
bool
AgentShared
AgentShared
ExtraKubeletArgs
cli
.
StringSlice
ExtraKubeletArgs
cli
.
StringSlice
ExtraKubeProxyArgs
cli
.
StringSlice
ExtraKubeProxyArgs
cli
.
StringSlice
...
@@ -127,6 +128,12 @@ var (
...
@@ -127,6 +128,12 @@ var (
Usage
:
"(agent/node) Registering and starting kubelet with set of labels"
,
Usage
:
"(agent/node) Registering and starting kubelet with set of labels"
,
Value
:
&
AgentConfig
.
Labels
,
Value
:
&
AgentConfig
.
Labels
,
}
}
DisableSELinuxFlag
=
cli
.
BoolFlag
{
Name
:
"disable-selinux"
,
Usage
:
"(agent/node) Disable SELinux in containerd if currently enabled"
,
Hidden
:
true
,
Destination
:
&
AgentConfig
.
DisableSELinux
,
}
)
)
func
NewAgentCommand
(
action
func
(
ctx
*
cli
.
Context
)
error
)
cli
.
Command
{
func
NewAgentCommand
(
action
func
(
ctx
*
cli
.
Context
)
error
)
cli
.
Command
{
...
@@ -169,6 +176,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
...
@@ -169,6 +176,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
NodeLabels
,
NodeLabels
,
NodeTaints
,
NodeTaints
,
DockerFlag
,
DockerFlag
,
DisableSELinuxFlag
,
CRIEndpointFlag
,
CRIEndpointFlag
,
PauseImageFlag
,
PauseImageFlag
,
PrivateRegistryFlag
,
PrivateRegistryFlag
,
...
...
pkg/cli/cmds/server.go
View file @
87257985
...
@@ -216,6 +216,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
...
@@ -216,6 +216,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
NodeLabels
,
NodeLabels
,
NodeTaints
,
NodeTaints
,
DockerFlag
,
DockerFlag
,
DisableSELinuxFlag
,
CRIEndpointFlag
,
CRIEndpointFlag
,
PauseImageFlag
,
PauseImageFlag
,
PrivateRegistryFlag
,
PrivateRegistryFlag
,
...
...
pkg/daemons/config/types.go
View file @
87257985
...
@@ -25,6 +25,7 @@ type Node struct {
...
@@ -25,6 +25,7 @@ type Node struct {
Docker
bool
Docker
bool
ContainerRuntimeEndpoint
string
ContainerRuntimeEndpoint
string
NoFlannel
bool
NoFlannel
bool
DisableSELinux
bool
FlannelBackend
string
FlannelBackend
string
FlannelConf
string
FlannelConf
string
FlannelConfOverride
bool
FlannelConfOverride
bool
...
...
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