kubernetes/kops · error

host is required

Error message

host is required

What it means

The enroll command needs the address (IP or hostname) of the bare-metal machine to SSH into and build the Host resource; without it no enrollment work is possible. RunToolboxEnroll validates `options.Host` up front and returns this error when it is empty.

Source

Thrown at pkg/commands/toolbox_enroll.go:100

func (o *ToolboxEnrollOptions) InitDefaults() {
	o.SSHUser = "root"
	o.SSHPort = 22
}

func RunToolboxEnroll(ctx context.Context, f commandutils.Factory, out io.Writer, options *ToolboxEnrollOptions) error {
	if !featureflag.Metal.Enabled() {
		return fmt.Errorf("bare-metal support requires the Metal feature flag to be enabled")
	}
	if options.ClusterName == "" {
		return fmt.Errorf("cluster is required")
	}
	if options.InstanceGroup == "" {
		return fmt.Errorf("instance-group is required")
	}
	if options.Host == "" {
		// Technically we could build the host resource without the PKI, but this isn't the case we are targeting right now.
		return fmt.Errorf("host is required")
	}

	// Resolve KOPS_BASE_URL early so that kops.Version is overridden
	// before the version downgrade check in ApplyClusterCmd.Run.
	if _, err := wellknownassets.BaseURL(); err != nil {
		return err
	}

	clientset, err := f.KopsClient()
	if err != nil {
		return err
	}

	configBuilder := &ConfigBuilder{
		Clientset:         clientset,
		ClusterName:       options.ClusterName,
		InstanceGroupName: options.InstanceGroup,
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Pass `--host <ip-or-hostname>` reachable via SSH as root (default SSH user/port)
  2. Fix the loop/variable so the host value is non-empty before invoking kops
  3. Confirm network reachability: `ssh root@<host>` should work with your key

Example fix

// before
HOSTS=""; for h in $HOSTS; do kops toolbox enroll --cluster c --instance-group metal --host $h; done
// after
HOSTS="10.0.0.5 10.0.0.6"; for h in $HOSTS; do kops toolbox enroll --cluster c --instance-group metal --host $h; done
Defensive patterns

Strategy: validation

Validate before calling

for h in $HOSTS; do
  [ -n "$h" ] || { echo "empty host in list"; exit 1; }
  ssh -o BatchMode=yes -o ConnectTimeout=5 "root@$h" true || { echo "host $h unreachable"; exit 1; }
done

Prevention

When it happens

Trigger: Running `kops toolbox enroll` with --cluster and --instance-group set but no `--host` (or an empty interpolated variable).

Common situations: Loop scripts where the host variable failed to expand; enrolling from a metadata/CSV where the IP column was blank; misremembering the flag name.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


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