kubernetes/kops · error

Subnet with name %q not found

Error message

Subnet with name %q not found

What it means

Guard error from Subnet.RenderGCE when the spec marks the subnet as shared but Find() found no matching subnet (a == nil). Shared subnets must pre-exist and be adopted, so absence is fatal instead of triggering creation.

Source

Thrown at upup/pkg/fi/cloudup/gcetasks/subnet.go:117

	actual.Shared = e.Shared

	return actual, nil
}

func (e *Subnet) Run(c *fi.CloudupContext) error {
	return fi.CloudupDefaultDeltaRunMethod(e, c)
}

func (_ *Subnet) CheckChanges(a, e, changes *Subnet) error {
	return nil
}

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

	cloud := t.Cloud
	project := cloud.Project()

	if a == nil {
		klog.V(2).Infof("Creating Subnet with CIDR: %q", fi.ValueOf(e.CIDR))

		subnet := &compute.Subnetwork{
			IpCidrRange:    fi.ValueOf(e.CIDR),
			Name:           *e.Name,
			Network:        e.Network.URL(project),
			StackType:      fi.ValueOf(e.StackType),
			Ipv6AccessType: fi.ValueOf(e.Ipv6AccessType),
		}

		for k, v := range e.SecondaryIpRanges {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Verify the subnet name in the spec matches an existing GCE subnetwork in the right region/project
  2. Create the subnet in GCE manually first if adopting it
  3. Drop the shared flag so kOps creates and manages the subnet
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at upup/pkg/fi/cloudup/gcetasks/subnet.go:117 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/02ae47c32f0a94d4. Report an issue: GitHub.