kubernetes/kops · warning

error writing to output: %v

Error message

error writing to output: %v

What it means

At the end of a successful create, kops writes a next-steps message (suggesting `kops update cluster --name <name> --yes --admin`) to the output writer. This error means the Write call on that writer failed. It occurs after the cluster config and SSH keys were already persisted, so the cluster exists but the instructions were never displayed.

Source

Thrown at cmd/kops/create_cluster.go:922

			fmt.Fprintf(&sb, "\n")
			fmt.Fprintf(&sb, "Cluster configuration has been created.\n")
			fmt.Fprintf(&sb, "\n")
			fmt.Fprintf(&sb, "Suggestions:\n")
			fmt.Fprintf(&sb, " * list clusters with: kops get cluster\n")
			fmt.Fprintf(&sb, " * edit this cluster with: kops edit cluster %s\n", cluster.Name)
			if len(nodes) > 0 {
				fmt.Fprintf(&sb, " * edit your node instance group: kops edit ig --name=%s %s\n", cluster.Name, nodes[0].ObjectMeta.Name)
			}
			if len(controlPlanes) > 0 {
				fmt.Fprintf(&sb, " * edit your control-plane instance group: kops edit ig --name=%s %s\n", cluster.Name, controlPlanes[0].ObjectMeta.Name)
			}
			fmt.Fprintf(&sb, "\n")
			fmt.Fprintf(&sb, "Finally configure your cluster with: kops update cluster --name %s --yes --admin\n", cluster.Name)
			fmt.Fprintf(&sb, "\n")

			_, err := out.Write(sb.Bytes())
			if err != nil {
				return fmt.Errorf("error writing to output: %v", err)
			}
		}
	}

	return nil
}

// checkProjectFlag rejects an explicitly empty --project flag. An empty value usually comes from
// an unset environment variable (e.g. --project=$PROJECT); silently accepting it would fall back
// to the gcloud default project, which may not be the intended one.
func checkProjectFlag(flagSet bool, project string) error {
	if flagSet && project == "" {
		return fmt.Errorf("--project cannot be empty; specify a project or omit the flag to use the gcloud default project")
	}
	return nil
}

// parseCloudLabels takes a CSV list of key=value records and parses them into a map. Nested '='s are supported via

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Re-run with a plain terminal or a healthy redirect target.
  2. Check disk space if output was redirected to a file.
  3. The cluster is likely already created — run `kops get clusters` to confirm, then proceed with `kops update cluster --name <name> --yes --admin`.
  4. Avoid piping kops output into commands that exit early (write to a file instead).

Example fix

// before
kops create cluster ... | head -1   # EPIPE on write
// after
kops create cluster ... > create-output.txt
Defensive patterns

Strategy: try-catch

Try / catch

if err := runCreateCluster(...); err != nil {
	if strings.Contains(err.Error(), "error writing to output") {
		// cluster is likely created; verify with kops get clusters and print next steps yourself
	}
	return err
}

Prevention

When it happens

Trigger: `kops create cluster` completing successfully but out.Write fails — e.g. stdout is a closed pipe (EPIPE), full disk on a redirected file, or the stream was closed by a wrapper program.

Common situations: `kops create cluster | head -1` causing SIGPIPE in scripts; stdout redirected to a file on a full filesystem; output stream closed by a CI runner or wrapper.

Related errors


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