{"record":{"id":"7a009eb6cb255c80","repo":"kubernetes/kops","slug":"method-createcluster-not-supported-in-server-side","errorCode":null,"errorMessage":"method CreateCluster not supported in server-side client","messagePattern":"method CreateCluster not supported in server-side client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops-controller/pkg/controllerclientset/clientset.go","lineNumber":87,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing %v: %w\", p, err)\n\t}\n\n\tcluster, ok := object.(*kops.Cluster)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unexpected kind for cluster, got %T, want kops.Cluster\", object)\n\t}\n\treturn cluster, nil\n}\n\n// VFSContext returns a VFSContext.\nfunc (c *client) VFSContext() *vfs.VFSContext {\n\treturn c.vfsContext\n}\n\n// CreateCluster creates a cluster\nfunc (c *client) CreateCluster(ctx context.Context, cluster *kops.Cluster) (*kops.Cluster, error) {\n\treturn nil, fmt.Errorf(\"method CreateCluster not supported in server-side client\")\n}\n\n// UpdateCluster updates a cluster\nfunc (c *client) UpdateCluster(ctx context.Context, cluster *kops.Cluster, status *kops.ClusterStatus) (*kops.Cluster, error) {\n\treturn nil, fmt.Errorf(\"method UpdateCluster not supported in server-side client\")\n}\n\n// ListClusters returns all clusters\nfunc (c *client) ListClusters(ctx context.Context, options metav1.ListOptions) (*kops.ClusterList, error) {\n\treturn nil, fmt.Errorf(\"method ListClusters not supported in server-side client\")\n}\n\n// ConfigBaseFor returns the vfs path where we will read configuration information from\nfunc (c *client) ConfigBaseFor(cluster *kops.Cluster) (vfs.Path, error) {\n\treturn nil, fmt.Errorf(\"method ConfigBaseFor not supported in server-side client\")\n}\n\n// InstanceGroupsFor returns the InstanceGroupInterface bound to the namespace for a particular Cluster","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops-controller/pkg/controllerclientset/clientset.go#L69-L105","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Do not create clusters from kops-controller; use the `kops` CLI against the same state store instead","If cluster creation is genuinely required in-process, use a real clientset backed by VFS (kopsclientset.NewVFSClients) rather than the server-side one","Restructure the code so creation happens in an operator/CLI step before the controller starts"],"exampleFix":"// before\ncluster, err := client.CreateCluster(ctx, clusterDef)\n// after: creation must happen via CLI/VFS clientset, not server-side client\n// $ kops create -f cluster.yaml && kops update cluster\ncluster, err := client.GetCluster(ctx, clusterPath)","handlingStrategy":"try-catch","validationCode":"if _, isServerSide := client.(*controllerclientset.Client); isServerSide {\n  return errors.New(\"CreateCluster is not available on the server-side clientset; use the kops CLI\")\n}","typeGuard":"func supportsClusterCreate(c kopsinterfaces.Kopsclientset) bool {\n  _, vfsBased := c.(*kopsclientset.VFSClients)\n  return vfsBased\n}","tryCatchPattern":"created, err := client.CreateCluster(ctx, cluster)\nif err != nil && strings.Contains(err.Error(), \"not supported in server-side client\") {\n  // fall back to CLI: os/exec kops create -f cluster.yaml\n  return runKopsCreate(ctx, cluster)\n}","preventionTips":["Treat the controller clientset as read/manage-only by design","Route all cluster creation through `kops create cluster` in CI or an operator","Check the interface implementation before assuming write support"],"tags":["go","unsupported-operation","kops","server-side-client"],"backgroundTag":"operation-not-supported-by-client","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}