kubernetes/kops · error

expected exactly one object in manifest %s, found %d

Error message

expected exactly one object in manifest %s, found %d

What it means

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.

Source

Thrown at pkg/model/components/etcdmanager/model.go:261

// buildPod creates the pod spec, based on the EtcdClusterSpec
func (b *EtcdManagerBuilder) buildPod(etcdCluster kops.EtcdClusterSpec, instanceGroupName string) (*v1.Pod, error) {
	var pod *v1.Pod
	var container *v1.Container

	var manifest []byte

	// TODO: pull from bundle
	bundle := "(embedded etcd manifest)"
	manifest = []byte(defaultManifest)

	{
		objects, err := model.ParseManifest(manifest)
		if err != nil {
			return nil, err
		}
		if len(objects) != 1 {
			return nil, fmt.Errorf("expected exactly one object in manifest %s, found %d", bundle, len(objects))
		}
		if podObject, ok := objects[0].(*v1.Pod); !ok {
			return nil, fmt.Errorf("expected v1.Pod object in manifest %s, found %T", bundle, objects[0])
		} else {
			pod = podObject
		}
	}

	etcdVersions := etcdSupportedVersions()
	if etcdCluster.Image != "" {
		// With a custom image, only the selected version's binaries are made
		// available in the pod; restoring backups, which can require the
		// binaries of a bundled version, is not supported.
		etcdVersions = []etcdVersion{{Version: strings.TrimPrefix(etcdCluster.Version, "v"), Image: etcdCluster.Image}}
	}

	for _, etcdVersion := range etcdVersions {
		if etcdVersion.SymlinkToVersion == "" {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Point the manifest/image bundle at a YAML containing exactly one Pod object.
  2. Split multi-document YAML and reference only the Pod document.
  3. Restore the stock vendored etcd-manager template if it was modified or truncated.
  4. Verify the file is not empty and parses: `kubectl create --dry-run=client -f manifest.yaml` should yield one Pod.

Example fix

// before (manifest.yaml: two documents)
apiVersion: v1
kind: ConfigMap
---
apiVersion: v1
kind: Pod
// after (manifest.yaml: one document)
apiVersion: v1
kind: Pod
Defensive patterns

Strategy: validation

Validate before calling

objs, err := model.ParseManifest(bundle)
if err != nil || len(objs) != 1 {
	return fmt.Errorf("bundle %s must parse to exactly one object", bundle)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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