Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Terminal output
One invisible character can break your whole Kubernetes file. You run kubectl apply, and it says it found a character that cannot start any token. A token is a meaningful piece the parser reads, like a key or a value. And line 7 is your clue: that's where it choked.
$ kubectl apply -f deployment.yaml
error: error converting YAML to JSON:
yaml: line 7: found character that cannot start any tokenSame line, whitespace revealed
Here's the cause. YAML, a config format, uses indentation to show structure, and it allows only spaces for that indentation. On the left, the line looks perfectly normal. With whitespace shown on the right, the other lines start with dots, but this one starts with a tab.
VS Code settings.json
In VS Code, two settings prevent this. For YAML files, insertSpaces makes the Tab key type spaces, two per level here. And renderWhitespace set to all shows spaces as dots and tabs as arrows. Then replace the old tab with spaces and run kubectl apply again.
{
"editor.renderWhitespace": "all",
"[yaml]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
}
}YAML counts spaces. Tabs don't count.
When you see "cannot start any token," reveal your whitespace first, before anything else. YAML counts spaces. Tabs don't count.
