kubernetes/kops · error
failed to parse spec.template.spec from Deployment: %v
Error message
failed to parse spec.template.spec from Deployment: %v
What it means
After confirming exactly one Deployment, Remap reparses the nested spec.template.spec into a corev1.PodSpec via the flexible reparser. If the manifest's Deployment lacks that path or its YAML cannot be decoded into a PodSpec, Reparse errors and this wrapped error is returned.
Source
Thrown at pkg/model/components/addonmanifests/dnscontroller/remap.go:52
var deployments []*kubemanifest.Object
for _, object := range objects {
if object.Kind() != "Deployment" {
continue
}
if object.APIVersion() != "apps/v1" {
continue
}
deployments = append(deployments, object)
}
if len(deployments) != 1 {
return fmt.Errorf("expected exactly one Deployment in dns-controller manifest, found %d", len(deployments))
}
podSpec := &corev1.PodSpec{}
if err := deployments[0].Reparse(podSpec, "spec", "template", "spec"); err != nil {
return fmt.Errorf("failed to parse spec.template.spec from Deployment: %v", err)
}
containers := podSpec.Containers
if len(containers) != 1 {
return fmt.Errorf("expected exactly one container in dns-controller Deployment, found %d", len(containers))
}
if err := iam.AddServiceAccountRole(&context.IAMModelContext, podSpec, &ServiceAccount{}); err != nil {
return err
}
if err := deployments[0].Set(podSpec, "spec", "template", "spec"); err != nil {
return err
}
return nil
}
View on GitHub (pinned to 4c8573c808)
Solutions
- Restore the original bundled dns-controller manifest so spec.template.spec matches the expected corev1.PodSpec schema.
- Validate the Deployment YAML structure (spec.template.spec.containers present) before updating the cluster.
- Upgrade/downgrade kops to the version matching the addon manifest bundle.
Example fix
// before (invalid manifest)
spec:
template: {}
// after
spec:
template:
spec:
containers:
- name: dns-controller
... Defensive patterns
Strategy: type-guard
Validate before calling
var deploy appsv1.Deployment
if err := yaml.Unmarshal(manifestSection, &deploy); err != nil {
return err
}
if deploy.Spec.Template.Spec.Containers == nil {
return fmt.Errorf("deployment %q lacks spec.template.spec.containers", deploy.Name)
} Type guard
func hasPodSpec(d *appsv1.Deployment) bool {
return d.Spec.Template.Spec.Containers != nil
} Prevention
- Keep spec.template.spec intact when editing addon manifests.
- Lint manifests against the corev1.PodSpec schema.
- Restore stock manifests after failed manual edits.
When it happens
Trigger: A dns-controller manifest Deployment whose template pod spec is missing, renamed, or structurally invalid when running `kops update cluster` remapping of addon images.
Common situations: Hand-edited manifests with modified podSpec fields; addon manifests from incompatible kops versions; malformed YAML indentation under spec.template.spec.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- expected exactly one Deployment in dns-controller manifest,
- failed to parse manifest: %w
- error parsing addons or manifest: %v
- error parsing addons: %v
- failed to parse objects: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/f06d7e309402ee53.
Report an issue: GitHub.