{"record":{"id":"48a4dc012ee3ad71","repo":"kubernetes/kops","slug":"expected-exactly-one-object-in-manifest-s-found","errorCode":null,"errorMessage":"expected exactly one object in manifest %s, found %d","messagePattern":"expected exactly one object in manifest (.+?), found (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/components/etcdmanager/model.go","lineNumber":261,"sourceCode":"\n// buildPod creates the pod spec, based on the EtcdClusterSpec\nfunc (b *EtcdManagerBuilder) buildPod(etcdCluster kops.EtcdClusterSpec, instanceGroupName string) (*v1.Pod, error) {\n\tvar pod *v1.Pod\n\tvar container *v1.Container\n\n\tvar manifest []byte\n\n\t// TODO: pull from bundle\n\tbundle := \"(embedded etcd manifest)\"\n\tmanifest = []byte(defaultManifest)\n\n\t{\n\t\tobjects, err := model.ParseManifest(manifest)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif len(objects) != 1 {\n\t\t\treturn nil, fmt.Errorf(\"expected exactly one object in manifest %s, found %d\", bundle, len(objects))\n\t\t}\n\t\tif podObject, ok := objects[0].(*v1.Pod); !ok {\n\t\t\treturn nil, fmt.Errorf(\"expected v1.Pod object in manifest %s, found %T\", bundle, objects[0])\n\t\t} else {\n\t\t\tpod = podObject\n\t\t}\n\t}\n\n\tetcdVersions := etcdSupportedVersions()\n\tif etcdCluster.Image != \"\" {\n\t\t// With a custom image, only the selected version's binaries are made\n\t\t// available in the pod; restoring backups, which can require the\n\t\t// binaries of a bundled version, is not supported.\n\t\tetcdVersions = []etcdVersion{{Version: strings.TrimPrefix(etcdCluster.Version, \"v\"), Image: etcdCluster.Image}}\n\t}\n\n\tfor _, etcdVersion := range etcdVersions {\n\t\tif etcdVersion.SymlinkToVersion == \"\" {","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/components/etcdmanager/model.go#L243-L279","documentation":"buildPod parses the embedded etcd-manager manifest bundle (template YAML shipped with kops or referenced by the etcd cluster) and expects it to decode to exactly one Kubernetes object. A different count means the bundle YAML is not a single-object document, so the builder refuses to proceed.","triggerScenarios":"buildManifest -> buildPod when the manifest for the etcd-manager image bundle parses to 0 or 2+ objects — e.g. a multi-document YAML, an empty file, or a truncated template.","commonSituations":"Custom etcd-manager image/manifest overrides pointing at multi-object YAML; corrupted vendored template after partial build; users replacing the etcd-manager manifest with their own file containing ConfigMap+Pod.","solutions":["Point the manifest/image bundle at a YAML containing exactly one Pod object.","Split multi-document YAML and reference only the Pod document.","Restore the stock vendored etcd-manager template if it was modified or truncated.","Verify the file is not empty and parses: `kubectl create --dry-run=client -f manifest.yaml` should yield one Pod."],"exampleFix":"// before (manifest.yaml: two documents)\napiVersion: v1\nkind: ConfigMap\n---\napiVersion: v1\nkind: Pod\n// after (manifest.yaml: one document)\napiVersion: v1\nkind: Pod","handlingStrategy":"validation","validationCode":"objs, err := model.ParseManifest(bundle)\nif err != nil || len(objs) != 1 {\n\treturn fmt.Errorf(\"bundle %s must parse to exactly one object\", bundle)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify override manifests with `kubectl create --dry-run=client -f manifest.yaml` (expect one Pod).","Never point the bundle at multi-document YAML files.","Keep vendored templates pristine; apply changes via supported spec fields."],"tags":["kops","etcd-manager","manifest","validation"],"backgroundTag":"invalid-manifest-document-count","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"}