mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
rootless: add kubelet flags automatically
Fix https://github.com/rancher/k3s/issues/784 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
c998789ccb
commit
aafccdbccb
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ type Agent struct {
|
||||
FlannelConf string
|
||||
Debug bool
|
||||
Rootless bool
|
||||
RootlessAlreadyUnshared bool
|
||||
AgentShared
|
||||
ExtraKubeletArgs cli.StringSlice
|
||||
ExtraKubeProxyArgs cli.StringSlice
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -80,6 +80,7 @@ type Agent struct {
|
||||
PrivateRegistry string
|
||||
DisableCCM bool
|
||||
DisableNPC bool
|
||||
Rootless bool
|
||||
}
|
||||
|
||||
type Control struct {
|
||||
|
Loading…
Reference in New Issue
Block a user