kubernetes/kops · error

controlPlaneRef.name not set for %v

Error message

controlPlaneRef.name not set for %v

What it means

While resolving the control plane for a CAPI Cluster, spec.controlPlaneRef.name is empty on the CAPI cluster object; kOps cannot look up the KopsControlPlane resource without it.

Source

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

		return nil, fmt.Errorf("cluster ownerRef not set on CAPI cluster %v/%v", capiCluster.GetNamespace(), capiCluster.GetName())
	}

	cluster := &kopsapi.Cluster{}
	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 {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Set spec.controlPlaneRef.name (and kind) on the CAPI Cluster to the KopsControlPlane name
  2. Check the CAPI cluster manifest generated by kops for missing reference fields
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/controllers/clusterapi/utils.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/61d843dec89100f0. Report an issue: GitHub.