Browse Source

Merge pull request #923 from AkihiroSuda/fix-rootless-kubelet-flags

rootless: add kubelet flags automatically
pull/958/head
Erik Wilson 5 years ago committed by GitHub
parent
commit
f648a64ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      pkg/agent/config/config.go
  2. 2
      pkg/agent/run.go
  3. 1
      pkg/cli/cmds/agent.go
  4. 5
      pkg/cli/server/server.go
  5. 8
      pkg/daemons/agent/agent.go
  6. 1
      pkg/daemons/config/types.go

4
pkg/agent/config/config.go

@ -348,6 +348,9 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
nodeConfig.AgentConfig.KubeConfigNode = kubeconfigNode
nodeConfig.AgentConfig.KubeConfigKubelet = kubeconfigKubelet
nodeConfig.AgentConfig.KubeConfigKubeProxy = kubeconfigKubeproxy
if envInfo.Rootless {
nodeConfig.AgentConfig.RootDir = filepath.Join(envInfo.DataDir, "kubelet")
}
nodeConfig.AgentConfig.PauseImage = envInfo.PauseImage
nodeConfig.AgentConfig.IPSECPSK = controlConfig.IPSECPSK
nodeConfig.AgentConfig.StrongSwanDir = filepath.Join(envInfo.DataDir, "strongswan")
@ -400,6 +403,7 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
nodeConfig.AgentConfig.PrivateRegistry = envInfo.PrivateRegistry
nodeConfig.AgentConfig.DisableCCM = controlConfig.DisableCCM
nodeConfig.AgentConfig.DisableNPC = controlConfig.DisableNPC
nodeConfig.AgentConfig.Rootless = envInfo.Rootless
return nodeConfig, nil
}

2
pkg/agent/run.go

@ -91,7 +91,7 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
return err
}
if cfg.Rootless {
if cfg.Rootless && !cfg.RootlessAlreadyUnshared {
if err := rootless.Rootless(cfg.DataDir); err != nil {
return err
}

1
pkg/cli/cmds/agent.go

@ -26,6 +26,7 @@ type Agent struct {
FlannelConf string
Debug bool
Rootless bool
RootlessAlreadyUnshared bool
AgentShared
ExtraKubeletArgs cli.StringSlice
ExtraKubeProxyArgs cli.StringSlice

5
pkg/cli/server/server.go

@ -187,6 +187,11 @@ func run(app *cli.Context, cfg *cmds.Server) error {
agentConfig.ServerURL = url
agentConfig.Token = token
agentConfig.DisableLoadBalancer = true
agentConfig.Rootless = cfg.Rootless
if agentConfig.Rootless {
// let agent specify Rootless kubelet flags, but not unshare twice
agentConfig.RootlessAlreadyUnshared = true
}
return agent.Run(ctx, agentConfig)
}

8
pkg/daemons/agent/agent.go

@ -137,6 +137,14 @@ func kubelet(cfg *config.Agent) {
argsMap["cloud-provider"] = "external"
}
if cfg.Rootless {
// flags are from https://github.com/rootless-containers/usernetes/blob/v20190826.0/boot/kubelet.sh
argsMap["cgroup-driver"] = "none"
argsMap["feature-gates=SupportNoneCgroupDriver"] = "true"
argsMap["cgroups-per-qos"] = "false"
argsMap["enforce-node-allocatable"] = ""
}
args := config.GetArgsList(argsMap, cfg.ExtraKubeletArgs)
command.SetArgs(args)

1
pkg/daemons/config/types.go

@ -80,6 +80,7 @@ type Agent struct {
PrivateRegistry string
DisableCCM bool
DisableNPC bool
Rootless bool
}
type Control struct {

Loading…
Cancel
Save