YAML (YAML Ain't Markup Language) is a human-readable data serialization language often used for configuration files and data exchang...
YAML (YAML Ain't Markup Language) is a human-readable data serialization language often used for configuration files and data exchange between languages. It's simple, clean, and structured. Here's a basic guide to get you started
1. Structure
- YAML uses indentation (spaces, not tabs) to define structure.
- Indentation represents nesting (hierarchical data).
2. Keys and Values
- YAML uses key-value pairs to store data.
- Keys are unique identifiers, and values can be text, numbers, booleans, or other data structu
.
2. Dictionaries (Key-Value Pairs)
- A dictionary is a collection of key-value pairs.
- Nested dictionaries can represent more complex structures
3. Lists
- A list in YAML is a sequence of values.
- Lists are represented using a hyphen (
-
)
4. Combining Dictionaries and Lists
Dictionaries and lists can be combined for more complex data structure
Here:
--> students is a list of dictionaries.
--> Each dictionary contains keys (name, age, subjects) and their values.
--> subjects is a nested list.
5. Arrays
- YAML doesn't explicitly define arrays but uses lists to achieve the same result
6. Multi-Line Strings
YAML supports multi-line values for keys.
Literal Block (Preserve Line Breaks):
Folded Block (Replace Line Breaks with Spaces):
7. Comments
8. Example Combining Everything
Here’s a full example that includes dictionaries, lists, and arrays
10. Best Practices
- Always use spaces (not tabs) for indentation.
- Maintain consistent indentation (e.g., 2 or 4 spaces).
- Use meaningful keys for readability.
Ready to dive deeper into Kubernetes workflows or advanced YAML techniques?