kubernetes/kops · error
error marshaling manifest to yaml: %v
Error message
error marshaling manifest to yaml: %v
What it means
The kube-apiserver model builds the kube-apiserver-healthcheck static pod manifest and converts it to versioned YAML via k8scodecs.ToVersionedYaml. If that marshaling fails, the model build aborts with "error marshaling manifest to yaml". This would only occur if the generated in-memory object cannot be encoded against any versioned scheme (internal inconsistency, invalid field values).
Source
Thrown at pkg/model/components/kubeapiserver/model.go:52
type KubeApiserverBuilder struct {
*model.KopsModelContext
Lifecycle fi.Lifecycle
AssetBuilder *assets.AssetBuilder
}
var _ fi.CloudupModelBuilder = &KubeApiserverBuilder{}
// Build creates the tasks relating to kube-apiserver
// Currently we only build the kube-apiserver-healthcheck sidecar
func (b *KubeApiserverBuilder) Build(c *fi.CloudupModelBuilderContext) error {
manifest, err := b.buildManifest()
if err != nil {
return err
}
manifestYAML, err := k8scodecs.ToVersionedYaml(manifest)
if err != nil {
return fmt.Errorf("error marshaling manifest to yaml: %v", err)
}
key := "kube-apiserver-healthcheck"
location := "manifests/static/" + key + ".yaml"
c.AddTask(&fitasks.ManagedFile{
Contents: fi.NewBytesResource(manifestYAML),
Lifecycle: b.Lifecycle,
Location: new(location),
Name: new("manifests-static-" + key),
})
b.AssetBuilder.AddStaticManifest(&assets.StaticManifest{
Key: key,
Path: location,
Contents: manifestYAML,
Roles: []kops.InstanceGroupRole{kops.InstanceGroupRoleControlPlane, kops.InstanceGroupRoleAPIServer},
})View on GitHub (pinned to 4c8573c808)
Solutions
- Read the inner %v error to identify the offending field, then fix that field in the cluster spec
- Upgrade kOps to the latest release; this is usually an internal encoding bug fixed upstream
- Validate the cluster spec with `kops toolbox template` / dry-run to isolate the bad value
- File an upstream issue with the cluster spec if reproducible
Defensive patterns
Strategy: try-catch
Try / catch
// Caller wrapping the kube-apiserver model build
if err := model.Build(ctx); err != nil {
if strings.Contains(err.Error(), "error marshaling manifest to yaml") {
return fmt.Errorf("healthcheck manifest encode failed — inspect cluster spec values: %w", err)
}
return err
} Prevention
- Keep kOps current; encoding failures are usually upstream bugs
- Avoid exotic resource quantities/field values in the cluster spec
- Capture the inner %v error text when reporting issues
When it happens
Trigger: kops update cluster reaching the kube-apiserver model's Build with a manifest containing fields the codec rejects — typically a kOps internal bug or invalid spec values that leak into the healthcheck pod.
Common situations: Hit during kOps upgrades when component templates change, or with exotic cluster specs that produce invalid pod fields.
Related errors
- error parsing addons or manifest: %v
- failed to parse objects: %w
- failed to parse objects: %w
- parsing yaml: %w
- error parsing addon %q: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/622e6dde0adc119c.
Report an issue: GitHub.