kubernetes/kops · error

unable to execute --dry-run without setting --output

Error message

unable to execute --dry-run without setting --output

What it means

RunCreateCluster rejects --dry-run when --output is not set, because a dry run renders the manifests to the chosen output format (yaml/json) and needs a destination format. This is an explicit argument-consistency validation in the CLI.

Source

Thrown at cmd/kops/create_cluster.go:542

	ctx, span := tracer.Start(ctx, "RunCreateCluster")
	defer span.End()

	isDryrun := false
	// direct requires --yes (others do not, because they don't make changes)
	targetName := c.Target
	if c.Target == cloudup.TargetDirect {
		if !c.Yes {
			isDryrun = true
			targetName = cloudup.TargetDryRun
		}
	}
	if c.Target == cloudup.TargetDryRun {
		isDryrun = true
		targetName = cloudup.TargetDryRun
	}

	if c.DryRun && c.Output == "" {
		return fmt.Errorf("unable to execute --dry-run without setting --output")
	}

	// TODO: Reuse rootCommand stateStore logic?

	if c.OutDir == "" {
		if c.Target == cloudup.TargetTerraform {
			c.OutDir = "out/terraform"
		} else {
			c.OutDir = "out"
		}
	}

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

	if c.ClusterName == "" {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Add --output yaml (or json) alongside --dry-run
  2. If you intend to actually create the cluster, remove --dry-run instead
  3. Note: --out (target directory for terraform) is not the same as --output

Example fix

// before
kops create cluster mycluster.example.com --dry-run
// after
kops create cluster mycluster.example.com --dry-run --output yaml
Defensive patterns

Strategy: validation

Validate before calling

if dryRun && outputFlag == "" {
	// fix before invoking
	outputFlag = "yaml"
}

Prevention

When it happens

Trigger: Invoking `kops create cluster --dry-run` without also passing `--output yaml` (or json).

Common situations: Scripting dry-run cluster creation to preview manifests but forgetting the output flag; copying old command lines where --output was dropped.

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/243370ddef47c0de. Report an issue: GitHub.