{"record":{"id":"1348ca242fdaa688","repo":"kubernetes/kops","slug":"error-marshaling-manifest-to-yaml-v-1348ca","errorCode":null,"errorMessage":"error marshaling manifest to yaml: %v","messagePattern":"error marshaling manifest to yaml: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodeup/pkg/model/kube_proxy.go","lineNumber":58,"sourceCode":"// Build is responsible for building the kube-proxy manifest\n// @TODO we should probably change this to a daemonset in the future and follow the kubeadm path\nfunc (b *KubeProxyBuilder) Build(c *fi.NodeupModelBuilderContext) error {\n\tif b.NodeupConfig.KubeProxy == nil {\n\t\tklog.V(2).Infof(\"Kube-proxy is disabled, will not create configuration for it.\")\n\t\treturn nil\n\t}\n\n\t{\n\t\tpod, err := b.buildPod()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error building kube-proxy manifest: %v\", err)\n\t\t}\n\n\t\tpod.ObjectMeta.Labels[\"kubernetes.io/managed-by\"] = \"nodeup\"\n\n\t\tmanifest, err := k8scodecs.ToVersionedYaml(pod)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error marshaling manifest to yaml: %v\", err)\n\t\t}\n\n\t\tc.AddTask(&nodetasks.File{\n\t\t\tPath:     \"/etc/kubernetes/manifests/kube-proxy.manifest\",\n\t\t\tContents: fi.NewBytesResource(manifest),\n\t\t\tType:     nodetasks.FileType_File,\n\t\t})\n\t}\n\n\t{\n\t\tvar kubeconfig fi.Resource\n\t\tvar err error\n\n\t\tif b.HasAPIServer {\n\t\t\tkubeconfig = b.BuildIssuedKubeconfig(\"kube-proxy\", nodetasks.PKIXName{CommonName: rbac.KubeProxy}, c)\n\t\t} else {\n\t\t\tkubeconfig, err = b.BuildBootstrapKubeconfig(\"kube-proxy\", c)\n\t\t\tif err != nil {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/nodeup/pkg/model/kube_proxy.go#L40-L76","documentation":"After KubeProxyBuilder.Build successfully builds the kube-proxy pod, it serializes it with k8scodecs.ToVersionedYaml before writing /etc/kubernetes/manifests/kube-proxy.manifest. Failure of that serialization is wrapped as 'error marshaling manifest to yaml'. Like the controller-manager equivalent, it means the pod object could not be converted to versioned YAML.","triggerScenarios":"k8scodecs.ToVersionedYaml(pod) returns an error — non-convertible fields on the pod object, nil required sub-objects (e.g. missing labels/containers populated incorrectly), or codec scheme issues in the nodeup build.","commonSituations":"kops/nodeup version skew causing pod fields not representable in the target manifest version; corrupted NodeupConfig values injected into the kube-proxy pod; nodeup bugs after upstream API bumps.","solutions":["Check the wrapped %v detail to identify the failing pod field","Align nodeup and kops versions (rebuild/re-deploy nodeup from the same release as kops)","Regenerate the node's NodeupConfig via `kops update cluster --yes`","Reproduce with `kops export kubecfg`/cluster inspection to find invalid kubeProxy values; file a kops issue if the config is valid"],"exampleFix":"// before (mixed versions)\nkops==1.28, nodeup binary from 1.26\n// after\nkops replace cluster ... ; kops update cluster --yes  # with a single kops version\n# rolling update replaces nodeup with the matching version","handlingStrategy":"try-catch","validationCode":"if pod == nil || pod.ObjectMeta.Labels == nil || len(pod.Spec.Containers) == 0 {\n    return fmt.Errorf(\"kube-proxy pod incomplete before yaml marshal\")\n}","typeGuard":"func isManifestMarshalErr(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"error marshaling manifest to yaml\")\n}","tryCatchPattern":"manifest, err := k8scodecs.ToVersionedYaml(pod)\nif err != nil {\n    return fmt.Errorf(\"error marshaling manifest to yaml: %v\", err)\n}\n// caller: if isManifestMarshalErr(err), dump the pod struct and check version skew","preventionTips":["Keep nodeup and kops versions in lockstep","Regenerate NodeupConfig after any kops upgrade","Validate kubeProxy config values (proxyMode, etc.) are supported for the target Kubernetes version","Capture the wrapped error detail to locate the offending pod field"],"tags":["go","kubernetes","nodeup","kube-proxy","yaml-marshaling"],"backgroundTag":"yaml-marshaling-failed","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"}