Browse Source

Add nonroot-devices flag to agent CLI

Add new flag that is passed through to the device_ownership_from_security_context parameter in the containerd CRI config. This is not possible to change without providing a complete custom containerd.toml template so we should add a flag for it.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/11236/head
Brad Davidson 3 weeks ago committed by Brad Davidson
parent
commit
56fb3b0991
  1. 1
      pkg/agent/config/config.go
  2. 1
      pkg/agent/containerd/config_linux.go
  3. 1
      pkg/agent/templates/templates.go
  4. 1
      pkg/agent/templates/templates_linux.go
  5. 7
      pkg/cli/cmds/agent.go
  6. 1
      pkg/cli/cmds/server.go
  7. 27
      pkg/daemons/config/types.go

1
pkg/agent/config/config.go

@ -603,6 +603,7 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
nodeConfig.Containerd.Log = filepath.Join(envInfo.DataDir, "agent", "containerd", "containerd.log")
nodeConfig.Containerd.Registry = filepath.Join(envInfo.DataDir, "agent", "etc", "containerd", "certs.d")
nodeConfig.Containerd.NoDefault = envInfo.ContainerdNoDefault
nodeConfig.Containerd.NonrootDevices = envInfo.ContainerdNonrootDevices
nodeConfig.Containerd.Debug = envInfo.Debug
applyContainerdStateAndAddress(nodeConfig)
applyCRIDockerdAddress(nodeConfig)

1
pkg/agent/containerd/config_linux.go

@ -73,6 +73,7 @@ func SetupContainerdConfig(cfg *config.Node) error {
SystemdCgroup: cfg.AgentConfig.Systemd,
IsRunningInUserNS: isRunningInUserNS,
EnableUnprivileged: kernel.CheckKernelVersion(4, 11, 0),
NonrootDevices: cfg.Containerd.NonrootDevices,
PrivateRegistryConfig: cfg.AgentConfig.Registry,
ExtraRuntimes: extraRuntimes,
Program: version.Program,

1
pkg/agent/templates/templates.go

@ -23,6 +23,7 @@ type ContainerdConfig struct {
IsRunningInUserNS bool
EnableUnprivileged bool
NoDefaultEndpoint bool
NonrootDevices bool
PrivateRegistryConfig *registries.Registry
ExtraRuntimes map[string]ContainerdRuntimeConfig
Program string

1
pkg/agent/templates/templates_linux.go

@ -19,6 +19,7 @@ version = 2
enable_selinux = {{ .NodeConfig.SELinux }}
enable_unprivileged_ports = {{ .EnableUnprivileged }}
enable_unprivileged_icmp = {{ .EnableUnprivileged }}
device_ownership_from_security_context = {{ .NonrootDevices }}
{{- if .DisableCgroup}}
disable_cgroup = true

7
pkg/cli/cmds/agent.go

@ -30,6 +30,7 @@ type Agent struct {
Snapshotter string
Docker bool
ContainerdNoDefault bool
ContainerdNonrootDevices bool
ContainerRuntimeEndpoint string
DefaultRuntime string
ImageServiceEndpoint string
@ -240,6 +241,11 @@ var (
Usage: "(agent/containerd) Disables containerd's fallback default registry endpoint when a mirror is configured for that registry",
Destination: &AgentConfig.ContainerdNoDefault,
}
NonrootDevicesFlag = &cli.BoolFlag{
Name: "nonroot-devices",
Usage: "(agent/containerd) Allows non-root pods to access devices by setting device_ownership_from_security_context=true in the containerd CRI config",
Destination: &AgentConfig.ContainerdNonrootDevices,
}
EnablePProfFlag = &cli.BoolFlag{
Name: "enable-pprof",
Usage: "(experimental) Enable pprof endpoint on supervisor port",
@ -303,6 +309,7 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
SnapshotterFlag,
PrivateRegistryFlag,
DisableDefaultRegistryEndpointFlag,
NonrootDevicesFlag,
AirgapExtraRegistryFlag,
NodeIPFlag,
BindAddressFlag,

1
pkg/cli/cmds/server.go

@ -527,6 +527,7 @@ var ServerFlags = []cli.Flag{
DefaultRuntimeFlag,
ImageServiceEndpointFlag,
DisableDefaultRegistryEndpointFlag,
NonrootDevicesFlag,
PauseImageFlag,
SnapshotterFlag,
PrivateRegistryFlag,

27
pkg/daemons/config/types.go

@ -78,19 +78,20 @@ type EtcdS3 struct {
}
type Containerd struct {
Address string
Log string
Root string
State string
Config string
Opt string
Template string
BlockIOConfig string
RDTConfig string
Registry string
NoDefault bool
SELinux bool
Debug bool
Address string
Log string
Root string
State string
Config string
Opt string
Template string
BlockIOConfig string
RDTConfig string
Registry string
NoDefault bool
NonrootDevices bool
SELinux bool
Debug bool
}
type CRIDockerd struct {

Loading…
Cancel
Save