kubernetes/kops · error

must specify mode for (non-shared) Network

Error message

must specify mode for (non-shared) Network

What it means

Validation error from Network.CheckChanges. Mode is empty and Shared is false. An empty mode means 'keep existing' and is only permitted when adopting a shared network; a kOps-managed network must declare auto, custom, or legacy.

Source

Thrown at upup/pkg/fi/cloudup/gcetasks/network.go:130

			return fmt.Errorf("CIDR must specified for networks where mode=legacy")
		}
		klog.Warningf("using legacy mode for GCE network %q", fi.ValueOf(e.Name))
	default:
		if cidr != "" {
			return fmt.Errorf("CIDR cannot specified for networks where mode=%s", e.Mode)
		}
	}

	switch e.Mode {
	case "auto":
	case "custom":
	case "legacy":
		// Known

	case "":
		// Treated as "keep existing", only allowed for shared mode
		if !fi.ValueOf(e.Shared) {
			return fmt.Errorf("must specify mode for (non-shared) Network")
		}

	default:
		return fmt.Errorf("unknown mode %q for Network", e.Mode)
	}

	return nil
}

func (_ *Network) RenderGCE(t *gce.GCEAPITarget, a, e, changes *Network) error {
	shared := fi.ValueOf(e.Shared)
	if shared {
		// Verify the network was found
		if a == nil {
			return fmt.Errorf("Network with name %q not found", fi.ValueOf(e.Name))
		}
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set an explicit mode (auto, custom, or legacy) on the network in the cluster spec
  2. Or mark the network as shared if it is an existing network managed outside kOps
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/gcetasks/network.go:130 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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