kubernetes/kops · error

subnet %s not found in network %s

Error message

subnet %s not found in network %s

What it means

kops is creating a new cluster on OpenStack and needs to map each availability zone to a subnet provider ID. It looks up every user-supplied subnet ID in the subnets discovered for the cluster's network (cluster.Spec.Networking.NetworkID). This error means one of the requested subnet IDs does not exist within that network, so the zone-to-subnet mapping cannot be built.

Source

Thrown at upup/pkg/fi/cloudup/new_cluster.go:959

	osCloud.UseZones(zones)

	networkInfo, err := osCloud.FindVPCInfo(cluster.Spec.Networking.NetworkID)
	if err != nil {
		return res, fmt.Errorf("error describing Network: %v", err)
	}
	if networkInfo == nil {
		return res, fmt.Errorf("network %q not found", cluster.Spec.Networking.NetworkID)
	}

	subnetByID := make(map[string]*fi.SubnetInfo)
	for _, subnetInfo := range networkInfo.Subnets {
		subnetByID[subnetInfo.ID] = subnetInfo
	}

	for _, subnetID := range subnetIDs {
		subnet, ok := subnetByID[subnetID]
		if !ok {
			return res, fmt.Errorf("subnet %s not found in network %s", subnetID, cluster.Spec.Networking.NetworkID)
		}

		if res[subnet.Zone] != "" {
			return res, fmt.Errorf("subnet %s and %s have the same zone", subnetID, res[subnet.Zone])
		}
		res[subnet.Zone] = subnetID
	}
	return res, nil
}

func setupControlPlane(opt *NewClusterOptions, cluster *api.Cluster, zoneToSubnetsMap map[string][]*api.ClusterSubnetSpec) ([]*api.InstanceGroup, error) {
	cloudProvider := cluster.GetCloudProvider()

	var controlPlanes []*api.InstanceGroup

	// Build the control-plane subnets.
	// The control-plane zones is the default set of zones unless explicitly set.
	// The control-plane count is the number of control-plane zones unless explicitly set.

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify each subnet ID exists in the network: `openstack subnet list --network <network-id>` and correct the flag values.
  2. If the network ID is wrong, pass the correct one via --network so the subnets resolve.
  3. Remove or replace subnets that belong to other projects/networks; ensure the OpenStack credentials can see the target project.
  4. Use a shared network/subnet properly (RBAC) if the subnets intentionally live in another project.

Example fix

// before
kops create cluster ... --network net-1234 --zones nova-a --os-subnet-id wrong-subnet
// after
openstack subnet list --network net-1234   # pick an ID actually in net-1234
kops create cluster ... --network net-1234 --os-subnet-id <subnet-in-net-1234>
Defensive patterns

Strategy: validation

Validate before calling

openstack subnet list --network <NETWORK_ID>  # ensure every --os-subnet-id appears here before create

Try / catch

if err := createCluster(); err != nil && strings.Contains(err.Error(), "not found in network") { /* re-check subnet IDs vs network ID, correct flags, retry once */ }

Prevention

When it happens

Trigger: Running `kops create cluster` against OpenStack with --network (NetworkID) set and subnet IDs (via zones/subnet flags wired through setupZones or setupTopology) that do not belong to the specified network: a typo in the subnet ID, a subnet from a different network/project, or a subnet that was deleted before cluster creation.

Common situations: Copy-pasting a subnet ID from another OpenStack project or region; specifying a subnet belonging to a different Neutron network than the one given; stale documentation/scripts referencing a deleted subnet; confusion between subnet name and subnet ID.

Related errors


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