kubernetes/kops · error

found multiple instance groups matching MIG %q

Error message

found multiple instance groups matching MIG %q

What it means

Returned by matchInstanceGroup when more than one kops InstanceGroup in the cluster spec matches the same GCE managed instance group, making the mapping ambiguous. GetCloudGroups cannot tell which kops instance group owns the MIG, so it fails rather than guess. This reflects inconsistent or duplicated cluster configuration.

Source

Thrown at upup/pkg/fi/cloudup/gce/instancegroups.go:296

	return s
}

// matchInstanceGroup filters a list of instancegroups for recognized cloud groups
func matchInstanceGroup(mig *compute.InstanceGroupManager, c *kops.Cluster, instancegroups []*kops.InstanceGroup) (*kops.InstanceGroup, error) {
	migName := LastComponent(mig.Name)
	var matches []*kops.InstanceGroup
	for _, ig := range instancegroups {
		name := NameForInstanceGroupManager(c.ObjectMeta.Name, ig.ObjectMeta.Name, LastComponent(mig.Zone))
		if name == migName {
			matches = append(matches, ig)
		}
	}

	if len(matches) == 0 {
		return nil, nil
	}
	if len(matches) != 1 {
		return nil, fmt.Errorf("found multiple instance groups matching MIG %q", mig.Name)
	}
	return matches[0], nil
}

func addCloudInstanceData(cm *cloudinstances.CloudInstance, instance *compute.Instance) {
	cm.MachineType = LastComponent(instance.MachineType)
	cm.Status = instance.Status
	if instance.Status == "RUNNING" {
		cm.State = cloudinstances.CloudInstanceStatusUpToDate
	}
	for k := range instance.Labels {
		if !strings.HasPrefix(k, GceLabelNameRolePrefix) {
			continue
		}
		role := strings.TrimPrefix(k, GceLabelNameRolePrefix)
		// A VM must have one network interface and at most a single AccessConfig on an network interface
		// Also kops doesn't support MultiNics
		cm.PrivateIP = fi.ValueOf(&instance.NetworkInterfaces[0].NetworkIP)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Dump the cluster spec (kops get ig <cluster> -o yaml) and remove/merge duplicate instance group entries.
  2. Ensure each kops InstanceGroup has a unique name; rename the copied one and re-apply (kops update cluster).
  3. Verify the MIG's kops-managed labels/name correspond to exactly one instance group; fix stale labels in GCP if edited manually.
  4. Re-run kops update cluster to reconcile the MIGs with the corrected spec, then retry the operation.

Example fix

// before (cluster spec)
metadata:
  name: nodes-a
  name: nodes-a   # duplicate
// after
metadata:
  name: nodes-a
metadata:
  name: nodes-b
Defensive patterns

Strategy: validation

Validate before calling

// pre-flight: assert every kops instance group name is unique and each MIG maps to exactly one group
names := map[string]int{}
for _, ig := range instancegroups {
    names[ig.ObjectMeta.Name]++
}
for name, n := range names {
    if n > 1 {
        log.Fatalf("instance group %q defined %d times in cluster spec", name, n)
    }
}

Type guard

func hasUniqueInstanceGroupNames(igs []*kops.InstanceGroup) bool {
    seen := map[string]bool{}
    for _, ig := range igs {
        if seen[ig.ObjectMeta.Name] {
            return false
        }
        seen[ig.ObjectMeta.Name] = true
    }
    return true
}

Try / catch

cloudGroups, err := gceCloud.GetCloudGroups(ctx, cluster, warnUnmatched, instancegroups)
if err != nil {
    if strings.Contains(err.Error(), "found multiple instance groups matching MIG") {
        log.Warn("duplicate kops instance groups match one MIG; deduplicate the cluster spec (kops get ig -o yaml) and re-apply")
    }
    return err
}

Prevention

When it happens

Trigger: Calling GetCloudGroups (indirectly via rolling-update, get, etc.) when the cluster spec contains two or more InstanceGroups whose names/tags both match mig.Name — e.g. duplicated group names, a MIG matching multiple groups by shared label/tag, or a copied instance group spec not fully renamed.

Common situations: Copy-pasting an instance group in the cluster spec and changing only some fields, exporting/re-importing cluster manifests producing duplicates, or MIGs with overly generic tags matching several groups.

Related errors


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