mirror of https://github.com/k3s-io/k3s
Merge pull request #923 from AkihiroSuda/fix-rootless-kubelet-flags
rootless: add kubelet flags automaticallypull/958/head
commit
f648a64ee3
|
@ -348,6 +348,9 @@ func get(envInfo *cmds.Agent) (*config.Node, error) {
|
||||||
nodeConfig.AgentConfig.KubeConfigNode = kubeconfigNode
|
nodeConfig.AgentConfig.KubeConfigNode = kubeconfigNode
|
||||||
nodeConfig.AgentConfig.KubeConfigKubelet = kubeconfigKubelet
|
nodeConfig.AgentConfig.KubeConfigKubelet = kubeconfigKubelet
|
||||||
nodeConfig.AgentConfig.KubeConfigKubeProxy = kubeconfigKubeproxy
|
nodeConfig.AgentConfig.KubeConfigKubeProxy = kubeconfigKubeproxy
|
||||||
|
if envInfo.Rootless {
|
||||||
|
nodeConfig.AgentConfig.RootDir = filepath.Join(envInfo.DataDir, "kubelet")
|
||||||
|
}
|
||||||
nodeConfig.AgentConfig.PauseImage = envInfo.PauseImage
|
nodeConfig.AgentConfig.PauseImage = envInfo.PauseImage
|
||||||
nodeConfig.AgentConfig.IPSECPSK = controlConfig.IPSECPSK
|
nodeConfig.AgentConfig.IPSECPSK = controlConfig.IPSECPSK
|
||||||
nodeConfig.AgentConfig.StrongSwanDir = filepath.Join(envInfo.DataDir, "strongswan")
|
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.PrivateRegistry = envInfo.PrivateRegistry
|
||||||
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
|
||||||
|
|
||||||
return nodeConfig, nil
|
return nodeConfig, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ func Run(ctx context.Context, cfg cmds.Agent) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.Rootless {
|
if cfg.Rootless && !cfg.RootlessAlreadyUnshared {
|
||||||
if err := rootless.Rootless(cfg.DataDir); err != nil {
|
if err := rootless.Rootless(cfg.DataDir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ type Agent struct {
|
||||||
FlannelConf string
|
FlannelConf string
|
||||||
Debug bool
|
Debug bool
|
||||||
Rootless bool
|
Rootless bool
|
||||||
|
RootlessAlreadyUnshared bool
|
||||||
AgentShared
|
AgentShared
|
||||||
ExtraKubeletArgs cli.StringSlice
|
ExtraKubeletArgs cli.StringSlice
|
||||||
ExtraKubeProxyArgs cli.StringSlice
|
ExtraKubeProxyArgs cli.StringSlice
|
||||||
|
|
|
@ -187,6 +187,11 @@ func run(app *cli.Context, cfg *cmds.Server) error {
|
||||||
agentConfig.ServerURL = url
|
agentConfig.ServerURL = url
|
||||||
agentConfig.Token = token
|
agentConfig.Token = token
|
||||||
agentConfig.DisableLoadBalancer = true
|
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)
|
return agent.Run(ctx, agentConfig)
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,14 @@ func kubelet(cfg *config.Agent) {
|
||||||
argsMap["cloud-provider"] = "external"
|
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)
|
args := config.GetArgsList(argsMap, cfg.ExtraKubeletArgs)
|
||||||
command.SetArgs(args)
|
command.SetArgs(args)
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,7 @@ type Agent struct {
|
||||||
PrivateRegistry string
|
PrivateRegistry string
|
||||||
DisableCCM bool
|
DisableCCM bool
|
||||||
DisableNPC bool
|
DisableNPC bool
|
||||||
|
Rootless bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Control struct {
|
type Control struct {
|
||||||
|
|
Loading…
Reference in New Issue