YAML Basics - neerajk555/Kubernetes GitHub Wiki
YAML (YAML Ain't Markup Language) is a human-friendly data serialization standard often used for configuration files. Below is a basic guide to get you started.
YAML Basics
Step-01: Comments & Key Value Pairs
- Space after colon is mandatory to differentiate key and value
# Defining simple key value pairs
name: James
age: 33
city: Mumbai
Step-02: Dictionary / Map
- Set of properties grouped together after an item
- Equal amount of blank space required for all the items under a dictionary
person:
name: James
age: 33
city: Mumbai
Step-03: Array / Lists
- Dash indicates an element of an array
person: # Dictionary
name: James
age: 33
city: Mumbai
hobbies: # List
- cycling
- cookines
hobbies: [cycling, cooking] # List with a differnt notation
Step-04: Multiple Lists
- Dash indicates an element of an array
person: # Dictionary
name: James
age: 33
city: Mumbai
hobbies: # List
- cycling
- cooking
hobbies: [cycling, cooking] # List with a differnt notation
friends: #
- name: friend1
age: 22
- name: friend2
age: 25
Step-05: Sample Pod Tempalte for Reference
apiVersion: v1 # String
kind: Pod # String
metadata: # Dictionary
name: myapp-pod
labels: # Dictionary
app: myapp
spec:
containers: # List
- name: myapp
image: nginx
ports:
- containerPort: 80
protocol: "TCP"
- containerPort: 81
protocol: "TCP"