kubernetes/kubernetes · error
%q does not take any arguments, got %q
Error message
%q does not take any arguments, got %q
What it means
Emitted by the cobra Args validator on the kube-controller-manager command. Like kube-apiserver, kube-controller-manager is flag-only and rejects any positional argument; the validator fails on the first non-empty token and reports the full args slice.
Source
Thrown at cmd/kube-controller-manager/app/controllermanager.go:167
if err != nil {
return err
}
// add feature enablement metrics
fg := s.ComponentGlobalsRegistry.FeatureGateFor(basecompatibility.DefaultKubeComponent)
fg.(featuregate.MutableFeatureGate).AddMetrics()
// add component version metrics
s.ComponentGlobalsRegistry.AddMetrics()
if utilfeature.DefaultFeatureGate.Enabled(cmfeatures.ControllerManagerReleaseLeaderElectionLockOnExit) {
ctx = server.SetupSignalContext()
}
return Run(ctx, c.Complete())
},
Args: func(cmd *cobra.Command, args []string) error {
for _, arg := range args {
if len(arg) > 0 {
return fmt.Errorf("%q does not take any arguments, got %q", cmd.CommandPath(), args)
}
}
return nil
},
}
fs := cmd.Flags()
namedFlagSets := s.Flags(KnownControllers(), ControllersDisabledByDefault(), ControllerAliases())
s.ParsedFlags = &namedFlagSets
verflag.AddFlags(namedFlagSets.FlagSet("global"))
globalflag.AddGlobalFlags(namedFlagSets.FlagSet("global"), cmd.Name(), logs.SkipLoggingConfigurationFlags())
for _, f := range namedFlagSets.FlagSets {
fs.AddFlagSet(f)
}
cols, _, _ := term.TerminalSize(cmd.OutOrStdout())
cliflag.SetUsageAndHelpFunc(cmd, namedFlagSets, cols)
View on GitHub (pinned to b882c60b40)
Solutions
- Remove all positional arguments; kube-controller-manager only accepts --flag=value.
- Audit the systemd ExecStart / container command for stray tokens.
- Use --controllers flags to select controllers instead of positional names.
Example fix
// before kube-controller-manager --leader-elect=true run // after kube-controller-manager --leader-elect=true
Defensive patterns
Strategy: validation
Validate before calling
func validateArgs(binary string, args []string) error {
for _, a := range args {
if a != "" { return fmt.Errorf("%s takes no positional args, got %v", binary, args) }
}
return nil
} Prevention
- kube-controller-manager is flag-only; never append subcommands.
- Lint systemd/container units for stray positional tokens.
When it happens
Trigger: Invoking `kube-controller-manager <token>` where <token> is not a flag, e.g. `kube-controller-manager --leader-elect run`.
Common situations: Leftover subcommand from hyperkube-era invocation; a wrapper appending a node name or profile name as a positional arg.
Related errors
- %q does not take any arguments, got %q
- duration time must be greater than one second as set via com
- concurrent-cron-job-syncs must be greater than 0, but got %d
- %q: %v
- cannot specify --cluster-signing-{cert,key}-file and other -
AI-assisted analysis of kubernetes/kubernetes@b882c60b40 (2026-08-07).
Data as JSON: /api/errors/0c9d91e362129719.
Report an issue: GitHub.