kubernetes/kops · error

controlPlaneRef.kind not set for %v

Error message

controlPlaneRef.kind not set for %v

What it means

spec.controlPlaneRef.kind is empty on the CAPI Cluster object: the reference carries a name but no kind, so kOps cannot confirm it points at a KopsControlPlane before fetching it.

Source

Thrown at pkg/controllers/clusterapi/utils.go:121

	if err := kube.Get(ctx, clusterKey, cluster); err != nil {
		return nil, fmt.Errorf("error fetching cluster %v: %w", clusterKey, err)
	}

	return cluster, nil
}

func getKopsControlPlaneFromCAPICluster(ctx context.Context, kube client.Client, capiCluster *unstructured.Unstructured) (*v1beta1.KopsControlPlane, error) {
	capiClusterKey := types.NamespacedName{
		Namespace: capiCluster.GetNamespace(),
		Name:      capiCluster.GetName(),
	}
	name, _, _ := unstructured.NestedString(capiCluster.Object, "spec", "controlPlaneRef", "name")
	if name == "" {
		return nil, fmt.Errorf("controlPlaneRef.name not set for %v", capiClusterKey)
	}
	kind, _, _ := unstructured.NestedString(capiCluster.Object, "spec", "controlPlaneRef", "kind")
	if kind == "" {
		return nil, fmt.Errorf("controlPlaneRef.kind not set for %v", capiClusterKey)
	}
	if kind != "KopsControlPlane" {
		return nil, fmt.Errorf("controlPlaneRef.kind was %q for %v, expected KopsControlPlane", kind, capiClusterKey)
	}

	key := types.NamespacedName{
		Namespace: capiCluster.GetNamespace(),
		Name:      name,
	}

	// TODO: Add ip addresses to status

	kopsControlPlane := &v1beta1.KopsControlPlane{}
	if err := kube.Get(ctx, key, kopsControlPlane); err != nil {
		return nil, fmt.Errorf("error fetching KopsControlPlane %v: %w", key, err)
	}

	return kopsControlPlane, nil

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set controlPlaneRef.kind to KopsControlPlane in the CAPI Cluster spec
  2. Regenerate the CAPI manifests with a current kOps version
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/controllers/clusterapi/utils.go:121 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/8061fafd080cc90a. Report an issue: GitHub.