kubernetes/kops · error

unknown subnet type %q

Error message

unknown subnet type %q

What it means

Raised by buildPublicIPOpts in its default switch branch when the resolved subnetType is not one of the recognized kops subnet types (Public, Utility, Private). This means an unrecognized subnet type value reached the public-IP decision logic.

Source

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

		subnetType = subnet.Type
	}

	var associatePublicIP bool
	switch subnetType {
	case kops.SubnetTypePublic, kops.SubnetTypeUtility:
		associatePublicIP = true
		if ig.Spec.AssociatePublicIP != nil {
			associatePublicIP = *ig.Spec.AssociatePublicIP
		}
	case kops.SubnetTypeDualStack, kops.SubnetTypePrivate:
		associatePublicIP = false
		if ig.Spec.AssociatePublicIP != nil {
			if *ig.Spec.AssociatePublicIP {
				klog.Warningf("Ignoring AssociatePublicIPAddress=true for private SpotInstanceGroup %q", ig.ObjectMeta.Name)
			}
		}
	default:
		return nil, fmt.Errorf("unknown subnet type %q", subnetType)
	}

	return new(associatePublicIP), nil
}

func (b *SpotInstanceGroupModelBuilder) buildRootVolumeOpts(ig *kops.InstanceGroup) (*spotinsttasks.RootVolumeOpts, error) {
	opts := new(spotinsttasks.RootVolumeOpts)

	var size int32
	var typ string
	var iops int32
	var throughput int32
	if ig.Spec.RootVolume != nil {
		// Optimization.
		{
			if fi.ValueOf(ig.Spec.RootVolume.Optimization) {
				opts.Optimization = ig.Spec.RootVolume.Optimization
			}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set subnetType to a valid value: Public, Private, or Utility
  2. Upgrade kops to the latest version if a newer subnet type is in use
  3. Validate the cluster YAML and re-run kops update --yes

Example fix

// before
spec:
  subnetType: publik
// after
spec:
  subnetType: Public
Defensive patterns

Strategy: validation

Validate before calling

allowed := map[kops.SubnetType]bool{"Public": true, "Private": true, "Utility": true}
for _, s := range cluster.Spec.Subnets {
  if !allowed[s.Type] {
    return fmt.Errorf("subnet %q has unsupported type %q", s.Name, s.Type)
  }
}

Type guard

func isKnownSubnetType(t kops.SubnetType) bool {
  switch t {
  case "", "Public", "Private", "Utility":
    return true
  }
  return false
}

Prevention

When it happens

Trigger: kops create/update where the cluster's subnet spec carries an unknown/invalid subnetType value that the Spotinst model does not handle.

Common situations: Hand-edited cluster YAML with a typo in subnet type, a subnetType introduced in a newer kops version used by an older binary (or vice versa), or corrupt cluster state in the state store.

Related errors


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