1
00:00:00,000 --> 00:00:11,533
Hi, In the earlier lecture we saw how to create a pod using a yaml file. Now

2
00:00:11,533 --> 00:00:16,332
I do have the pod up and running and I'm going to see the options how to access

3
00:00:16,332 --> 00:00:26,033
these pods. As we did the describe of this particular pod, it is exposing the port 80

4
00:00:26,033 --> 00:00:31,166
from the container. Now let us see how to access this particular port from the

5
00:00:31,166 --> 00:00:37,166
host. I do have this host and I'm going to run a command port forward, so that

6
00:00:37,166 --> 00:00:42,199
whenever the host is receiving any request from the port 80 it will be

7
00:00:42,200 --> 00:00:46,366
forwarded to the port 80 of this specific pod. So I'm going to use the command

8
00:00:46,366 --> 00:00:53,199
port forward and I'm going to mention address as 0.0.0.0 that means the

9
00:00:53,200 --> 00:00:58,700
request coming from any host and whenever it is getting the request in

10
00:00:58,700 --> 00:01:04,800
port 80 it will be forwarded to the port 80 of this specific pod and this is not the

11
00:01:04,800 --> 00:01:09,400
right way to forward the request, I'm doing it so that to get an understanding

12
00:01:09,400 --> 00:01:14,800
how the port mapping going to happen. So what I have done I have started a

13
00:01:14,800 --> 00:01:19,566
small port forward requests, so any requests that is coming in port 80 will be

14
00:01:19,566 --> 00:01:24,032
forwarded to this particular container into port 80. Now I can access this

15
00:01:24,033 --> 00:01:29,633
particular host and check whether it's serving in port 80 or not. So the host IP

16
00:01:29,633 --> 00:01:37,833
address is 192.168.0.51 and in port 80, so I'm getting the welcome page of nginx.

17
00:01:37,833 --> 00:01:42,399
and as I mentioned earlier this is not the right way to forward the request for that

18
00:01:42,400 --> 00:01:47,033
we will be creating something called services and it will be having a load

19
00:01:47,033 --> 00:01:51,999
balancer in the front end and only that specific load balancer IP address will be

20
00:01:52,000 --> 00:01:56,566
exposed to the outside world. We will be having all the pods in the abstracted

21
00:01:56,566 --> 00:02:01,299
layer, we will be discussing more in detail about how to expose the pods to the

22
00:02:01,300 --> 00:02:05,333
outside world later when we are discussing about services. Now let us see

23
00:02:05,333 --> 00:02:11,399
the other options of how to access the specific pod using the bash shell I can

24
00:02:11,400 --> 00:02:17,733
use the exec command kubectl exec and I wanted to do it in the interactive mode

25
00:02:17,733 --> 00:02:23,899
and provide the pod name and I want to execute the bash shell within it. So now

26
00:02:23,900 --> 00:02:28,100
I am into the bash shell and these are all the content available within

27
00:02:28,100 --> 00:02:34,300
the bash shell within the pod I can get into the location this is having

28
00:02:34,300 --> 00:02:39,133
index.html and this is what it is getting served by default whenever I am

29
00:02:39,133 --> 00:02:44,866
accessing the homepage of nginx this is just to quickly show how I can access

30
00:02:44,866 --> 00:02:49,799
the pod and pod is nothing but it is just another container where it is running with

31
00:02:49,800 --> 00:02:55,600
some base image and it is abstract container by itself. Now in case if I wanted

32
00:02:55,600 --> 00:03:00,300
to copy any specific file from my local file system to the container or the

33
00:03:00,300 --> 00:03:04,833
specific pod I can go ahead and do that. Generally this is also not recommended

34
00:03:04,833 --> 00:03:09,366
the reason because most of the time I will be expecting the container to be in

35
00:03:09,366 --> 00:03:13,466
the immutable state any change to be done I will be making the change to the

36
00:03:13,466 --> 00:03:17,832
image and create a new container or deploy a new container but for

37
00:03:17,833 --> 00:03:21,699
debugging purposes or for some reason if I wanted to copy some file I can go

38
00:03:21,700 --> 00:03:28,066
ahead and do that, let me create a file within the container, so I'm going to get

39
00:03:28,066 --> 00:03:32,732
into the container, let me create a directory get in to the directory and

40
00:03:32,733 --> 00:03:40,333
create a file called 1.txt and within that I do have a text like file copy test

41
00:03:40,333 --> 00:03:47,566
So what I have done within the container I created a text file with the name 1.txt

42
00:03:47,566 --> 00:03:53,299
I'm going to copy this particular file from the container to the host storage or the

43
00:03:53,300 --> 00:03:58,266
host hard disk. I can do the other way as well I can copy any files from the host to

44
00:03:58,266 --> 00:04:03,066
the container also. Only difference will be within the copy command the source and

45
00:04:03,066 --> 00:04:07,499
destination will be different. Now using the kubectl command I am going to copy

46
00:04:07,500 --> 00:04:12,033
the file from the container to the host, I will be mentioning the container file

47
00:04:12,033 --> 00:04:17,599
1.txt as the source and target within the host. If I want to copy the file from the

48
00:04:17,600 --> 00:04:22,200
host to the container I will be mentioning the  hosts file as the source and target as

49
00:04:22,200 --> 00:04:27,000
within the container by providing the container name. Let me issue the

50
00:04:27,000 --> 00:04:32,633
command using the kubectl, kubectl copy and then the name of the pod and

51
00:04:32,633 --> 00:04:37,799
the location where the file is available within the pod and the target. The file

52
00:04:37,800 --> 00:04:43,800
should get copied, let me check this specific location I do have the file one.txt

53
00:04:43,800 --> 00:04:48,633
same content is available, don't worry about this specific error message, it's not

54
00:04:48,633 --> 00:04:52,833
even error message it's just a warning because I am doing the copy being within

55
00:04:52,833 --> 00:04:57,433
that specific location, so it is providing that info message, now what I have done

56
00:04:57,433 --> 00:05:02,133
I have copied a file from the container to the host location. So in a quick summary

57
00:05:02,133 --> 00:05:07,699
we had seen how to expose a port from the container to the host and how to

58
00:05:07,700 --> 00:05:13,600
access that specific port and how to access the pod using the bash shell as

59
00:05:13,600 --> 00:05:19,166
well how to copy a file between the container and the host file system.

