kubernetes/kops · error
error marshaling manifest to yaml: %v
Error message
error marshaling manifest to yaml: %v
What it means
After building the etcd-manager Pod manifest, the builder converts it to a versioned YAML with k8scodecs.ToVersionedYaml and wraps any failure. This means the in-memory Pod object could not be serialized to YAML — a marshaling failure of a struct that is normally always serializable, so the underlying error (from %v) is the real cause.
Source
Thrown at pkg/model/components/etcdmanager/model.go:116
for _, etcdCluster := range b.Cluster.Spec.EtcdClusters {
backupStore := ""
if etcdCluster.Backups != nil {
backupStore = etcdCluster.Backups.BackupStore
}
if backupStore == "" {
return fmt.Errorf("backupStore must be set for use with etcd-manager")
}
for _, member := range etcdCluster.Members {
instanceGroupName := fi.ValueOf(member.InstanceGroup)
manifest, err := b.buildManifest(etcdCluster, instanceGroupName)
if err != nil {
return err
}
manifestYAML, err := k8scodecs.ToVersionedYaml(manifest)
if err != nil {
return fmt.Errorf("error marshaling manifest to yaml: %v", err)
}
name := fmt.Sprintf("%s-%s", etcdCluster.Name, instanceGroupName)
c.AddTask(&fitasks.ManagedFile{
Contents: fi.NewBytesResource(manifestYAML),
Lifecycle: b.Lifecycle,
Location: new("manifests/etcd/" + name + ".yaml"),
Name: new("manifests-etcdmanager-" + name),
})
}
info := &etcdClusterSpec{
EtcdVersion: etcdCluster.Version,
MemberCount: int32(len(etcdCluster.Members)),
}
d, err := json.MarshalIndent(info, "", " ")
if err != nil {View on GitHub (pinned to 4c8573c808)
Solutions
- Read the wrapped %v cause and fix the offending field in the etcd cluster spec / image override it points at.
- Ensure kOps dependencies (k8s.io/apimachinery, k8s.io/api) are consistent: `make gomod` after dependency changes.
- Upgrade or rebuild kops so the bundled etcd-manager manifest template matches the installed k8s codecs.
- Run with --v=2+ to capture which manifest (bundle) failed and file an issue if it reproduces with a stock template.
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := k8scodecs.ToVersionedYaml(manifest); err != nil {
return fmt.Errorf("manifest for %q not serializable: %w", etcdCluster.Name, err)
} Try / catch
if err := buildModel(); err != nil {
if strings.Contains(err.Error(), "error marshaling manifest to yaml") {
// inspect wrapped cause with --v=2 and fix the offending spec field
}
} Prevention
- Keep k8s.io/api and apimachinery versions aligned across the kOps module graph.
- Test custom manifest overrides locally with kubectl dry-run before cluster updates.
- Upgrade kops as one unit rather than cherry-picking dependencies.
When it happens
Trigger: buildManifest produces a Pod containing values the Kubernetes codec cannot marshal (e.g. malformed typed fields, custom object injected into the manifest) during `kops update cluster`.
Common situations: kOps/k8s.io/api version skew where ToVersionedYaml cannot map the Pod to a registered versioned type; corrupted or patched etcd-manager template manifest; custom builds with modified Pod structs.
Related errors
- unable to marshal YAML: %v
- error converting to yaml: %v
- marshaling to yaml for %v: %w
- error serializing addons yaml: %v
- error serializing addons: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/09ca09ad19169082.
Report an issue: GitHub.