kubernetes/kops · error

error building user data: %v

Error message

error building user data: %v

What it means

buildElastigroup generates node bootstrap user data by delegating to b.BootstrapScriptBuilder.ResourceNodeUp(c, ig). This wrapper fires when rendering the nodeup bootstrap script fails, so the Elastigroup task cannot be completed during `kops update cluster`.

Source

Thrown at pkg/model/awsmodel/spotinst.go:317

		return fmt.Errorf("error building security groups: %v", err)
	}

	// SSH key.
	group.SSHKey, err = b.LinkToSSHKey()
	if err != nil {
		return fmt.Errorf("error building ssh key: %v", err)
	}

	// Load balancers.
	group.LoadBalancers, group.TargetGroups, err = b.buildLoadBalancers(c, ig)
	if err != nil {
		return fmt.Errorf("error building load balancers: %v", err)
	}

	// User data.
	group.UserData, err = b.BootstrapScriptBuilder.ResourceNodeUp(c, ig)
	if err != nil {
		return fmt.Errorf("error building user data: %v", err)
	}

	// Public IP.
	group.AssociatePublicIPAddress, err = b.buildPublicIPOpts(ig)
	if err != nil {
		return fmt.Errorf("error building public ip options: %v", err)
	}

	// Subnets.
	group.Subnets, err = b.buildSubnets(ig)
	if err != nil {
		return fmt.Errorf("error building subnets: %v", err)
	}

	// Capacity.
	group.MinSize, group.MaxSize = b.buildCapacity(ig)

	// Monitoring.

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the wrapped inner error; it names the failed template or asset.
  2. Clear the kops asset cache (rm -rf ~/.cache/kops) and retry `kops update cluster`.
  3. Ensure ig.spec.image matches a supported AMI for the region and the cluster's Kubernetes version.
  4. Upgrade or downgrade kOps to a release matching your cluster's Kubernetes version and retry.

Example fix

// before (cluster.yaml)
image: ami-custom-unsupported
// after
image: ami-0abcdef1234567890 # supported Ubuntu/Debian AMI for the region
Defensive patterns

Strategy: retry

Validate before calling

// ensure a supported image and matching kubernetesVersion
if ig.Spec.Image == "" {
  return fmt.Errorf("instance group %s must set spec.image", ig.Name)
}

Try / catch

if err := kopsUpdate(); err != nil {
  if strings.Contains(err.Error(), "error building user data") {
    os.RemoveAll(filepath.Join(home, ".cache", "kops")) // clear asset cache
    // retry update
  }
}

Prevention

When it happens

Trigger: `kops update cluster` with Spotinst where the nodeup bootstrap template rendering fails — typically missing/invalid assets in the asset store, an unsupported image/instance-type combination that the template cannot resolve, or an internal template execution error.

Common situations: Custom/unsupported AMIs whose architecture the nodeup script cannot infer; corrupted local asset cache (~/.cache/kops); kOps version skew where the template expects assets not present for the selected kubernetes version.

Related errors


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