kubernetes/kops · error
invalid topology %s
Error message
invalid topology %s
What it means
After handling public and private topology, setupTopology's switch falls through to default when --topology is any other value. This is the guard against invalid topology strings, echoing the value the user passed.
Source
Thrown at upup/pkg/fi/cloudup/new_cluster.go:1502
PublicName: "bastion." + cluster.Name,
}
}
if opt.IPv6 {
for _, s := range cluster.Spec.Networking.Subnets {
if s.Type == api.SubnetTypeDualStack {
bastionGroup.Spec.Subnets = append(bastionGroup.Spec.Subnets, s.Name)
}
}
}
if cluster.GetCloudProvider() == api.CloudProviderGCE {
bastionGroup.Spec.Zones = allZones.List()
}
bastionGroup.Spec.Image = opt.BastionImage
}
default:
return nil, fmt.Errorf("invalid topology %s", opt.Topology)
}
if opt.IPv6 {
cluster.Spec.Networking.NonMasqueradeCIDR = "::/0"
cluster.Spec.ExternalCloudControllerManager = &api.CloudControllerManagerConfig{}
if cluster.GetCloudProvider() == api.CloudProviderAWS {
for i := range cluster.Spec.Networking.Subnets {
cluster.Spec.Networking.Subnets[i].IPv6CIDR = fmt.Sprintf("/64#%x", i)
}
} else {
klog.Errorf("IPv6 support is available only on AWS")
}
}
return bastions, nil
}
func setupDNSTopology(opt *NewClusterOptions, cluster *api.Cluster) error {View on GitHub (pinned to 4c8573c808)
Solutions
- Use exactly --topology public or --topology private.
- Fix shell variables so the flag expands to a valid value, or drop the flag if the default is fine.
- Check `kops create cluster --help` for accepted topology values.
Example fix
// before kops create cluster my.cluster --topology $TOPOLOGY # TOPOLOGY empty -> "invalid topology " // after TOPOLOGY=private kops create cluster my.cluster --topology $TOPOLOGY
Defensive patterns
Strategy: validation
Validate before calling
case "$TOPOLOGY" in public|private) ;; *) echo "--topology must be public or private"; exit 1;; esac
Try / catch
if err := createCluster(); err != nil && strings.Contains(err.Error(), "invalid topology") { /* print the value, fix it, retry */ } Prevention
- Whitelist topology values in wrapper scripts
- Guard against unset variables defaulting the flag to empty
- Use lowercase values only
When it happens
Trigger: `kops create cluster --topology <invalid>` where <invalid> is anything other than "public" or "private" — e.g. a typo (`privte`), an empty value from a shell variable, or "federated" from a misunderstanding.
Common situations: Typos in scripts; unset shell variables expanding --topology ""; copying flags from other tools that support different topology names; case-sensitivity issues (Public vs public).
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- bastion supports --topology='private' only
- unknown DNSType: %q
- specified %d control-plane zones, but also requested %d cont
- unknown networking mode %q
- unknown topology type: %q
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/1f885ff75b9bda5d.
Report an issue: GitHub.