1
00:00:00,000 --> 00:00:11,500
Hi let us understand about yaml file, within kubernetes we will be defining

2
00:00:11,500 --> 00:00:17,033
every object using this yaml that's a declarative way of defining how that

3
00:00:17,033 --> 00:00:22,299
particular object should behave and what are all its properties. Of course we

4
00:00:22,300 --> 00:00:28,600
do have other formats as well like XML or Json and comparatively yaml is much

5
00:00:28,600 --> 00:00:32,800
easier to understand for the human as well as for the computer systems

6
00:00:32,800 --> 00:00:36,800
understanding of the basics of yaml is much important because we are going to

7
00:00:36,800 --> 00:00:43,066
define every object for our demo using this yaml file. Yaml it's very simple where

8
00:00:43,066 --> 00:00:47,799
I am going to have collection of key-value pairs. When I say collection of key-value

9
00:00:47,800 --> 00:00:52,966
pairs it's like a map where a key is going to be a string and value could be

10
00:00:52,966 --> 00:00:57,799
anything right from a string or integer or it could be another complex object like a

11
00:00:57,800 --> 00:01:04,300
collection or in fact another map as well. Let's go over a few samples that's going

12
00:01:04,300 --> 00:01:09,533
to give us some clarity. In this particular example I do have a collection of map

13
00:01:09,533 --> 00:01:17,199
that is a key value pair with API version as key and V1 as value. The same way I do

14
00:01:17,200 --> 00:01:25,200
have another key value pair where kind is a key and value pod. Now instead of this

15
00:01:25,200 --> 00:01:30,466
particular value I can have another collection as well, the entire yaml file

16
00:01:30,466 --> 00:01:35,166
works based on the alignment of the text where I am going to have a regular

17
00:01:35,166 --> 00:01:40,999
interval between the text intent within the yaml file. Say for example within this

18
00:01:41,000 --> 00:01:47,700
particular file I do have two spaces and that particular aligned collection is going

19
00:01:47,700 --> 00:01:53,200
to be a child element for this particular element. Let's go over another sample

20
00:01:53,200 --> 00:01:59,600
here I do have a key value pair api version V1 kind as a key and pod as

21
00:01:59,600 --> 00:02:04,566
value. The next key is going to be metadata which is going to have another

22
00:02:04,566 --> 00:02:10,431
map as value and map is going to have a collection of key value pair, where name is

23
00:02:10,433 --> 00:02:16,699
the key my-site is value, if you look at only this particular block entire map is

24
00:02:16,700 --> 00:02:22,366
going to be a value for this particular key metadata and within this particular key

25
00:02:22,366 --> 00:02:28,666
value pair the first element that is name and my-site is one record within the map

26
00:02:28,666 --> 00:02:34,399
and name is the key my sight is value and within the labels key I'm going to

27
00:02:34,400 --> 00:02:40,500
have another map as value. So app a web and I may have some more

28
00:02:40,500 --> 00:02:46,700
additional elements or may not. So this is an example of having another map as the

29
00:02:46,700 --> 00:02:52,600
value within a key like this I can have any combinations where I can have map of

30
00:02:52,600 --> 00:02:59,866
maps, maps of list, list of lists and lists of maps. Now let us understand how a list

31
00:02:59,866 --> 00:03:05,999
going to be. For any key I may want to represent a collection of values, say for

32
00:03:06,000 --> 00:03:11,166
example when I want to expose a collection of ports, I may give collection

33
00:03:11,166 --> 00:03:15,799
saying these are all the ports I want to expose or I may want to pass a

34
00:03:15,800 --> 00:03:20,366
collection of arguments. These are all the arguments I want to pass it as a

35
00:03:20,366 --> 00:03:26,599
collection. So for a key args I'm going to pass four values that will be marked with

36
00:03:26,600 --> 00:03:33,366
a dash and all the dash will be arranged in the same intent. Now let us go over this particular

37
00:03:33,366 --> 00:03:40,599
yaml file where I do have a key value pair api version and v1 this is one key value

38
00:03:40,600 --> 00:03:46,800
pair and next to that we have another key value pair kind as pod and the next we

39
00:03:46,800 --> 00:03:52,000
have the key metadata and the value is this, what this particular value going to

40
00:03:52,000 --> 00:03:58,200
have, that's going to have name as the key my-site as value and the next key is

41
00:03:58,200 --> 00:04:04,300
labels that's going to have a child key and value pair. Now let's look into this

42
00:04:04,300 --> 00:04:10,200
specific key, the fourth key that is specs of the entire yaml file, that's going to

43
00:04:10,200 --> 00:04:18,200
have a key containers. That's having a collection the first element is a map

44
00:04:18,200 --> 00:04:23,500
and the second element is another map, within the map I do have a key value pair

45
00:04:23,500 --> 00:04:31,000
name as the key front-end as value. Then I do have images key and I do have value

46
00:04:31,000 --> 00:04:35,800
then I have ports within that I do have a collection, within the collection I have

47
00:04:35,800 --> 00:04:41,766
mentioned what is the container port and the other details will follow with a dash.

48
00:04:41,766 --> 00:04:47,599
So we have seen four major parts that is key that's going to be a string always and

49
00:04:47,600 --> 00:04:53,833
I'm going to have a value. Value could be any type and it could be a simple string

50
00:04:53,833 --> 00:04:59,833
or an integer or it could be another complex object like a map or a collection

51
00:04:59,833 --> 00:05:04,466
and every element within that particular map can have another inner complex

52
00:05:04,466 --> 00:05:10,299
object. So if you look at yaml file as just key and a value, value could be any

53
00:05:10,300 --> 00:05:15,466
complex object then the things going to be very simple. If you consider any yaml

54
00:05:15,466 --> 00:05:20,266
file that's going to have key-value pairs. If you look at this particular example I do

55
00:05:20,266 --> 00:05:24,999
have a yaml file and I do have a collection of representation of the

56
00:05:25,000 --> 00:05:30,200
objects, every object will be represented using these four important keys

57
00:05:30,200 --> 00:05:37,000
api version kind metadata and its specification. Here I do have a kind called

58
00:05:37,000 --> 00:05:43,266
service and the version is v1, so I do have a key value pair, api version and

59
00:05:43,266 --> 00:05:50,466
values is v1 the kind is the key and value is service then I do have a key as

60
00:05:50,466 --> 00:05:56,299
metadata within that I do have a map and how many keys are there, name as one

61
00:05:56,300 --> 00:06:02,333
key, labels as another key. Name it is having a text and labels is having another

62
00:06:02,333 --> 00:06:10,599
map, that map is having three key value pairs and the keys are app, tier and role.

63
00:06:10,600 --> 00:06:16,900
So if you look at any yaml file this is how the structure going to be, let's have an

64
00:06:16,900 --> 00:06:21,766
understanding on this specific structure, I do have a key value pair api version as

65
00:06:21,766 --> 00:06:26,566
the key apps/v1 as value and the comment within the yaml file will be

66
00:06:26,566 --> 00:06:32,299
represented using a hash symbol and the next key value pair is kind as the key

67
00:06:32,300 --> 00:06:38,800
deployment as value, metadata is the key and that is having a key value pair as a

68
00:06:38,800 --> 00:06:45,866
value which is having one key value pair name and front end. Then I do have spec

69
00:06:45,866 --> 00:06:52,199
spec is having selector as one key, replicas as other key, template as another

70
00:06:52,200 --> 00:06:57,833
key. So everything is represented using this same intent, within template I do

71
00:06:57,833 --> 00:07:03,666
have a key called metadata and spec, within metadata I do have a key called

72
00:07:03,666 --> 00:07:09,099
labels that is going to have two key value pairs, app as the key and tier as the

73
00:07:09,100 --> 00:07:16,500
another key. The same way I can decode any yaml file and we will be representing

74
00:07:16,500 --> 00:07:20,133
every object within the kubernetes session as the yaml file and the entire

75
00:07:20,133 --> 00:07:25,299
yaml file will also be uploaded as a part of the session, so that you don't need to

76
00:07:25,300 --> 00:07:30,200
code the yaml file but always it is a good idea to have a thorough understanding on

77
00:07:30,200 --> 00:07:35,400
the yaml file, so that any changes to the yaml file we can do it over the text file

78
00:07:35,400 --> 00:07:40,533
as well and there are n number of online yaml validator, where you can validate

79
00:07:40,533 --> 00:07:45,466
whether it is following the right syntax or not. So in a quick summary we had seen

80
00:07:45,466 --> 00:07:50,432
what is the yaml file and how the syntax is being followed within the yaml file and

81
00:07:50,433 --> 00:07:54,366
we saw a few samples as well how the keys and values

82
00:07:54,366 --> 00:07:58,666
will be represented within the yaml file.

