Mega Menu

Saturday, March 07, 2020

YAML Basic example

YAML

A definition language used by Kubernetes to create and manage the configurations. Primarily yaml consists of three types of fields -

1. Key-Value Pairs

eg: name: test
      age: 00 

      Positioning of the elements is quite important in yaml. name and age elements should start at the same position.
     All values should have a space after colon (:) 

2. Array
         hyphen (-) indicates an element of an array
eg: Fruits:
      -  Apple
      -  Mango 
      -  Banana
      Vegetables:
       -  Carrot
       -  Tomato

3. Dictionary/Map

eg: Employee:
          Name: employeeOne
          Sex: Male
          Age: 30
          Title: Systems Engineer


An example of YAML file with list of dictionaries
    Employee:
        Name: employeeOne
        Sex: Male
        Age: 30
        Title: Systems Engineer
    Projects:
    -  Digital
    -  Retail
    Payslips:
    -  Month: June
       Wage: 4000
    -  Month: July
       Wage: 4500
    -  Month: August
       Wage: 4000

 

No comments:

Post a Comment