YAML is similar to Python in one very important way - indentation matters.
Kubernetes configs are written in YAML, and YAML is extremely strict about indentation (just like Python).
The CKA, CKS, CKAD exams are timebound & stressful.
So, you don’t want to waste time by encountering YAML errors.
Why do you need to change config?
By default, Vim inserts tab character (\t) when you press the tab key on your keyboard.
But Tabs (\t) are completely invalid in YAML.
Example error you’ll see:
found character '\t' that cannot start any token
So the rule is simple:
Always use spaces. Never tab.
Does YAML require 2 spaces or 4 spaces for indentation?
Both are valid. YAML only requires:
- consistent indentation
- spaces only
But 2 spaces in Kubernetes is widely used since official docs uses 2 spaces.
Config
Put this in your .vimrc:
set expandtab
set tabstop=2
set shiftwidth=2Settings explained:
- expandtab: use spaces for tab
- tabstop: amount of spaces used for tab
- shiftwidth: amount of spaces used during indentation
The above config will already be configured in your real exam environment in ~/.vimrc. But it’s never a bad idea to double check.
