DevOps in K8s — YAML + Three Tricks to Write K8s Object File
YAML, which stands for “Yet Another Markup Language,” is a text-based format used for configuration data. Kubernetes (K8s) supports creating resource objects in both YAML and JSON formats, which facilitate message exchange between interfaces and are suitable for development. However, YAML has gained more widespread use and become the de facto standard in the K8s ecosystem.
Compared to JSON, YAML offers a more user-friendly format. Additionally, YAML is a superset of JSON, meaning that a YAML parser can interpret JSON, though the reverse may not be true. In general, YAML is visually easier to read, can reference other items, does not allow duplicate keys, and provides more features. These advantages have contributed to YAML becoming the default standard language for K8s.
Declarative vs Imperative
The YAML language used by K8s has a very key feature called “Declarative”, which corresponds to another word: “Imperative”. So before we get to know YAML in detail, we have to take a look at the two ways of working, “declarative“ vs “imperative“. Their relationship in the computer world is a bit like the “sword” and “aircraft” in the novel.