{"record":{"id":"860f7bf029d92202","repo":"k3s-io/k3s","slug":"value-required-for-kubelet-arg-s","errorCode":null,"errorMessage":"value required for kubelet-arg --%s","messagePattern":"value required for kubelet-arg --(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/daemons/agent/agent.go","lineNumber":128,"sourceCode":"\t\t\tcontinue\n\t\t}\n\n\t\tvar val string\n\t\tkey := strings.TrimPrefix(extraArgs[i], \"--\")\n\t\tif k, v, ok := strings.Cut(key, \"=\"); ok {\n\t\t\t// key=val pair\n\t\t\tkey = k\n\t\t\tval = v\n\t\t} else if len(extraArgs) > i+1 {\n\t\t\t// key in this arg, value in next arg\n\t\t\tval = extraArgs[i+1]\n\t\t\tskipVal = true\n\t\t}\n\n\t\tswitch key {\n\t\tcase \"config\", \"config-dir\":\n\t\t\tif val == \"\" {\n\t\t\t\treturn nil, fmt.Errorf(\"value required for kubelet-arg --%s\", key)\n\t\t\t}\n\t\t\tstrippedArgs[key] = val\n\t\tdefault:\n\t\t\targs = append(args, extraArgs[i])\n\t\t}\n\t}\n\n\t// copy the config file into our managed config dir, unless its already in there\n\tif strippedArgs[\"config\"] != \"\" && !strings.HasPrefix(strippedArgs[\"config\"], path) {\n\t\tsrc := strippedArgs[\"config\"]\n\t\tdest := filepath.Join(path, \"10-cli-config.conf\")\n\t\tif err := agentutil.CopyFile(src, dest, false); err != nil {\n\t\t\treturn nil, errors.WithMessagef(err, \"copy config %q into managed drop-in dir %q\", src, dest)\n\t\t}\n\t}\n\t// copy the config-dir into our managed config dir, unless its already in there\n\tif strippedArgs[\"config-dir\"] != \"\" && !strings.HasPrefix(strippedArgs[\"config-dir\"], path) {\n\t\tsrc := strippedArgs[\"config-dir\"]","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/k3s-io/k3s/blob/6ba341e396edc16b8dcae978a7c5e3ac7ee5606e/pkg/daemons/agent/agent.go#L110-L146","documentation":"When starting the agent, k3s parses each --kubelet-arg value as either key=val or key followed by the value in the next list element. The keys `config` and `config-dir` are special-cased (k3s copies the referenced kubelet config into its managed dir), and they must carry a non-empty value. A bare or empty-valued `config`/`config-dir` entry aborts agent startup.","triggerScenarios":"`--kubelet-arg config` as the last item in the list (no next element to use as value), `--kubelet-arg config=`, or a YAML config with `kubelet-arg: [\"config\"]` / `kubelet-arg: [\"config=\"]` (pkg/daemons/agent/agent.go:120-130).","commonSituations":"Operator intends to point kubelet at a custom config file but forgets the value; YAML list item written with wrong quoting so the `=` part is lost; trailing empty element from a template.","solutions":["Provide the value: `--kubelet-arg config=/etc/kubernetes/kubelet-config.yaml` (or the key item followed by its value item).","Remove the bare `config`/`config-dir` entry entirely if no override is wanted - k3s generates its own kubelet config.","Check the YAML config quoting: write kubelet-arg entries as complete strings like \"config=/path\", not split items."],"exampleFix":"# before\nk3s agent --server https://server:6443 --kubelet-arg config\n# (or in /etc/rancher/k3s/config.yaml: kubelet-arg: [\"config\"])\n\n# after\nk3s agent --server https://server:6443 --kubelet-arg config=/etc/kubernetes/kubelet-config.yaml","handlingStrategy":"validation","validationCode":"// Validate kubelet-arg entries before launching the agent:\nfunc validateKubeletArgs(args []string) error {\n    for i := 0; i < len(args); i++ {\n        key, val, _ := strings.Cut(args[i], \"=\")\n        if val == \"\" && len(args) > i+1 { val = args[i+1] }\n        if (key == \"config\" || key == \"config-dir\") && strings.TrimSpace(val) == \"\" {\n            return fmt.Errorf(\"kubelet-arg %q needs a value\", key)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write kubelet-arg overrides as single 'key=value' strings.","Prefer kubelet configuration via the KubeletConfiguration manifest in the server's manifest dir where possible.","Test generated config files with a dry-run lint before rolling nodes."],"tags":["kubelet","configuration","cli","agent","k3s"],"backgroundTag":null,"analyzedSha":"6ba341e396edc16b8dcae978a7c5e3ac7ee5606e","analyzedAt":"2026-08-15T16:27:54.286Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}