1
00:00:00,000 --> 00:00:11,133
Hi let us understand some additional detail about pods. Already we do have

2
00:00:11,133 --> 00:00:18,166
minikube installed and we do have the kubectl client. I'm going to start a pod and

3
00:00:18,166 --> 00:00:23,632
see how I can leverage kubectl to explore the functionalities available as a part of

4
00:00:23,633 --> 00:00:28,599
pod. I do have the system where the minikube is installed and everything is

5
00:00:28,600 --> 00:00:33,633
running fine and kubectl is also very well configured. Now I'm going to start a

6
00:00:33,633 --> 00:00:38,433
sample pod and there are n number of ways to start the pod I'm going to use the

7
00:00:38,433 --> 00:00:44,299
easiest way to start the pod by providing an image name. I will use the kubectl

8
00:00:44,300 --> 00:00:49,500
run command and I will give a name of the pod and generator I will mention it as

9
00:00:49,500 --> 00:00:54,566
run pod version 1. The api what we are going to use over here don't worry

10
00:00:54,566 --> 00:00:59,199
as of now we will have a detailed discussion, this is to have little more

11
00:00:59,200 --> 00:01:03,533
understanding on the pod, so that we can explore various objects available as a

12
00:01:03,533 --> 00:01:09,099
part of kubernetes. I'm using the run command of kubectl and I'm providing

13
00:01:09,100 --> 00:01:14,400
a name and generator that is the api version and image I wanted to use is

14
00:01:14,400 --> 00:01:19,033
nginx. So the pod will get created, I'm going to use the command

15
00:01:19,033 --> 00:01:25,766
kubectl, get pods. That's going to list all the pods available as a part of the default

16
00:01:25,766 --> 00:01:29,999
namespace. Now I am introducing another terminology namespace

17
00:01:30,000 --> 00:01:35,200
namespace is nothing but a logical consolidation of objects together. I can

18
00:01:35,200 --> 00:01:40,533
create my own custom namespace or use the default namespace as of now I

19
00:01:40,533 --> 00:01:46,266
am going to use the default namespace and there is a system namespace

20
00:01:46,266 --> 00:01:51,099
already available where all the system related objects will be running within this

21
00:01:51,100 --> 00:01:56,266
system namespace. Here I do have the name of the pod and the status that is

22
00:01:56,266 --> 00:02:01,832
one pod needs to run and it's getting ready the status container it is getting

23
00:02:01,833 --> 00:02:06,599
created and it was created 8 seconds ago. Let me go ahead and list the pods

24
00:02:06,600 --> 00:02:11,900
yes, it is up and running and it did not get restarted any time from the beginning

25
00:02:11,900 --> 00:02:17,200
and it is up and running for 74 seconds. Now I can get more details about this

26
00:02:17,200 --> 00:02:24,733
particular pod by providing the command describe. kubectl describe

27
00:02:24,733 --> 00:02:32,199
pods and the name of the pod. I will have all the information about the pod in

28
00:02:32,200 --> 00:02:37,500
terms of what is the IP address in which node it is running and it's going to run in

29
00:02:37,500 --> 00:02:43,733
only one node as I do have minikube and it will be running in one single node, the IP

30
00:02:43,733 --> 00:02:48,233
address of the pod and what is the container running within it, as we

31
00:02:48,233 --> 00:02:52,733
discussed earlier one pod can have n number of containers, what is the idea of

32
00:02:52,733 --> 00:02:57,166
the container what image it is using and what is the state of that specific

33
00:02:57,166 --> 00:03:02,066
container, what are all the ports it is exposing and different parameters for that

34
00:03:02,066 --> 00:03:06,732
particular container and it is going to provide the output in yaml format

35
00:03:06,733 --> 00:03:11,866
and I do have different events in terms of how that particular pod got started what

36
00:03:11,866 --> 00:03:18,766
are all the events happened within that particular pod I can get those details. Now to have better understanding visually

37
00:03:18,766 --> 00:03:24,366
I am going to draw the pod unit over here, so what happened on top of minikube a

38
00:03:24,366 --> 00:03:29,966
pod got created, within pod a container got created, that got an IP address as

39
00:03:29,966 --> 00:03:36,166
this. So what did we do we created a pod quickly using the kubectl run command

40
00:03:36,166 --> 00:03:40,466
where the pod got created and a container is running within it. We do not

41
00:03:40,466 --> 00:03:45,132
have much control in terms of what port to expose how to label this pods and it's

42
00:03:45,133 --> 00:03:49,699
all going to be much difficult where I can go ahead and use a yaml file with

43
00:03:49,700 --> 00:03:53,700
declaratively I can define how that particular pod should behave what are all

44
00:03:53,700 --> 00:04:00,300
its properties and how to communicate with the pod using the kubectl. Let me go

45
00:04:00,300 --> 00:04:06,233
ahead and delete this specific pod and create a new pod using yaml file. I'm

46
00:04:06,233 --> 00:04:15,399
going to delete the pod, kubectl delete pod and the name of the pod. The pod is

47
00:04:15,400 --> 00:04:20,200
getting deleted. Now let me go ahead and list the pods there are no pods available

48
00:04:20,200 --> 00:04:25,033
as a part of default namespace, now let me go ahead and create a yaml file so

49
00:04:25,033 --> 00:04:30,599
that I can create the entire resources available as a part of the yaml file. I'm

50
00:04:30,600 --> 00:04:35,800
going to name the file as, I will be adding this specific yaml file as it is within the

51
00:04:35,800 --> 00:04:40,833
resources so that you can download and use it as it is. As we discussed earlier as a

52
00:04:40,833 --> 00:04:46,066
part of the yaml discussion we are going to have four important keys api version,

53
00:04:46,066 --> 00:04:52,199
kind, metadata and spec. I'm going to create an object called pod and the api

54
00:04:52,200 --> 00:04:57,366
version I'm going to use is version 1 and metadata I'm giving name of this

55
00:04:57,366 --> 00:05:03,766
particular pod that I wanted to create as nginx yaml and within specifications

56
00:05:03,766 --> 00:05:08,399
I'm going to have containers and within containers, I do have only one element

57
00:05:08,400 --> 00:05:13,366
which will have an image nginx and it will have the name nginx and I'm going

58
00:05:13,366 --> 00:05:19,566
to expose the port 80. I can get more details about the pod and it's a syntax

59
00:05:19,566 --> 00:05:24,232
within the reference of kubernetes website. I can get into the kubernetes api

60
00:05:24,233 --> 00:05:31,766
the latest version is version 1.18 within that you can get into pod v1 core, here

61
00:05:31,766 --> 00:05:36,766
I do have the information on what are all the fields it can have api version, kind

62
00:05:36,766 --> 00:05:42,932
metadata, spec and status. So here I'm going to have the spec as pod

63
00:05:42,933 --> 00:05:47,999
specifications, if I get into the pod spec I will have details on what are all fields it

64
00:05:48,000 --> 00:05:53,133
can have. The fields I'm going to have is containers and container is going to have

65
00:05:53,133 --> 00:05:58,333
detail about the container and it is going to be of type array. If I check the details

66
00:05:58,333 --> 00:06:01,966
about the container it will have information on what are all the fields it

67
00:06:01,966 --> 00:06:08,099
can have, the fields that we have is about images and what are all ports it can open

68
00:06:08,100 --> 00:06:13,466
again container port it's going to be of type array I can get into the container

69
00:06:13,466 --> 00:06:18,132
port and get the details on what are all the fields it can have. So the api is having

70
00:06:18,133 --> 00:06:22,999
the complete details on how the yaml file can be constructed and what are all

71
00:06:23,000 --> 00:06:30,933
informations or the fields it can have. So if I get into this pod nginx, I do have the

72
00:06:30,933 --> 00:06:35,833
specifications within that I had containers and I have the details about

73
00:06:35,833 --> 00:06:40,799
image, name, ports and ports going to have details about the container port

74
00:06:40,800 --> 00:06:45,100
name and other information. So that's what it's mentioned over here, container

75
00:06:45,100 --> 00:06:50,200
port name and in case if you wanted to specify the protocol or any host

76
00:06:50,200 --> 00:06:56,366
IP address to which I wanted to bind, I can mention all this information. Now I do

77
00:06:56,366 --> 00:07:01,866
have the pod definition using a yaml file, now I am going to create a pod, I will

78
00:07:01,866 --> 00:07:11,699
be using the command apply, kubectl apply and use the file, pod nginx.yaml

79
00:07:11,700 --> 00:07:20,733
The pod will get created, now let me go ahead and list the pods, kubectl get pods. So I do

80
00:07:20,733 --> 00:07:26,133
have one pod with a name nginx-yaml up and running. Let me go ahead and

81
00:07:26,133 --> 00:07:37,133
describe the pod, kubectl describe pods nginx yaml. So I will be having all the

82
00:07:37,133 --> 00:07:42,733
information about how I requested the pod to get created. So it got created

83
00:07:42,733 --> 00:07:47,799
within the default namespace and this is the IP address and it is using the image

84
00:07:47,800 --> 00:07:57,766
nginx and the port 80 is exposed from the container. So this nginx is exposing

85
00:07:57,766 --> 00:08:02,399
the port 80. In the next lecture we will see how to access this particular port and

86
00:08:02,400 --> 00:08:06,966
delete the pod using the file and what are all its advantages. So in a quick

87
00:08:06,966 --> 00:08:11,399
summary we saw how to create a pod using the run command as well as using

88
00:08:11,400 --> 00:08:16,233
the apply command and what are all its differences and how to get

89
00:08:16,233 --> 00:08:20,499
the details about the pod using the describe command.

