kubernetes/kops · error

Error creating router. Could not list external networks for

Error message

Error creating router.  Could not list external networks for gateway: %v

What it means

Router.RenderOpenstack, while creating a router, calls t.Cloud.GetExternalNetwork() to determine the floating/external network for the router gateway. If that lookup fails, the error is wrapped with this message, indicating the router could not be configured with an external gateway.

Source

Thrown at upup/pkg/fi/cloudup/openstacktasks/router.go:105

		if changes.AvailabilityZoneHints != nil {
			return fi.CannotChangeField("AvailabilityZoneHints")
		}
	}
	return nil
}

func (_ *Router) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *Router) error {
	if a == nil {
		klog.V(2).Infof("Creating Router with name:%q", fi.ValueOf(e.Name))

		opt := routers.CreateOpts{
			Name:                  fi.ValueOf(e.Name),
			AdminStateUp:          new(true),
			AvailabilityZoneHints: fi.StringSliceValue(e.AvailabilityZoneHints),
		}
		floatingNet, err := t.Cloud.GetExternalNetwork()
		if err != nil {
			return fmt.Errorf("Error creating router.  Could not list external networks for gateway: %v", err)
		}

		opt.GatewayInfo = &routers.GatewayInfo{
			NetworkID: floatingNet.ID,
		}

		routerFloatingSubnet, err := t.Cloud.GetExternalSubnet()
		if err != nil {
			return fmt.Errorf("Failed to find floatingip subnet: %v", err)
		}
		if routerFloatingSubnet != nil {
			opt.GatewayInfo.ExternalFixedIPs = []routers.ExternalFixedIP{
				{
					SubnetID: routerFloatingSubnet.ID,
				},
			}
		}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify an external network exists: `openstack network list --external` (needs router:external=True)
  2. Create or designate an external/floating network in the Openstack cloud if missing
  3. Check the cluster spec's external network configuration matches the cloud
  4. Grant the project access to the shared external network if visibility is the issue
  5. Inspect the wrapped error for API/auth failures and re-run kops

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

extNets, err := cloud.ListNetworks(networks.ListOpts{"router:external": true})
if err != nil || len(extNets) == 0 {
    return fmt.Errorf("no external network with router:external=True available for router gateway")
}

Try / catch

floatingNet, err := t.Cloud.GetExternalNetwork()
if err != nil {
    return fmt.Errorf("Error creating router.  Could not list external networks for gateway: %v", err)
} // fix cloud config (external network) before retrying

Prevention

When it happens

Trigger: Create path (a==nil) and GetExternalNetwork returns an error — no external network can be listed (none marked router:external, listing API error, or auth failure).

Common situations: Openstack deployment has no external network defined (no network with router:external=True); the project lacks visibility of the external network; Neutron API/credential issues; `externalNet` config mismatch in the kops cluster spec.

Related errors


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