kubernetes/kops · error

error building public ip options: %v

Error message

error building public ip options: %v

What it means

buildElastigroup calls b.buildPublicIPOpts to decide group.AssociatePublicIPAddress from the instance group's subnets. This wrapper fires when that derivation fails, e.g. the subnets referenced by the instance group cannot be resolved consistently into public/private placement, so the Spotinst group cannot be configured.

Source

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

		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.
	group.Monitoring = ig.Spec.DetailedInstanceMonitoring

	// Tags.
	group.Tags, err = b.buildTags(ig)
	if err != nil {
		return fmt.Errorf("error building cloud tags: %v", err)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the wrapped inner error for the exact subnet resolution failure.
  2. Confirm every name in ig.spec.subnets exists in cluster.spec.subnets (`kops get cluster -oyaml`).
  3. Use only 'utility' subnets for groups that need public IPs and private subnets otherwise; don't mix.
  4. Re-run `kops update cluster` after fixing the instance group spec.

Example fix

// before
spec:
  subnets: [us-east-1a, nonexistent-1b]
// after
spec:
  subnets: [utility-us-east-1a, utility-us-east-1b]
Defensive patterns

Strategy: validation

Validate before calling

clusterSubnets := map[string]bool{}
for _, s := range cluster.Spec.Subnets { clusterSubnets[s.Name] = true }
for _, n := range ig.Spec.Subnets {
  if !clusterSubnets[n] {
    return fmt.Errorf("instance group %s references unknown subnet %q", ig.Name, n)
  }
}

Try / catch

if err := kopsUpdate(); err != nil {
  if strings.Contains(err.Error(), "error building public ip options") {
    // reconcile ig.spec.subnets with cluster.spec.subnets and retry
  }
}

Prevention

When it happens

Trigger: `kops update cluster` with Spotinst where an instance group's spec.subnets reference subnet names that don't exist in the cluster spec or mix subnet kinds so no consistent public-IP setting can be computed.

Common situations: Typo in subnet names under spec.subnets; instance groups edited by hand referencing subnets removed from cluster.spec.subnets; mixed utility/private subnet lists on one IG.

Related errors


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