1
00:00:00,000 --> 00:00:10,700
Hi, Let us understand what is config map, how to create, and make use of it.

2
00:00:10,700 --> 00:00:15,266
Whenever I am creating a pod there will be a requirement to pass some

3
00:00:15,266 --> 00:00:19,732
configuration informations to the pod how it should function or for the

4
00:00:19,733 --> 00:00:22,999
containers to give some of the environmental variables that needs

5
00:00:23,000 --> 00:00:27,633
to be passed and sometimes it may be confidential as well as non-confidential

6
00:00:27,633 --> 00:00:33,799
informations. For that we do have two type of configuration kinds like

7
00:00:33,800 --> 00:00:39,966
config maps and secret. Config maps mostly it will be used to store and pass

8
00:00:39,966 --> 00:00:44,566
the non-confidential informations in the format of key value pair. Whenever I say

9
00:00:44,566 --> 00:00:49,666
key value pair we can very well relate to the yaml file where the key is going to be

10
00:00:49,666 --> 00:00:55,132
a string and value could be another map or it could be a collection or even it

11
00:00:55,133 --> 00:00:59,966
could be another string. Let's go ahead and create a config map and see how to

12
00:00:59,966 --> 00:01:05,666
make use of it. Once the config map is created the pod can make use of it as

13
00:01:05,666 --> 00:01:10,532
environmental variables or command line arguments or even a configuration file

14
00:01:10,533 --> 00:01:15,533
within a volume. Now let us see different options available and this

15
00:01:15,533 --> 00:01:20,166
configuration map will help to create environmental specific configuration so

16
00:01:20,166 --> 00:01:24,499
that we can pass it to the container and make the container to have different

17
00:01:24,500 --> 00:01:29,800
behavior in different environments, in terms of using different images or

18
00:01:29,800 --> 00:01:34,633
application properties based on the environment. Let us go ahead and create a

19
00:01:34,633 --> 00:01:40,933
config map I do have a yaml file where I have mentioned the kind as config map

20
00:01:40,933 --> 00:01:47,066
and within data I do have key value pair for example player initial lives it is 3

21
00:01:47,066 --> 00:01:52,432
and the value needs to be mentioned as double quotes and that needs to be

22
00:01:52,433 --> 00:01:56,966
handled as the integer when it is getting read within the application. Within

23
00:01:56,966 --> 00:02:03,599
config map it has to be of type string or another map. In this case I do have

24
00:02:03,600 --> 00:02:08,600
game.properties within that I do have two key value pairs where types

25
00:02:08,600 --> 00:02:14,666
as collection of values and the maximum lives as a string with value 5. So I'm going

26
00:02:14,666 --> 00:02:19,399
to use this particular yaml file and create a config map, let me go ahead and

27
00:02:19,400 --> 00:02:26,066
create a config map using the yaml file. I'll use kubectl apply and then the

28
00:02:26,066 --> 00:02:31,666
yaml file name. So the config map got created let me go ahead and get the

29
00:02:31,666 --> 00:02:37,932
config maps available, so I do have the config map my config. I'm going to get

30
00:02:37,933 --> 00:02:43,899
the details about this config map kubectl describe config maps and then the

31
00:02:43,900 --> 00:02:48,033
name of the config map. The name of the config map was available as a part of the

32
00:02:48,033 --> 00:02:54,166
yaml file, here I do have the name my-config. So I'm going to give describe

33
00:02:54,166 --> 00:02:59,099
and then the name of the config map. Here I do have information in terms of

34
00:02:59,100 --> 00:03:04,300
what are all the keys and the values. Now I'm going to get the output in the

35
00:03:04,300 --> 00:03:09,466
yaml format which would be much easier to understand kubectl get the

36
00:03:09,466 --> 00:03:15,432
config maps and the name of the config map -o the yaml format. Here

37
00:03:15,433 --> 00:03:19,866
the tree structure will be very clearly visible. Now I am going to have a

38
00:03:19,866 --> 00:03:24,632
property file and use the property file and create the config map. As the

39
00:03:24,633 --> 00:03:29,399
property files going to have the key value pair, I can use the property file as well so

40
00:03:29,400 --> 00:03:34,000
I do have a property file with key value pairs. I can directly feed in this property

41
00:03:34,000 --> 00:03:39,700
file and create a config map. I'll use kubectl create configmap and then name

42
00:03:39,700 --> 00:03:44,766
of the config file and provide the property file. Now I can get the output

43
00:03:44,766 --> 00:03:52,099
of the config map that got created as a yaml format. So this different ways of

44
00:03:52,100 --> 00:03:56,633
creating the configmap will be useful whenever I am going to migrate the

45
00:03:56,633 --> 00:04:01,766
legacy applications into the kubernetes where I can go ahead and directly use the

46
00:04:01,766 --> 00:04:09,132
property files or the other yaml files and create a config map. Now let us see how

47
00:04:09,133 --> 00:04:15,566
to use the config map as a part of the pod and get those values. For the demo

48
00:04:15,566 --> 00:04:20,932
purpose I am going to create a configmap, let me get the details about the yaml file

49
00:04:20,933 --> 00:04:26,166
here I do have the configmap where I do have the data that is this is the key and

50
00:04:26,166 --> 00:04:32,766
this is the value. So I do have special_level as one key special_type as

51
00:04:32,766 --> 00:04:38,166
another key. Let me go ahead and create a configmap using this specific yaml file

52
00:04:38,166 --> 00:04:45,299
So I'll use kubectl create and then provide the yaml file the configmap got

53
00:04:45,300 --> 00:04:50,666
created. Now I'm going to have the yaml file for the pod, let me get the details

54
00:04:50,666 --> 00:04:56,999
about the pod yaml file. As I mentioned earlier all these yaml files will be added

55
00:04:57,000 --> 00:05:02,100
as a part of the lecture, so that you can download and directly make use of it.

56
00:05:02,100 --> 00:05:09,900
Here I'm going to create a pod with the name dapi-test-pod and here I am

57
00:05:09,900 --> 00:05:14,233
going to pass the config map as the environmental variable. Here this is the

58
00:05:14,233 --> 00:05:18,733
first time I'm introducing a container can get the environmental variables and

59
00:05:18,733 --> 00:05:22,799
make use of it internally. So here I'm going to pass the environmental variable

60
00:05:22,800 --> 00:05:28,866
with the name special_level_key, so what is going to get passed for this particular

61
00:05:28,866 --> 00:05:33,132
environmental variable that's going to get from the config map and it's going to use

62
00:05:33,133 --> 00:05:39,766
this specific key special_level and what config map to read from it's going to read

63
00:05:39,766 --> 00:05:47,099
from special-config configuration map and the same way I'm going to have

64
00:05:47,100 --> 00:05:51,933
another environmental variable as well that's going to have the name as

65
00:05:51,933 --> 00:05:58,233
special_type_key within the container I am going to execute the bash shell and

66
00:05:58,233 --> 00:06:03,199
it is going to echo these two environmental variables. So this pod

67
00:06:03,200 --> 00:06:07,633
when it is getting created it's going to pass the environment variables by

68
00:06:07,633 --> 00:06:13,099
reading the config maps and within the container it is going to print this

69
00:06:13,100 --> 00:06:19,733
environmental variables as a part of the logs and there will not be any daemon it will be

70
00:06:19,733 --> 00:06:24,399
running, so it's going to log and the life cycle of the pod will get over. I can check

71
00:06:24,400 --> 00:06:29,466
the logs of the pod and see whether those values got printed or not. Now let

72
00:06:29,466 --> 00:06:34,832
me go ahead and create the pod, I'm going to use the kubectl create and

73
00:06:34,833 --> 00:06:39,166
provide the yaml file. Before getting into the pod let's go ahead and check the

74
00:06:39,166 --> 00:06:43,832
details about the config maps that got created. So I'm going to get the details

75
00:06:43,833 --> 00:06:50,399
about the special-config that got created using the yaml file and I do have these

76
00:06:50,400 --> 00:06:58,533
data. That is level 4 and power user as a part of special_level and special_type

77
00:06:58,533 --> 00:07:03,833
Now I am going to get the details about the pod that got created, let me get the

78
00:07:03,833 --> 00:07:13,099
list of pods kubectl get pods, so here's where, I do have the pod, let me get the

79
00:07:13,100 --> 00:07:16,166
description about the pod. The pod got completed these are all the

80
00:07:16,166 --> 00:07:21,699
environmental variables that was set, now I can get into the pod and see the

81
00:07:21,700 --> 00:07:28,533
logs. So I can use the command kubectl logs and the name of the pod kubectl

82
00:07:28,533 --> 00:07:33,666
logs and then name of the pod. So here's where the value that got printed using

83
00:07:33,666 --> 00:07:38,199
the echo statement. So in a quick summary we have seen what is config

84
00:07:38,200 --> 00:07:43,833
maps and how to make use of it within the pods and their uses.

