kubernetes/kops · error

method CreateCluster not supported in server-side client

Error message

method CreateCluster not supported in server-side client

What it means

The controller's server-side clientset is read-oriented: it serves data from the running cluster's state store and intentionally does not implement cluster creation. CreateCluster is a stub that always returns this error, satisfying the kopsclientset interface without providing VFS write semantics.

Source

Thrown at cmd/kops-controller/pkg/controllerclientset/clientset.go:87

	if err != nil {
		return nil, fmt.Errorf("error parsing %v: %w", p, err)
	}

	cluster, ok := object.(*kops.Cluster)
	if !ok {
		return nil, fmt.Errorf("unexpected kind for cluster, got %T, want kops.Cluster", object)
	}
	return cluster, nil
}

// VFSContext returns a VFSContext.
func (c *client) VFSContext() *vfs.VFSContext {
	return c.vfsContext
}

// CreateCluster creates a cluster
func (c *client) CreateCluster(ctx context.Context, cluster *kops.Cluster) (*kops.Cluster, error) {
	return nil, fmt.Errorf("method CreateCluster not supported in server-side client")
}

// UpdateCluster updates a cluster
func (c *client) UpdateCluster(ctx context.Context, cluster *kops.Cluster, status *kops.ClusterStatus) (*kops.Cluster, error) {
	return nil, fmt.Errorf("method UpdateCluster not supported in server-side client")
}

// ListClusters returns all clusters
func (c *client) ListClusters(ctx context.Context, options metav1.ListOptions) (*kops.ClusterList, error) {
	return nil, fmt.Errorf("method ListClusters not supported in server-side client")
}

// ConfigBaseFor returns the vfs path where we will read configuration information from
func (c *client) ConfigBaseFor(cluster *kops.Cluster) (vfs.Path, error) {
	return nil, fmt.Errorf("method ConfigBaseFor not supported in server-side client")
}

// InstanceGroupsFor returns the InstanceGroupInterface bound to the namespace for a particular Cluster

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Do not create clusters from kops-controller; use the `kops` CLI against the same state store instead
  2. If cluster creation is genuinely required in-process, use a real clientset backed by VFS (kopsclientset.NewVFSClients) rather than the server-side one
  3. Restructure the code so creation happens in an operator/CLI step before the controller starts

Example fix

// before
cluster, err := client.CreateCluster(ctx, clusterDef)
// after: creation must happen via CLI/VFS clientset, not server-side client
// $ kops create -f cluster.yaml && kops update cluster
cluster, err := client.GetCluster(ctx, clusterPath)
Defensive patterns

Strategy: try-catch

Validate before calling

if _, isServerSide := client.(*controllerclientset.Client); isServerSide {
  return errors.New("CreateCluster is not available on the server-side clientset; use the kops CLI")
}

Type guard

func supportsClusterCreate(c kopsinterfaces.Kopsclientset) bool {
  _, vfsBased := c.(*kopsclientset.VFSClients)
  return vfsBased
}

Try / catch

created, err := client.CreateCluster(ctx, cluster)
if err != nil && strings.Contains(err.Error(), "not supported in server-side client") {
  // fall back to CLI: os/exec kops create -f cluster.yaml
  return runKopsCreate(ctx, cluster)
}

Prevention

When it happens

Trigger: Any code path in the controller invoking client.CreateCluster(ctx, cluster) on the server-side clientset, e.g. code ported from the CLI that tries to provision a new cluster from within kops-controller.

Common situations: Reusing kops library code (designed for `kops create cluster`) inside the controller; adding a controller feature that bootstraps clusters instead of managing an existing one.

Related errors


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