Updates to CLI flag grouping + deprecated flag warnings. (#5937)

* Consolidate data dir flag
* Group cluster flags together
* Reorder and group agent flags
* Add additional info around vmodule flag
* Hide deprecated flags, and add warning about their removal

Signed-off-by: Derek Nola <derek.nola@suse.com>
pull/5134/head
Derek Nola 2022-08-02 13:51:16 -07:00 committed by GitHub
parent 13af0b1d88
commit 118a68c913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 94 additions and 88 deletions

View File

@ -515,6 +515,9 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N
if nodeConfig.FlannelBackend == config.FlannelBackendNone { if nodeConfig.FlannelBackend == config.FlannelBackendNone {
nodeConfig.NoFlannel = true nodeConfig.NoFlannel = true
} else if envInfo.NoFlannel {
logrus.Warn("no-flannel is deprecated, it will be removed in v1.25. Use --flannel-backend=none instead.")
nodeConfig.NoFlannel = envInfo.NoFlannel
} else { } else {
nodeConfig.NoFlannel = envInfo.NoFlannel nodeConfig.NoFlannel = envInfo.NoFlannel
} }

View File

@ -46,6 +46,7 @@ func Run(ctx *cli.Context) error {
} }
if cmds.AgentConfig.Token == "" && cmds.AgentConfig.ClusterSecret != "" { if cmds.AgentConfig.Token == "" && cmds.AgentConfig.ClusterSecret != "" {
logrus.Warn("cluster-secret is deprecated, it will be removed in v1.25. Use --token instead.")
cmds.AgentConfig.Token = cmds.AgentConfig.ClusterSecret cmds.AgentConfig.Token = cmds.AgentConfig.ClusterSecret
} }

View File

@ -86,11 +86,23 @@ var (
Usage: "(agent/node) Append id to node name", Usage: "(agent/node) Append id to node name",
Destination: &AgentConfig.WithNodeID, Destination: &AgentConfig.WithNodeID,
} }
DockerFlag = cli.BoolFlag{ ProtectKernelDefaultsFlag = cli.BoolFlag{
Hidden: true, Name: "protect-kernel-defaults",
Name: "docker", Usage: "(agent/node) Kernel tuning behavior. If set, error if kernel tunables are different than kubelet defaults.",
Usage: "(deprecated) (agent/runtime) Use docker instead of containerd", Destination: &AgentConfig.ProtectKernelDefaults,
Destination: &AgentConfig.Docker, }
SELinuxFlag = cli.BoolFlag{
Name: "selinux",
Usage: "(agent/node) Enable SELinux in containerd",
Destination: &AgentConfig.EnableSELinux,
EnvVar: version.ProgramUpper + "_SELINUX",
}
LBServerPortFlag = cli.IntFlag{
Name: "lb-server-port",
Usage: "(agent/node) Local port for supervisor client load-balancer. If the supervisor and apiserver are not colocated an additional port 1 less than this port will also be used for the apiserver client load-balancer.",
Destination: &AgentConfig.LBServerPort,
EnvVar: version.ProgramUpper + "_LB_SERVER_PORT",
Value: 6444,
} }
CRIEndpointFlag = cli.StringFlag{ CRIEndpointFlag = cli.StringFlag{
Name: "container-runtime-endpoint", Name: "container-runtime-endpoint",
@ -121,11 +133,6 @@ var (
Destination: &AgentConfig.Snapshotter, Destination: &AgentConfig.Snapshotter,
Value: DefaultSnapshotter, Value: DefaultSnapshotter,
} }
FlannelFlag = cli.BoolFlag{
Name: "no-flannel",
Usage: "(deprecated) use --flannel-backend=none",
Destination: &AgentConfig.NoFlannel,
}
FlannelIfaceFlag = cli.StringFlag{ FlannelIfaceFlag = cli.StringFlag{
Name: "flannel-iface", Name: "flannel-iface",
Usage: "(agent/networking) Override default flannel interface", Usage: "(agent/networking) Override default flannel interface",
@ -184,23 +191,17 @@ var (
Usage: "(deprecated) Use --selinux to explicitly enable SELinux", Usage: "(deprecated) Use --selinux to explicitly enable SELinux",
Hidden: true, Hidden: true,
} }
ProtectKernelDefaultsFlag = cli.BoolFlag{ DockerFlag = cli.BoolFlag{
Name: "protect-kernel-defaults", Hidden: true,
Usage: "(agent/node) Kernel tuning behavior. If set, error if kernel tunables are different than kubelet defaults.", Name: "docker",
Destination: &AgentConfig.ProtectKernelDefaults, Usage: "(deprecated) (agent/runtime) Use docker instead of containerd",
Destination: &AgentConfig.Docker,
} }
SELinuxFlag = cli.BoolFlag{ FlannelFlag = cli.BoolFlag{
Name: "selinux", Hidden: true,
Usage: "(agent/node) Enable SELinux in containerd", Name: "no-flannel",
Destination: &AgentConfig.EnableSELinux, Usage: "(deprecated) use --flannel-backend=none",
EnvVar: version.ProgramUpper + "_SELINUX", Destination: &AgentConfig.NoFlannel,
}
LBServerPortFlag = cli.IntFlag{
Name: "lb-server-port",
Usage: "(agent/node) Local port for supervisor client load-balancer. If the supervisor and apiserver are not colocated an additional port 1 less than this port will also be used for the apiserver client load-balancer.",
Destination: &AgentConfig.LBServerPort,
EnvVar: version.ProgramUpper + "_LB_SERVER_PORT",
Value: 6444,
} }
) )
@ -253,7 +254,9 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
NodeTaints, NodeTaints,
ImageCredProvBinDirFlag, ImageCredProvBinDirFlag,
ImageCredProvConfigFlag, ImageCredProvConfigFlag,
DockerFlag, &SELinuxFlag,
LBServerPortFlag,
ProtectKernelDefaultsFlag,
CRIEndpointFlag, CRIEndpointFlag,
PauseImageFlag, PauseImageFlag,
SnapshotterFlag, SnapshotterFlag,
@ -267,24 +270,23 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
FlannelCniConfFileFlag, FlannelCniConfFileFlag,
ExtraKubeletArgs, ExtraKubeletArgs,
ExtraKubeProxyArgs, ExtraKubeProxyArgs,
ProtectKernelDefaultsFlag,
cli.BoolFlag{ cli.BoolFlag{
Name: "rootless", Name: "rootless",
Usage: "(experimental) Run rootless", Usage: "(experimental) Run rootless",
Destination: &AgentConfig.Rootless, Destination: &AgentConfig.Rootless,
}, },
&SELinuxFlag,
LBServerPortFlag,
// Deprecated/hidden below // Deprecated/hidden below
&DisableSELinuxFlag, &DisableSELinuxFlag,
DockerFlag,
FlannelFlag, FlannelFlag,
cli.StringFlag{ cli.StringFlag{
Name: "cluster-secret", Name: "cluster-secret",
Usage: "(deprecated) use --token", Usage: "(deprecated) use --token",
Destination: &AgentConfig.ClusterSecret, Destination: &AgentConfig.ClusterSecret,
EnvVar: version.ProgramUpper + "_CLUSTER_SECRET", EnvVar: version.ProgramUpper + "_CLUSTER_SECRET",
Hidden: true,
}, },
}, },
} }

View File

@ -14,11 +14,7 @@ var (
ConfigFlag, ConfigFlag,
LogFile, LogFile,
AlsoLogToStderr, AlsoLogToStderr,
cli.StringFlag{ DataDirFlag,
Name: "data-dir,d",
Usage: "(data) Folder to hold state default /var/lib/rancher/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root",
Destination: &ServerConfig.DataDir,
},
cli.StringSliceFlag{ cli.StringSliceFlag{
Name: "service,s", Name: "service,s",
Usage: "List of services to rotate certificates for. Options include (admin, api-server, controller-manager, scheduler, " + version.Program + "-controller, " + version.Program + "-server, cloud-controller, etcd, auth-proxy, kubelet, kube-proxy)", Usage: "List of services to rotate certificates for. Options include (admin, api-server, controller-manager, scheduler, " + version.Program + "-controller, " + version.Program + "-server, cloud-controller, etcd, auth-proxy, kubelet, kube-proxy)",

View File

@ -28,7 +28,7 @@ var (
} }
VModule = cli.StringFlag{ VModule = cli.StringFlag{
Name: "vmodule", Name: "vmodule",
Usage: "(logging) Comma-separated list of pattern=N settings for file-filtered logging", Usage: "(logging) Comma-separated list of FILE_PATTERN=LOG_LEVEL settings for file-filtered logging",
Destination: &LogConfig.VModule, Destination: &LogConfig.VModule,
} }
LogFile = cli.StringFlag{ LogFile = cli.StringFlag{

View File

@ -39,7 +39,7 @@ func NewApp() *cli.App {
DebugFlag, DebugFlag,
cli.StringFlag{ cli.StringFlag{
Name: "data-dir,d", Name: "data-dir,d",
Usage: "(data) Folder to hold state default /var/lib/rancher/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root", Usage: "(data) Folder to hold state (default: /var/lib/rancher/" + version.Program + " or ${HOME}/.rancher/" + version.Program + " if not root)",
}, },
} }

View File

@ -218,7 +218,7 @@ var ServerFlags = []cli.Flag{
}, },
cli.StringFlag{ cli.StringFlag{
Name: "egress-selector-mode", Name: "egress-selector-mode",
Usage: "(networking) One of 'agent', cluster', 'pod', 'disabled'", Usage: "(networking) One of 'agent', 'cluster', 'pod', 'disabled'",
Destination: &ServerConfig.EgressSelectorMode, Destination: &ServerConfig.EgressSelectorMode,
Value: "agent", Value: "agent",
}, },
@ -228,13 +228,6 @@ var ServerFlags = []cli.Flag{
Destination: &ServerConfig.ServiceLBNamespace, Destination: &ServerConfig.ServiceLBNamespace,
Value: "kube-system", Value: "kube-system",
}, },
ServerToken,
cli.StringFlag{
Name: "token-file",
Usage: "(cluster) File containing the cluster-secret/token",
Destination: &ServerConfig.TokenFile,
EnvVar: version.ProgramUpper + "_TOKEN_FILE",
},
cli.StringFlag{ cli.StringFlag{
Name: "write-kubeconfig,o", Name: "write-kubeconfig,o",
Usage: "(client) Write kubeconfig for admin client to this file", Usage: "(client) Write kubeconfig for admin client to this file",
@ -247,10 +240,47 @@ var ServerFlags = []cli.Flag{
Destination: &ServerConfig.KubeConfigMode, Destination: &ServerConfig.KubeConfigMode,
EnvVar: version.ProgramUpper + "_KUBECONFIG_MODE", EnvVar: version.ProgramUpper + "_KUBECONFIG_MODE",
}, },
ServerToken,
cli.StringFlag{
Name: "token-file",
Usage: "(cluster) File containing the cluster-secret/token",
Destination: &ServerConfig.TokenFile,
EnvVar: version.ProgramUpper + "_TOKEN_FILE",
},
cli.StringFlag{
Name: "agent-token",
Usage: "(cluster) Shared secret used to join agents to the cluster, but not servers",
Destination: &ServerConfig.AgentToken,
EnvVar: version.ProgramUpper + "_AGENT_TOKEN",
},
cli.StringFlag{
Name: "agent-token-file",
Usage: "(cluster) File containing the agent secret",
Destination: &ServerConfig.AgentTokenFile,
EnvVar: version.ProgramUpper + "_AGENT_TOKEN_FILE",
},
cli.StringFlag{
Name: "server,s",
Usage: "(cluster) Server to connect to, used to join a cluster",
EnvVar: version.ProgramUpper + "_URL",
Destination: &ServerConfig.ServerURL,
},
cli.BoolFlag{ cli.BoolFlag{
Name: "enable-pprof", Name: "cluster-init",
Usage: "(experimental) Enable pprof endpoint on supervisor port", Usage: "(cluster) Initialize a new cluster using embedded Etcd",
Destination: &ServerConfig.EnablePProf, EnvVar: version.ProgramUpper + "_CLUSTER_INIT",
Destination: &ServerConfig.ClusterInit,
},
cli.BoolFlag{
Name: "cluster-reset",
Usage: "(cluster) Forget all peers and become sole member of a new cluster",
EnvVar: version.ProgramUpper + "_CLUSTER_RESET",
Destination: &ServerConfig.ClusterReset,
},
&cli.StringFlag{
Name: "cluster-reset-restore-path",
Usage: "(db) Path to snapshot file to be restored",
Destination: &ServerConfig.ClusterResetRestorePath,
}, },
ExtraAPIArgs, ExtraAPIArgs,
ExtraEtcdArgs, ExtraEtcdArgs,
@ -287,7 +317,7 @@ var ServerFlags = []cli.Flag{
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "etcd-expose-metrics", Name: "etcd-expose-metrics",
Usage: "(db) Expose etcd metrics to client interface. (Default false)", Usage: "(db) Expose etcd metrics to client interface. (default: false)",
Destination: &ServerConfig.EtcdExposeMetrics, Destination: &ServerConfig.EtcdExposeMetrics,
}, },
&cli.BoolFlag{ &cli.BoolFlag{
@ -297,7 +327,7 @@ var ServerFlags = []cli.Flag{
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "etcd-snapshot-name", Name: "etcd-snapshot-name",
Usage: "(db) Set the base name of etcd snapshots. Default: etcd-snapshot-<unix-timestamp>", Usage: "(db) Set the base name of etcd snapshots (default: etcd-snapshot-<unix-timestamp>)",
Destination: &ServerConfig.EtcdSnapshotName, Destination: &ServerConfig.EtcdSnapshotName,
Value: "etcd-snapshot", Value: "etcd-snapshot",
}, },
@ -315,7 +345,7 @@ var ServerFlags = []cli.Flag{
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "etcd-snapshot-dir", Name: "etcd-snapshot-dir",
Usage: "(db) Directory to save db snapshots. (Default location: ${data-dir}/db/snapshots)", Usage: "(db) Directory to save db snapshots. (default: ${data-dir}/db/snapshots)",
Destination: &ServerConfig.EtcdSnapshotDir, Destination: &ServerConfig.EtcdSnapshotDir,
}, },
&cli.BoolFlag{ &cli.BoolFlag{
@ -456,46 +486,16 @@ var ServerFlags = []cli.Flag{
ExtraKubeletArgs, ExtraKubeletArgs,
ExtraKubeProxyArgs, ExtraKubeProxyArgs,
ProtectKernelDefaultsFlag, ProtectKernelDefaultsFlag,
cli.BoolFlag{
Name: "enable-pprof",
Usage: "(experimental) Enable pprof endpoint on supervisor port",
Destination: &ServerConfig.EnablePProf,
},
cli.BoolFlag{ cli.BoolFlag{
Name: "rootless", Name: "rootless",
Usage: "(experimental) Run rootless", Usage: "(experimental) Run rootless",
Destination: &ServerConfig.Rootless, Destination: &ServerConfig.Rootless,
}, },
cli.StringFlag{
Name: "agent-token",
Usage: "(cluster) Shared secret used to join agents to the cluster, but not servers",
Destination: &ServerConfig.AgentToken,
EnvVar: version.ProgramUpper + "_AGENT_TOKEN",
},
cli.StringFlag{
Name: "agent-token-file",
Usage: "(cluster) File containing the agent secret",
Destination: &ServerConfig.AgentTokenFile,
EnvVar: version.ProgramUpper + "_AGENT_TOKEN_FILE",
},
cli.StringFlag{
Name: "server,s",
Usage: "(cluster) Server to connect to, used to join a cluster",
EnvVar: version.ProgramUpper + "_URL",
Destination: &ServerConfig.ServerURL,
},
cli.BoolFlag{
Name: "cluster-init",
Usage: "(cluster) Initialize a new cluster using embedded Etcd",
EnvVar: version.ProgramUpper + "_CLUSTER_INIT",
Destination: &ServerConfig.ClusterInit,
},
cli.BoolFlag{
Name: "cluster-reset",
Usage: "(cluster) Forget all peers and become sole member of a new cluster",
EnvVar: version.ProgramUpper + "_CLUSTER_RESET",
Destination: &ServerConfig.ClusterReset,
},
&cli.StringFlag{
Name: "cluster-reset-restore-path",
Usage: "(db) Path to snapshot file to be restored",
Destination: &ServerConfig.ClusterResetRestorePath,
},
cli.BoolFlag{ cli.BoolFlag{
Name: "secrets-encryption", Name: "secrets-encryption",
Usage: "(experimental) Enable Secret encryption at rest", Usage: "(experimental) Enable Secret encryption at rest",
@ -515,14 +515,16 @@ var ServerFlags = []cli.Flag{
&DisableSELinuxFlag, &DisableSELinuxFlag,
FlannelFlag, FlannelFlag,
cli.StringSliceFlag{ cli.StringSliceFlag{
Name: "no-deploy", Name: "no-deploy",
Usage: "(deprecated) Do not deploy packaged components (valid items: " + DisableItems + ")", Usage: "(deprecated) Do not deploy packaged components (valid items: " + DisableItems + ")",
Hidden: true,
}, },
cli.StringFlag{ cli.StringFlag{
Name: "cluster-secret", Name: "cluster-secret",
Usage: "(deprecated) use --token", Usage: "(deprecated) use --token",
Destination: &ServerConfig.ClusterSecret, Destination: &ServerConfig.ClusterSecret,
EnvVar: version.ProgramUpper + "_CLUSTER_SECRET", EnvVar: version.ProgramUpper + "_CLUSTER_SECRET",
Hidden: true,
}, },
cli.BoolFlag{ cli.BoolFlag{
Name: "disable-agent", Name: "disable-agent",

View File

@ -88,6 +88,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
} }
if cfg.Token == "" && cfg.ClusterSecret != "" { if cfg.Token == "" && cfg.ClusterSecret != "" {
logrus.Warn("cluster-secret is deprecated, it will be removed in v1.25. Use --token instead.")
cfg.Token = cfg.ClusterSecret cfg.Token = cfg.ClusterSecret
} }
@ -348,6 +349,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
serverConfig.ControlConfig.Skips = map[string]bool{} serverConfig.ControlConfig.Skips = map[string]bool{}
for _, noDeploy := range app.StringSlice("no-deploy") { for _, noDeploy := range app.StringSlice("no-deploy") {
logrus.Warn("no-deploy flag is deprecated, it will be removed in v1.25. Use --skip-deploy instead.")
for _, v := range strings.Split(noDeploy, ",") { for _, v := range strings.Split(noDeploy, ",") {
v = strings.TrimSpace(v) v = strings.TrimSpace(v)
serverConfig.ControlConfig.Skips[v] = true serverConfig.ControlConfig.Skips[v] = true