YAML(YAML Ain’t Markup Language) basics :-
1 min readSep 1, 2022
YAML is a serialization language like XML, JSON
# key-value pair
app: “user-authentication \n” #string quotes are not required but use it when there is special character usage
port: 9000
version: 1.7#object creation
microservice:
app: user-authentication # these are properties
port: 9000
version: 1.7
deployed: true # bool value# if we are using simple data types we can use `[]` for list
versions1: [1.9, 2.3, 4.5]
versions2:
- 1.9
- 2.3
- 4.5
# list of objects
microservices:
- app: user-authentication1
port: 9000
version: 1.7
deployed: true
- app: shopping-cart
port: 9001
version: 1.7
deployed: false # bool value
switch: on # bool value# multi line strings
multilineString : | #usage of pipe hints that multi line strings are used
this is line 1
this is line 2
this is line 3# for readability if we write in multi lines how to put in single line ?
# use >
singleLineString : >
this is single line
that should be above
this also should be in line 1# Using env variables in yaml
# $env
command:
- /bin/sh
- -ec
- >-
mysql -h 127.0.0.1 -u -p $MYSQL_ROOT_PASSWORD -e 'SELECT 1'# Using placeholders in YAML
# {{ placeholders }}
metadata:
name: {{ .Values.service.app }}# multi yaml files can be put into a single yaml file
# separated by ---
---
app: user-authentication1
port: 9000
version: 1.7