Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ func get(ctx context.Context, envInfo *cmds.Agent, proxy proxy.Proxy) (*config.N

if nodeConfig.FlannelBackend == config.FlannelBackendNone {
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 {
nodeConfig.NoFlannel = envInfo.NoFlannel
}
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func Run(ctx *cli.Context) error {
}

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
}

Expand Down
62 changes: 32 additions & 30 deletions pkg/cli/cmds/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,23 @@ var (
Usage: "(agent/node) Append id to node name",
Destination: &AgentConfig.WithNodeID,
}
DockerFlag = cli.BoolFlag{
Hidden: true,
Name: "docker",
Usage: "(deprecated) (agent/runtime) Use docker instead of containerd",
Destination: &AgentConfig.Docker,
ProtectKernelDefaultsFlag = cli.BoolFlag{
Name: "protect-kernel-defaults",
Usage: "(agent/node) Kernel tuning behavior. If set, error if kernel tunables are different than kubelet defaults.",
Destination: &AgentConfig.ProtectKernelDefaults,
}
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{
Name: "container-runtime-endpoint",
Expand Down Expand Up @@ -121,11 +133,6 @@ var (
Destination: &AgentConfig.Snapshotter,
Value: DefaultSnapshotter,
}
FlannelFlag = cli.BoolFlag{
Name: "no-flannel",
Usage: "(deprecated) use --flannel-backend=none",
Destination: &AgentConfig.NoFlannel,
}
FlannelIfaceFlag = cli.StringFlag{
Name: "flannel-iface",
Usage: "(agent/networking) Override default flannel interface",
Expand Down Expand Up @@ -184,23 +191,17 @@ var (
Usage: "(deprecated) Use --selinux to explicitly enable SELinux",
Hidden: true,
}
ProtectKernelDefaultsFlag = cli.BoolFlag{
Name: "protect-kernel-defaults",
Usage: "(agent/node) Kernel tuning behavior. If set, error if kernel tunables are different than kubelet defaults.",
Destination: &AgentConfig.ProtectKernelDefaults,
}
SELinuxFlag = cli.BoolFlag{
Name: "selinux",
Usage: "(agent/node) Enable SELinux in containerd",
Destination: &AgentConfig.EnableSELinux,
EnvVar: version.ProgramUpper + "_SELINUX",
DockerFlag = cli.BoolFlag{
Hidden: true,
Name: "docker",
Usage: "(deprecated) (agent/runtime) Use docker instead of containerd",
Destination: &AgentConfig.Docker,
}
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,
FlannelFlag = cli.BoolFlag{
Hidden: true,
Name: "no-flannel",
Usage: "(deprecated) use --flannel-backend=none",
Destination: &AgentConfig.NoFlannel,
}
)

Expand Down Expand Up @@ -253,7 +254,9 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
NodeTaints,
ImageCredProvBinDirFlag,
ImageCredProvConfigFlag,
DockerFlag,
&SELinuxFlag,
LBServerPortFlag,
ProtectKernelDefaultsFlag,
CRIEndpointFlag,
PauseImageFlag,
SnapshotterFlag,
Expand All @@ -267,24 +270,23 @@ func NewAgentCommand(action func(ctx *cli.Context) error) cli.Command {
FlannelCniConfFileFlag,
ExtraKubeletArgs,
ExtraKubeProxyArgs,
ProtectKernelDefaultsFlag,
cli.BoolFlag{
Name: "rootless",
Usage: "(experimental) Run rootless",
Destination: &AgentConfig.Rootless,
},
&SELinuxFlag,
LBServerPortFlag,

// Deprecated/hidden below

&DisableSELinuxFlag,
DockerFlag,
FlannelFlag,
cli.StringFlag{
Name: "cluster-secret",
Usage: "(deprecated) use --token",
Destination: &AgentConfig.ClusterSecret,
EnvVar: version.ProgramUpper + "_CLUSTER_SECRET",
Hidden: true,
},
},
}
Expand Down
6 changes: 1 addition & 5 deletions pkg/cli/cmds/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ var (
ConfigFlag,
LogFile,
AlsoLogToStderr,
cli.StringFlag{
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,
},
DataDirFlag,
cli.StringSliceFlag{
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)",
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmds/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
}
VModule = cli.StringFlag{
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,
}
LogFile = cli.StringFlag{
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/cmds/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewApp() *cli.App {
DebugFlag,
cli.StringFlag{
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)",
},
}

Expand Down
104 changes: 53 additions & 51 deletions pkg/cli/cmds/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ var ServerFlags = []cli.Flag{
},
cli.StringFlag{
Name: "egress-selector-mode",
Usage: "(networking) One of 'agent', cluster', 'pod', 'disabled'",
Usage: "(networking) One of 'agent', 'cluster', 'pod', 'disabled'",
Destination: &ServerConfig.EgressSelectorMode,
Value: "agent",
},
Expand All @@ -228,13 +228,6 @@ var ServerFlags = []cli.Flag{
Destination: &ServerConfig.ServiceLBNamespace,
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{
Name: "write-kubeconfig,o",
Usage: "(client) Write kubeconfig for admin client to this file",
Expand All @@ -247,10 +240,47 @@ var ServerFlags = []cli.Flag{
Destination: &ServerConfig.KubeConfigMode,
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{
Name: "enable-pprof",
Usage: "(experimental) Enable pprof endpoint on supervisor port",
Destination: &ServerConfig.EnablePProf,
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,
},
ExtraAPIArgs,
ExtraEtcdArgs,
Expand Down Expand Up @@ -287,7 +317,7 @@ var ServerFlags = []cli.Flag{
},
&cli.BoolFlag{
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,
},
&cli.BoolFlag{
Expand All @@ -297,7 +327,7 @@ var ServerFlags = []cli.Flag{
},
&cli.StringFlag{
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,
Value: "etcd-snapshot",
},
Expand All @@ -315,7 +345,7 @@ var ServerFlags = []cli.Flag{
},
&cli.StringFlag{
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,
},
&cli.BoolFlag{
Expand Down Expand Up @@ -456,46 +486,16 @@ var ServerFlags = []cli.Flag{
ExtraKubeletArgs,
ExtraKubeProxyArgs,
ProtectKernelDefaultsFlag,
cli.BoolFlag{
Name: "enable-pprof",
Usage: "(experimental) Enable pprof endpoint on supervisor port",
Destination: &ServerConfig.EnablePProf,
},
cli.BoolFlag{
Name: "rootless",
Usage: "(experimental) Run 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{
Name: "secrets-encryption",
Usage: "(experimental) Enable Secret encryption at rest",
Expand All @@ -515,14 +515,16 @@ var ServerFlags = []cli.Flag{
&DisableSELinuxFlag,
FlannelFlag,
cli.StringSliceFlag{
Name: "no-deploy",
Usage: "(deprecated) Do not deploy packaged components (valid items: " + DisableItems + ")",
Name: "no-deploy",
Usage: "(deprecated) Do not deploy packaged components (valid items: " + DisableItems + ")",
Hidden: true,
},
cli.StringFlag{
Name: "cluster-secret",
Usage: "(deprecated) use --token",
Destination: &ServerConfig.ClusterSecret,
EnvVar: version.ProgramUpper + "_CLUSTER_SECRET",
Hidden: true,
},
cli.BoolFlag{
Name: "disable-agent",
Expand Down
2 changes: 2 additions & 0 deletions pkg/cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont
}

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
}

Expand Down Expand Up @@ -348,6 +349,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont

serverConfig.ControlConfig.Skips = map[string]bool{}
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, ",") {
v = strings.TrimSpace(v)
serverConfig.ControlConfig.Skips[v] = true
Expand Down