{"record":{"id":"89fbf4c9b22d7afd","repo":"kubernetes/kops","slug":"no-instance-groups-found","errorCode":null,"errorMessage":"no instance groups found","messagePattern":"no instance groups found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/components/apiserver.go","lineNumber":52,"sourceCode":"// KubeAPIServerOptionsBuilder adds options for the apiserver to the model\ntype KubeAPIServerOptionsBuilder struct {\n\t*OptionsContext\n}\n\nvar _ loader.ClusterOptionsBuilder = &KubeAPIServerOptionsBuilder{}\n\n// BuildOptions is responsible for filling in the default settings for the kube apiserver\nfunc (b *KubeAPIServerOptionsBuilder) BuildOptions(cluster *kops.Cluster) error {\n\tclusterSpec := &cluster.Spec\n\tif clusterSpec.KubeAPIServer == nil {\n\t\tclusterSpec.KubeAPIServer = &kops.KubeAPIServerConfig{}\n\t}\n\tc := clusterSpec.KubeAPIServer\n\n\tif c.APIServerCount == nil {\n\t\tcount := b.buildAPIServerCount(clusterSpec)\n\t\tif count == 0 {\n\t\t\treturn fmt.Errorf(\"no instance groups found\")\n\t\t}\n\t\tc.APIServerCount = new(int32(count))\n\t}\n\n\t// @question: should the question every be able to set this?\n\tif c.StorageBackend == nil {\n\t\t// @note: we can use the first version as we enforce both running the same versions.\n\t\t// albeit feels a little weird to do this\n\t\tsem, err := semver.Parse(strings.TrimPrefix(clusterSpec.EtcdClusters[0].Version, \"v\"))\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tc.StorageBackend = new(fmt.Sprintf(\"etcd%d\", sem.Major))\n\t}\n\n\tif c.KubeletPreferredAddressTypes == nil {\n\t\t// We prioritize the internal IP above the hostname\n\t\tc.KubeletPreferredAddressTypes = []string{","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/components/apiserver.go#L34-L70","documentation":"BuildOptions for the kube-apiserver component derives APIServerCount from the cluster's instance groups (essentially the number of control-plane groups). When buildAPIServerCount returns 0 — no instance groups are registered with the cluster — there is no basis to size the API server replication, so the model builder refuses to continue.","triggerScenarios":"Calling the apiserver component BuildOptions (e.g. during `kops update cluster` model rendering) when the cluster has zero instance groups attached, or when instance groups have not yet been created/applied for a new cluster.","commonSituations":"Provisioning a cluster programmatically via the API before any InstanceGroup (master) is added; a cluster manifest missing instanceGroups; a tool that edits cluster.spec without ever creating instance groups.","solutions":["Create at least one instance group with role Master before running update: `kops create instancegroup master-<zone> --role Master`","If using the Go API, attach InstanceGroup objects to the cluster before invoking the apiserver model builder","Explicitly set cluster.spec.kubeAPIServer.count if you must render the model without instance groups"],"exampleFix":"// before: updating a cluster with no instance groups\nkops update cluster mycluster.example.com\n// error: no instance groups found\n// after\nkops create instancegroup master-us-east-1a --role Master --zones us-east-1a\nkops update cluster mycluster.example.com","handlingStrategy":"validation","validationCode":"igs, err := clientset.InstanceGroupsFor(cluster).List(ctx, metav1.ListOptions{})\nif err != nil { return err }\nif len(igs.Items) == 0 {\n\treturn fmt.Errorf(\"create at least one instance group (role Master) before updating cluster %s\", cluster.Name)\n}","typeGuard":"func hasInstanceGroups(igs []*kops.InstanceGroup) bool { return len(igs) > 0 }","tryCatchPattern":"if err := buildModel(); err != nil {\n\tif strings.Contains(err.Error(), \"no instance groups found\") {\n\t\t// create master instance group, then retry once\n\t}\n\treturn err\n}","preventionTips":["Always run `kops create instancegroup ... --role Master` before the first `kops update cluster`","When scripting against the kops API, add instance groups to the cluster before invoking model builders","Validate cluster spec with `kops validate`/dry-run (--target dryrun) before real applies"],"tags":["cluster-config","instance-groups","kops"],"backgroundTag":"missing-instance-groups","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"}