kubernetes/kops · error

must specify name of keyset to add keypair to

Error message

must specify name of keyset to add keypair to

What it means

The Args validator requires exactly at least one positional argument naming the keyset (e.g. apiserver, kubelet, ca) to which a new keypair will be added. With zero args, the command cannot proceed and returns this message.

Source

Thrown at cmd/kops/create_keypair.go:107

// NewCmdCreateKeypair returns a create keypair command.
func NewCmdCreateKeypair(f *util.Factory, out io.Writer) *cobra.Command {
	options := &CreateKeypairOptions{}

	cmd := &cobra.Command{
		Use:     "keypair {KEYSET | all}",
		Short:   createKeypairShort,
		Long:    createKeypairLong,
		Example: createKeypairExample,
		Args: func(cmd *cobra.Command, args []string) error {
			options.ClusterName = rootCommand.ClusterName(true)

			if options.ClusterName == "" {
				return fmt.Errorf("--name is required")
			}

			if len(args) == 0 {
				return fmt.Errorf("must specify name of keyset to add keypair to")
			}

			options.Keyset = args[0]

			if len(args) != 1 {
				return fmt.Errorf("can only add to one keyset at a time")
			}

			if options.Keyset == "all" {
				if options.CertPath != "" {
					return fmt.Errorf("cannot specify --cert with \"all\"")
				}
				if options.PrivateKeyPath != "" {
					return fmt.Errorf("cannot specify --key with \"all\"")
				}
				if options.Primary {
					return fmt.Errorf("cannot specify --primary with \"all\"")
				}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Provide the keyset name: `kops create keypair --name <cluster> <keyset>` (e.g. `ca`, `apiserver`, `kubelet`)
  2. List available keysets with `kops get secrets` / cluster keyset listing to pick a valid name
  3. Fix empty variables in scripts that interpolate the keyset argument

Example fix

// before
kops create keypair --name c.k8s.local
// after
kops create keypair --name c.k8s.local apiserver
Defensive patterns

Strategy: validation

Validate before calling

[ $# -ge 1 ] || { echo "usage: kops create keypair --name <cluster> <keyset>" >&2; exit 2; }

Prevention

When it happens

Trigger: Running `kops create keypair --name <cluster>` with no keyset argument at all.

Common situations: Omitting the keyset name when copy-pasting the command skeleton; scripting where a variable holding the keyset is empty; confusing `create keypair` with `export kubecfg`-style commands that need no argument.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/95fc47be365e92fa. Report an issue: GitHub.