{"record":{"id":"0fbe2e717bfdd867","repo":"kubernetes/kops","slug":"found-multiple-kubeschedulerconfiguration-objects","errorCode":null,"errorMessage":"found multiple KubeSchedulerConfiguration objects in cluster configuration; expected at most one","messagePattern":"found multiple KubeSchedulerConfiguration objects in cluster configuration; expected at most one","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/components/kubescheduler/model.go","lineNumber":76,"sourceCode":"\t})\n\treturn nil\n}\n\nfunc (b *KubeSchedulerBuilder) buildSchedulerConfig() ([]byte, error) {\n\tvar matches []*kubemanifest.Object\n\tfor _, additionalObject := range b.AdditionalObjects {\n\t\tgvk := additionalObject.GroupVersionKind()\n\t\tif gvk.Group != \"kubescheduler.config.k8s.io\" {\n\t\t\tcontinue\n\t\t}\n\t\tif gvk.Kind != \"KubeSchedulerConfiguration\" {\n\t\t\tcontinue\n\t\t}\n\t\tmatches = append(matches, additionalObject)\n\t}\n\n\tif len(matches) > 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple KubeSchedulerConfiguration objects in cluster configuration; expected at most one\")\n\t}\n\n\tvar config *unstructured.Unstructured\n\tif len(matches) == 1 {\n\t\tconfig = matches[0].ToUnstructured()\n\t} else {\n\t\tconfig = &unstructured.Unstructured{}\n\t\tconfig.SetKind(\"KubeSchedulerConfiguration\")\n\t\tconfig.SetAPIVersion(\"kubescheduler.config.k8s.io/v1\")\n\t\t// We need to store the object, because we are often called repeatedly (until we converge)\n\t\tb.AdditionalObjects = append(b.AdditionalObjects, kubemanifest.NewObject(config.Object))\n\t}\n\n\t// TODO: Handle different versions? e.g. gvk := config.GroupVersionKind()\n\n\tif err := unstructured.SetNestedField(config.Object, wellknownpaths.KubeSchedulerKubeConfig, \"clientConnection\", \"kubeconfig\"); err != nil {\n\t\treturn nil, fmt.Errorf(\"error setting clientConnection.kubeconfig in kube-scheduler configuration: %w\", err)\n\t}","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/components/kubescheduler/model.go#L58-L94","documentation":"buildSchedulerConfig scans b.AdditionalObjects for KubeSchedulerConfiguration objects (matching GVK) and requires at most one, since a single kube-scheduler component config is unambiguous. If more than one AdditionalObject has the KubeSchedulerConfiguration kind, the builder cannot pick one and returns this error.","triggerScenarios":"Passing two or more AdditionalObjects of kind KubeSchedulerConfiguration (apiVersion kubescheduler.config.k8s.io) into the KubeScheduler builder and calling Build → buildSchedulerConfig, e.g. from addons or task inputs that each add a scheduler config.","commonSituations":"A cluster addon and a user-supplied manifest both ship a KubeSchedulerConfiguration; a template renders the config twice; merging cluster specs duplicated the additional object.","solutions":["Remove duplicate KubeSchedulerConfiguration objects from AdditionalObjects so only one remains","Merge the two configs into a single KubeSchedulerConfiguration before passing it in","Verify which addon/task adds the extra object (inspect b.AdditionalObjects before Build) and drop the redundant one"],"exampleFix":"// before\nb.AdditionalObjects = append(b.AdditionalObjects, schedCfg1)\nb.AdditionalObjects = append(b.AdditionalObjects, schedCfg2)\n// after\nb.AdditionalObjects = append(b.AdditionalObjects, mergedSchedCfg)","handlingStrategy":"validation","validationCode":"count := 0\nfor _, o := range b.AdditionalObjects {\n    if o.GetKind() == \"KubeSchedulerConfiguration\" {\n        count++\n    }\n}\nif count > 1 {\n    return fmt.Errorf(\"%d KubeSchedulerConfiguration objects in AdditionalObjects; expected at most 1\", count)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep exactly one source of truth for the scheduler component config","Before Build, deduplicate AdditionalObjects by GVK+name","Audit addons for manifests that ship their own KubeSchedulerConfiguration"],"tags":["kube-scheduler","duplicate-resources","componentconfig","validation"],"backgroundTag":"duplicate-resource-config","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"}