kubernetes/kops · error

applying object to cluster: %w

Error message

applying object to cluster: %w

What it means

createKopsControlPlane applies the KopsControlPlane custom resource (controlplane.cluster.x-k8s.io/v1beta1) via server-side apply. This error wraps a failure of that Patch: typically the KopsControlPlane CRD is not installed, RBAC denies the apply, or the API server rejects the object.

Source

Thrown at pkg/controllers/clusterapi/cluster_controller.go:335

	}

	// TODO: Sync with LinkToNetwork
	obj := map[string]any{
		"apiVersion": "controlplane.cluster.x-k8s.io/v1beta1",
		"kind":       "KopsControlPlane",
		"metadata": map[string]any{
			"name":      name,
			"namespace": s.namespace(),
		},
		"spec": map[string]any{},
	}

	u := &unstructured.Unstructured{Object: obj}

	// setOwnerRef(u, s.Cluster)

	if err := s.ssa(ctx, kube, u); err != nil {
		return fmt.Errorf("applying object to cluster: %w", err)
	}

	// TODO: Sync with LinkToNetwork
	statusObj := map[string]any{
		"apiVersion": "controlplane.cluster.x-k8s.io/v1beta1",
		"kind":       "KopsControlPlane",
		"metadata": map[string]any{
			"name":      name,
			"namespace": s.namespace(),
		},
		"status": status,
	}

	if err := s.ssaStatus(ctx, kube, &unstructured.Unstructured{Object: statusObj}); err != nil {
		return fmt.Errorf("applying object to cluster: %w", err)
	}

	s.capiControlPlane = u

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Install or update the kops controlplane.cluster.x-k8s.io/v1beta1 CRDs on the management cluster
  2. Grant RBAC patch/update on kopscontrolplanes.resources in the controller role
  3. Check the wrapped error: 'no matches for kind' → CRD missing; Forbidden → RBAC; otherwise API-server validation detail
  4. Verify CRD apiVersion compatibility with the installed kops CAPI controller version

Example fix

# before
# CRDs not installed: kubectl apply fails with 'no matches for kind "KopsControlPlane"'
# after
kubectl apply -f clusterapi/controlplane/kops/config/crd/bases/
Defensive patterns

Strategy: validation

Validate before calling

// pre-flight: ensure CRD is installed
kubectl get crd kopscontrolplanes.controlplane.cluster.x-k8s.io
# expect: Established=True

Try / catch

if err := s.ssa(ctx, kube, u); err != nil {
    if apierrors.IsNotFound(err) || strings.Contains(err.Error(), "no matches for kind") {
        klog.Errorf("KopsControlPlane CRD not installed: %v", err)
    }
    return fmt.Errorf("applying object to cluster: %w", err)
}

Prevention

When it happens

Trigger: The controlplane.cluster.x-k8s.io/v1beta1 CRD is missing from the management cluster (no matches for kind); the controller's ServiceAccount lacks patch permission on kopscontrolplanes; the object fails validation; API server connectivity failure.

Common situations: Deploying the kops CAPI controller before installing/upgrading the kops CAPI CRDs; CRD version drift after a cluster-api upgrade; incomplete RBAC manifests in the Helm/manifest install.

Related errors


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