{"record":{"id":"d08de77b0cad8566","repo":"kubernetes/kops","slug":"error-building-kubelet-flags-v","errorCode":null,"errorMessage":"error building kubelet flags: %v","messagePattern":"error building kubelet flags: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodeup/pkg/model/kubelet.go","lineNumber":473,"sourceCode":"// buildManifestDirectory creates the directory where kubelet expects static manifests to reside\nfunc (b *KubeletBuilder) buildManifestDirectory(kubeletConfig *kops.KubeletConfigSpec) (*nodetasks.File, error) {\n\tif kubeletConfig.PodManifestPath == \"\" {\n\t\treturn nil, fmt.Errorf(\"failed to build manifest path. Path was empty\")\n\t}\n\tdirectory := &nodetasks.File{\n\t\tPath: kubeletConfig.PodManifestPath,\n\t\tType: nodetasks.FileType_Directory,\n\t\tMode: s(\"0755\"),\n\t}\n\treturn directory, nil\n}\n\n// buildSystemdEnvironmentFile renders the environment file for the kubelet\nfunc (b *KubeletBuilder) buildSystemdEnvironmentFile(ctx context.Context, kubeletConfig *kops.KubeletConfigSpec) (*nodetasks.File, error) {\n\t// TODO: Dump the separate file for flags - just complexity!\n\tflags, err := flagbuilder.BuildFlags(kubeletConfig)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error building kubelet flags: %v\", err)\n\t}\n\n\tif b.UsesSecondaryIP() {\n\t\tlocalIP, err := b.GetMetadataLocalIP(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif localIP != \"\" {\n\t\t\tflags += \" --node-ip=\" + localIP\n\t\t}\n\t}\n\n\tif b.IsIPv6Only() {\n\t\tflags += \" --node-ip=::\"\n\t}\n\n\tflags += \" --config=\" + kubeletConfigFilePath\n","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/nodeup/pkg/model/kubelet.go#L455-L491","documentation":"buildSystemdEnvironmentFile renders /etc/sysconfig/kubelet by converting the KubeletConfigSpec struct into kubelet command-line flags via flagbuilder.BuildFlags. If the flag builder cannot serialize a field (unsupported type, reflection failure), the error is wrapped with \"error building kubelet flags: %v\".","triggerScenarios":"buildSystemdEnvironmentFile -> flagbuilder.BuildFlags(kubeletConfig) returns an error, typically a field on KubeletConfigSpec that flagbuilder cannot render to a --flag=value string.","commonSituations":"New kops spec fields added without corresponding flagbuilder support; unusual types (slices/maps) in the config that the reflection-based flag builder rejects; version skew between kops controller and nodeup binary.","solutions":["Read the wrapped underlying error to identify the failing field","Ensure the kops and nodeup binaries are the same version","Remove or correct the unsupported kubelet spec field","Upgrade kops to a version where the field's flag rendering is supported"],"exampleFix":"// before (mixed versions)\nkops update cluster --yes && nodeup-from-old-version\n// after (align versions)\nkops update cluster --yes && kops rolling-update cluster --yes # ships matching nodeup","handlingStrategy":"try-catch","validationCode":"// Dry-run flag rendering before writing the env file\nif _, err := flagbuilder.BuildFlags(kubeletConfig); err != nil {\n    return fmt.Errorf(\"kubelet flags cannot be rendered: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"flags, err := flagbuilder.BuildFlags(kubeletConfig)\nif err != nil {\n    return fmt.Errorf(\"check kubelet spec fields against your kops/nodeup version: %v\", err)\n}","preventionTips":["Run matching versions of kops and nodeup binaries","Test flag rendering in unit tests when adding new KubeletConfigSpec fields","Avoid setting experimental kubelet fields not supported by the installed kops version"],"tags":["kubelet","flags","nodeup","systemd"],"backgroundTag":"flag-build-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"}