kubernetes/kops · error

applying GCPCluster object to cluster: %w

Error message

applying GCPCluster object to cluster: %w

What it means

applyGCPCluster builds an unstructured GCPCluster object and applies it to the management cluster with server-side apply (ssa). Any failure from that apply (API errors, conflicts, RBAC, invalid fields) is wrapped with this message. It means the infrastructure GCPCluster resource could not be created or updated in the management cluster.

Source

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

		"metadata": map[string]any{
			"name":      name,
			"namespace": s.namespace(),
		},
		"spec": map[string]any{
			"project": gcpProject,
			"region":  gcpRegion,
			"network": map[string]any{
				"name": gcpNetworkName,
			},
		},
	}

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

	// setOwnerRef(u, s.Cluster)

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

	s.capiInfra = u
	return nil
}

func (s *clusterScope) findSystemEndpoints(ctx context.Context) ([]capikops.SystemEndpoint, error) {
	cluster := s.Cluster

	clusterInternal := &kops.Cluster{}
	if err := kopscodecs.Scheme.Convert(cluster, clusterInternal, nil); err != nil {
		return nil, fmt.Errorf("converting cluster object: %w", err)
	}

	cloud, err := cloudup.BuildCloud(clusterInternal)
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Install/upgrade the CAPG (Cluster API Provider GCP) CRDs in the management cluster
  2. Check the wrapped inner error: fix RBAC or field-manager conflict it reports
  3. Validate the generated GCPCluster fields against the CRD schema
Defensive patterns

Strategy: try-catch

Validate before calling

// verify CRD exists before applying
if err := kube.Get(ctx, client.ObjectKey{}, &apiextensionsv1.CustomResourceDefinition{ObjectMeta: metav1.ObjectMeta{Name: "gcpclusters.infrastructure.cluster.x-k8s.io"}}); err != nil {
	return fmt.Errorf("CAPG CRDs not installed: %w", err)
}

Try / catch

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

Prevention

When it happens

Trigger: clusterScope.Apply() calling s.ssa(ctx, kube, u) with the constructed GCPCluster unstructured object during reconciliation.

Common situations: infrastructure.cluster.x-k8s.io CRDs not installed (GCPCluster kind unknown); RBAC denying the controller; field manager conflicts from another controller owning fields; invalid field values rejected by the API server.

Related errors


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