kubernetes/kops · error

method DeleteCluster not supported in server-side client

Error message

method DeleteCluster not supported in server-side client

What it means

The server-side (in-cluster) clientset intentionally does not implement cluster deletion: DeleteCluster on this client always returns this error. It is a permanent capability limitation by design, not a transient or input-dependent failure.

Source

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

		klog.Fatalf("clientset bound to cluster %q, got cluster %q", c.clusterName, clusterName)
	}

	return c.clusterKeystore, nil
}

// SSHCredentialStore builds the SSHCredential store for the specified cluster
func (c *client) SSHCredentialStore(cluster *kops.Cluster) (fi.SSHCredentialStore, error) {
	clusterName := cluster.Name
	if clusterName != c.clusterName {
		klog.Fatalf("clientset bound to cluster %q, got cluster %q", c.clusterName, clusterName)
	}

	return newSSHCredentialStore(c.clusterBasePath, cluster), nil
}

// DeleteCluster deletes all the state for the specified cluster
func (c *client) DeleteCluster(ctx context.Context, cluster *kops.Cluster) error {
	return fmt.Errorf("method DeleteCluster not supported in server-side client")
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Perform cluster deletion exclusively via the `kops delete cluster` CLI, with its confirmation flow
  2. If automated deletion is required, invoke the CLI from a dedicated job/operator, never from kops-controller
  3. Keep the controller strictly read/manage for an already-provisioned cluster

Example fix

// before
err := client.DeleteCluster(ctx, cluster)
// after: deletion is a CLI operation
// $ kops delete cluster --name mycluster.example.com --yes
Defensive patterns

Strategy: validation

Validate before calling

if isServerSideClientset(client) {
  return errors.New("cluster deletion must be done via `kops delete cluster` CLI with confirmation")
}

Try / catch

err := client.DeleteCluster(ctx, cluster)
if err != nil && strings.Contains(err.Error(), "DeleteCluster not supported") {
  // delegate to CLI with explicit --yes
  return exec.CommandContext(ctx, "kops", "delete", "cluster", "--name", cluster.Name, "--yes").Run()
}

Prevention

When it happens

Trigger: Calling client.DeleteCluster(ctx, cluster) from code running in kops-controller, e.g. a cleanup or lifecycle-management routine reusing CLI deletion logic.

Common situations: Porting `kops delete cluster` logic into an operator; adding an auto-cleanup feature to the controller.

Related errors


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