kubernetes/kops · error

did not find floatingsubnet for external router

Error message

did not find floatingsubnet for external router

What it means

getExternalSubnet resolves the floating-IP subnet associated with the external router. It lists candidate subnets and requires exactly one match; if zero or more than one subnet is found, it returns the literal error "did not find floatingsubnet for external router". This is a configuration-ambiguity error, not an API failure.

Source

Thrown at upup/pkg/fi/cloudup/openstack/subnet.go:148

	return getExternalSubnet(c, c.extSubnetName)
}

func getExternalSubnet(c OpenstackCloud, subnetName *string) (subnet *subnets.Subnet, err error) {
	if subnetName == nil {
		return nil, nil
	}

	subnets, err := c.ListSubnets(subnets.ListOpts{
		Name: fi.ValueOf(subnetName),
	})
	if err != nil {
		return nil, err
	}

	if len(subnets) == 1 {
		return &subnets[0], nil
	}
	return nil, fmt.Errorf("did not find floatingsubnet for external router")
}

func (c *openstackCloud) GetLBFloatingSubnet() (subnet *subnets.Subnet, err error) {
	return getLBFloatingSubnet(c, c.floatingSubnet)
}

func getLBFloatingSubnet(c OpenstackCloud, floatingSubnet *string) (subnet *subnets.Subnet, err error) {
	if floatingSubnet == nil {
		return nil, nil
	}

	subnets, err := c.ListSubnets(subnets.ListOpts{
		Name: fi.ValueOf(floatingSubnet),
	})
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Explicitly configure the floating subnet in the cluster spec (extFloatingSubnet/floating subnet fields) so only one matches
  2. Ensure the external network has exactly one subnet, or narrow the filter via cluster config
  3. Run `openstack network show <extnet>` / `openstack subnet list --network <extnet>` to inspect candidates
  4. Update the cluster spec and re-run kops

Example fix

// before (cluster.yaml)
spec:
  network:
    externalNetwork: public
// after: pin the exact floating subnet
spec:
  network:
    externalNetwork: public
    extFloatingSubnet: public-subnet-1
Defensive patterns

Strategy: validation

Validate before calling

// Require exactly one floating subnet match before invoking kops
subnets, err := execCmdJSON("openstack", "subnet", "list", "--network", extNetworkID)
if err != nil || len(subnets) != 1 {
	log.Fatalf("external network %s must have exactly one subnet, got %d", extNetworkID, len(subnets))
}

Try / catch

sub, err := GetExternalSubnet(cloud)
if err != nil {
	if strings.Contains(err.Error(), "did not find floatingsubnet for external router") {
		// fall back to explicit config in cluster spec
	}
	return err
}

Prevention

When it happens

Trigger: The external network has zero subnets, or multiple subnets match the configured filter, so len(subnets) != 1.

Common situations: Operator did not set the floating subnet in the cluster spec and the external network has several subnets; or the external network has no subnet at all; config key for the external router typo'd so filters match nothing.

Related errors


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