kubernetes/kops · error

InstanceGroup #%d did not have a Name

Error message

InstanceGroup #%d did not have a Name

What it means

CreateClusterConfig validates the instance groups before persisting the cluster config. Every InstanceGroup must have a non-empty ObjectMeta.Name; if the group at index i+1 has an empty name, this error is thrown. The name is required because instance groups are stored as named cluster resources and referenced by cluster templating.

Source

Thrown at pkg/apis/kops/registry/helpers.go:35

package registry

import (
	"context"
	"fmt"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	api "k8s.io/kops/pkg/apis/kops"
	"k8s.io/kops/pkg/client/simple"
	"k8s.io/kops/pkg/kubemanifest"
)

func CreateClusterConfig(ctx context.Context, clientset simple.Clientset, cluster *api.Cluster, groups []*api.InstanceGroup, addons kubemanifest.ObjectList) error {
	// Check for instancegroup Name duplicates before writing
	{
		names := map[string]bool{}
		for i, ns := range groups {
			if ns.ObjectMeta.Name == "" {
				return fmt.Errorf("InstanceGroup #%d did not have a Name", i+1)
			}
			if names[ns.ObjectMeta.Name] {
				return fmt.Errorf("duplicate InstanceGroup Name found: %q", ns.ObjectMeta.Name)
			}
			names[ns.ObjectMeta.Name] = true
		}
	}

	_, err := clientset.CreateCluster(ctx, cluster)
	if err != nil {
		return err
	}

	for _, ig := range groups {
		_, err = clientset.InstanceGroupsFor(cluster).Create(ctx, ig, metav1.CreateOptions{})
		if err != nil {
			return fmt.Errorf("error writing updated instancegroup configuration: %v", err)
		}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set ObjectMeta.Name on every InstanceGroup before calling CreateClusterConfig (e.g. ig.Name = "nodes" or ig.ObjectMeta.Name = ...).
  2. If using `kops create cluster`, rely on its default IG names (master.*, nodes) instead of constructing groups by hand.
  3. Add a pre-submit check iterating groups and failing early on empty names with the index reported.
  4. If the group came from a YAML manifest, add `metadata: name: <ig-name>`.

Example fix

// before
groups := []*api.InstanceGroup{{Spec: api.InstanceGroupSpec{Role: api.InstanceGroupRoleNode}}}
// after
groups := []*api.InstanceGroup{{ObjectMeta: metav1.ObjectMeta{Name: "nodes"}, Spec: api.InstanceGroupSpec{Role: api.InstanceGroupRoleNode}}}
Defensive patterns

Strategy: validation

Validate before calling

func requireIGNames(groups []*api.InstanceGroup) error {
	for i, ig := range groups {
		if ig == nil || ig.ObjectMeta.Name == "" {
			return fmt.Errorf("InstanceGroup #%d missing Name", i+1)
		}
	}
	return nil
}

Try / catch

if err := kopsregistry.CreateClusterConfig(ctx, cs, cluster, groups, addons); err != nil {
	if strings.Contains(err.Error(), "did not have a Name") {
		return fmt.Errorf("fix group construction: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Calling CreateClusterConfig (from RunCreateCluster, i.e. `kops create cluster`) with a groups slice containing an api.InstanceGroup whose ObjectMeta.Name is "" — e.g. building IGs programmatically and forgetting to set Name, or a template/manifest with a missing `metadata.name`.

Common situations: Programmatic cluster creation via the kops API where IG structs are constructed manually; generating instance groups in a script and leaving the name field blank; YAML manifests for `kops replace -f` style flows missing metadata.name.

Related errors


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