YAML (YAML Ain’t Markup Language) is widely used for serialization and deserialization— which means converting data structures or object state into a format that can be stored or transmitted and then reconstructed later.
Its work in declarative format.
Example array data i want to convert to list..and this thing is not possible directly so we convert into common type then again convert to required format. Json also work in similar way.
Difference between Yaml and Json
YAML✅ Supports comments while Json ❌ No comment support
YAML is more human friendly while json is more machine friendly
YAML is using indentation for syntax while Json is bracket bases..
Most of pipeline and manifest file written in YAML.
We can use Json also in kubernetes but YAML is superset of Json.
YAML is case sensitive
YAML only have english, -, (dash), : (collan) so its easy to understand.
Manifest file we use camelCase latter only.
Yaml store in .yml or .YAML
You can check your yaml format in yamllint.com
if we use – (hyphen) then its list.
In YAML spacing is not an issue but alignment must be there. Ex below both are same even we have added many spaces in containerport. its just for looks better we give less space.
ports:
– containerport:
and
ports:
– containerport:
But for key value we need to give one space after colon(:)
key: value
— ( 3 dash) – we use to separate different document in one file like deployment and service.