kubernetes/kops · error

must specify names of keypairs to trust keypair in

Error message

must specify names of keypairs to trust keypair in

What it means

`kops trust keypair` requires the keyset name followed by one or more keypair IDs to trust. If only one argument (the keyset) is given, the Args validator returns this error because no keypair IDs were supplied.

Source

Thrown at cmd/kops/trust_keypair.go:76

	cmd := &cobra.Command{
		Use:     "keypair KEYSET ID...",
		Short:   trustKeypairShort,
		Long:    trustKeypairLong,
		Example: trustKeypairExample,
		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 trust keypair in")
			}
			options.Keyset = args[0]

			if len(args) == 1 {
				return fmt.Errorf("must specify names of keypairs to trust keypair in")
			}
			options.KeypairIDs = args[1:]

			return nil
		},
		ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
			return completeTrustKeyset(cmd.Context(), f, options, args, toComplete)
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			ctx := cmd.Context()

			return RunTrustKeypair(ctx, f, out, options)
		},
	}

	return cmd
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Append one or more keypair IDs: `kops trust keypair --name <cluster> <keyset> <id1> [<id2>...]`.
  2. List keypair IDs first with `kops get keypairs --name <cluster> <keyset>` and copy the desired ones.
  3. See `kops trust keypair --help` for the expected argument list.

Example fix

// before
kops trust keypair --name mycluster.example.com kubernetes-ca
// after
kops trust keypair --name mycluster.example.com kubernetes-ca 2026-01-01
Defensive patterns

Strategy: validation

Validate before calling

if len(positionalArgs) < 2 { return errors.New("keypair IDs required: kops trust keypair <keyset> <keypair-id>...") }

Try / catch

out, err := exec.Command("kops", "trust", "keypair", cmdArgs...).CombinedOutput()
if strings.Contains(string(out), "must specify names of keypairs") { fetch keypair IDs via `kops get keypairs` and append them }

Prevention

When it happens

Trigger: Running `kops trust keypair --name <cluster> <keyset>` with exactly one positional argument and no keypair IDs.

Common situations: Stopping after the keyset argument by mistake; forgetting to paste the keypair ID from `kops get keypairs` output.

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/40fadf89c3449b62. Report an issue: GitHub.