1
00:00:02,160 --> 00:00:03,760
To create this service,

2
00:00:03,760 --> 00:00:06,460
we can again use the command line here.

3
00:00:06,460 --> 00:00:09,710
Now, I will keep this dashboard process up and running,

4
00:00:09,710 --> 00:00:12,940
and therefore create a new terminal window.

5
00:00:12,940 --> 00:00:15,690
And then here we can, again use Kube Control

6
00:00:15,690 --> 00:00:17,660
to create a service.

7
00:00:17,660 --> 00:00:20,260
Now, if we run Kube Control Create,

8
00:00:20,260 --> 00:00:24,563
we actually see that we could create a service here.

9
00:00:25,650 --> 00:00:27,330
And whilst this would work,

10
00:00:27,330 --> 00:00:29,690
it's actually not what I'll do here.

11
00:00:29,690 --> 00:00:32,650
Instead, there is an even more convenient command

12
00:00:32,650 --> 00:00:35,980
for exposing the pod created by a deployment.

13
00:00:35,980 --> 00:00:40,060
And that's the Kube Control Expose command.

14
00:00:40,060 --> 00:00:42,610
This command does what the name implies.

15
00:00:42,610 --> 00:00:47,060
It exposes a pod created by a deployment

16
00:00:47,060 --> 00:00:49,520
by creating such a service.

17
00:00:49,520 --> 00:00:51,410
Now we need to let Kubernetes know

18
00:00:51,410 --> 00:00:54,280
that we wanna expose a deployment,

19
00:00:54,280 --> 00:00:58,130
and then we specify the name of that deployment.

20
00:00:58,130 --> 00:01:02,750
And then we need to add two important options.

21
00:01:02,750 --> 00:01:07,670
The first option is the port, which we wanna expose.

22
00:01:07,670 --> 00:01:10,190
And in my case, that will be Port 8080

23
00:01:10,190 --> 00:01:12,820
because that is what the container exposes,

24
00:01:12,820 --> 00:01:16,063
because that is what the containerized app listens on.

25
00:01:17,570 --> 00:01:21,230
So here, I'll expose Port 8080, like this,

26
00:01:21,230 --> 00:01:24,743
and you need to assign the value with such an equal sign.

27
00:01:25,630 --> 00:01:27,340
Now, that's one thing.

28
00:01:27,340 --> 00:01:31,780
The other important option is the type of service

29
00:01:31,780 --> 00:01:35,110
or exposing which you wanna create here.

30
00:01:35,110 --> 00:01:38,100
And there are different built-in types.

31
00:01:38,100 --> 00:01:40,810
One possible type you could specify here

32
00:01:40,810 --> 00:01:43,100
would be cluster IP.

33
00:01:43,100 --> 00:01:46,640
This is actually the default type which basically means

34
00:01:46,640 --> 00:01:50,870
it will only be reachable from inside the cluster.

35
00:01:50,870 --> 00:01:53,310
Still, we will then at least get an address

36
00:01:53,310 --> 00:01:56,590
which doesn't change, but it's not what we need here.

37
00:01:56,590 --> 00:01:59,050
Instead, we also have NodePort,

38
00:01:59,050 --> 00:02:03,507
which actually means this deployment should be exposed

39
00:02:03,507 --> 00:02:07,350
with help off the IP address of the worker node

40
00:02:07,350 --> 00:02:09,199
on which it's running.

41
00:02:09,199 --> 00:02:12,980
Distant actually would be accessible from outside.

42
00:02:12,980 --> 00:02:16,587
But even better than that, there's the type LoadBalancer.

43
00:02:17,920 --> 00:02:22,390
Now LoadBalancer utilizes a LoadBalancer

44
00:02:22,390 --> 00:02:25,060
which has to exist in the infrastructure

45
00:02:25,060 --> 00:02:27,070
on which our cluster runs.

46
00:02:27,070 --> 00:02:30,010
And then this LoadBalancer will actually generate

47
00:02:30,010 --> 00:02:32,630
a unique address for this service.

48
00:02:32,630 --> 00:02:35,790
And it will not just do that, but as the name implies,

49
00:02:35,790 --> 00:02:39,390
it will also evenly distribute incoming traffic

50
00:02:39,390 --> 00:02:42,886
across all pods, which are part of this service.

51
00:02:42,886 --> 00:02:45,570
Obviously, this doesn't matter to us here

52
00:02:45,570 --> 00:02:48,110
because we only have one pod at the moment.

53
00:02:48,110 --> 00:02:49,880
But if we would scale this,

54
00:02:49,880 --> 00:02:52,930
and we would run multiple instances of this pod,

55
00:02:52,930 --> 00:02:55,260
it would start to matter.

56
00:02:55,260 --> 00:02:58,690
Now LoadBalancer, this type here

57
00:02:58,690 --> 00:03:02,510
is only available if your cluster and the infrastructure

58
00:03:02,510 --> 00:03:04,769
on which the cluster runs supports it.

59
00:03:04,769 --> 00:03:09,769
AWS does, for example, and minikube thankfully also does it

60
00:03:09,930 --> 00:03:12,410
which means that we can use this type here.

61
00:03:12,410 --> 00:03:16,790
So if we now hit Enter, this service was created.

62
00:03:16,790 --> 00:03:18,890
And we can check that it was created

63
00:03:18,890 --> 00:03:22,133
by running Kube Control Get Services.

64
00:03:23,130 --> 00:03:28,130
And here, you should actually see Kube Services here.

65
00:03:29,410 --> 00:03:32,250
The first one, the bottom one, Kubernetes,

66
00:03:32,250 --> 00:03:34,870
this actually has the type cluster IP,

67
00:03:34,870 --> 00:03:38,190
and it's a default service which was created automatically,

68
00:03:38,190 --> 00:03:39,203
not by us.

69
00:03:40,040 --> 00:03:44,360
But here we see the service for the first app deployment.

70
00:03:44,360 --> 00:03:47,840
You see the type and the cluster internal IP

71
00:03:47,840 --> 00:03:49,530
which won't help us.

72
00:03:49,530 --> 00:03:53,310
Now, if this would be deployed on a cloud provider,

73
00:03:53,310 --> 00:03:56,220
we would actually see an external IP here,

74
00:03:56,220 --> 00:03:57,460
but for minikube,

75
00:03:57,460 --> 00:04:01,400
this will always stay in the pending status.

76
00:04:01,400 --> 00:04:04,310
Nonetheless, minikube balls has got us covered.

77
00:04:04,310 --> 00:04:07,080
The reason why we don't see the external IP here

78
00:04:07,080 --> 00:04:10,290
is that of course, we must not forget that minikube

79
00:04:10,290 --> 00:04:13,690
is still a virtual machine running on our local machine.

80
00:04:13,690 --> 00:04:16,779
So it doesn't have too many IPs available

81
00:04:16,779 --> 00:04:21,779
since well, these IPs would lead to websites out there.

82
00:04:21,980 --> 00:04:24,740
So therefore, we don't have an external IP here,

83
00:04:24,740 --> 00:04:26,680
but minikube has a command,

84
00:04:26,680 --> 00:04:29,750
which will give us access to the service

85
00:04:29,750 --> 00:04:33,400
by basically mapping a special port to an IP

86
00:04:33,400 --> 00:04:35,840
which we can reach from our local machine,

87
00:04:35,840 --> 00:04:38,370
and which identifies this virtual machine

88
00:04:38,370 --> 00:04:40,760
running on our local machine.

89
00:04:40,760 --> 00:04:44,430
And that command is the minikube service command,

90
00:04:44,430 --> 00:04:47,220
where we then need to specify our deployment

91
00:04:47,220 --> 00:04:51,350
and our service name therefore, in this case, first app.

92
00:04:51,350 --> 00:04:54,570
Obviously, if you created this service on a Cloud provider,

93
00:04:54,570 --> 00:04:56,400
which supports a LoadBalancer,

94
00:04:56,400 --> 00:04:59,200
you should find an external address here

95
00:04:59,200 --> 00:05:01,320
and you don't need this command.

96
00:05:01,320 --> 00:05:03,120
This command wouldn't even work then

97
00:05:03,120 --> 00:05:05,790
because it's minikube specific.

98
00:05:05,790 --> 00:05:09,750
So if we now hit Enter, we get this table with an address

99
00:05:09,750 --> 00:05:12,440
which we can use to view our application.

100
00:05:12,440 --> 00:05:15,390
And normally, it should also automatically open that

101
00:05:15,390 --> 00:05:17,150
in the browser for you.

102
00:05:17,150 --> 00:05:20,020
So if everything worked, you can use this address

103
00:05:20,020 --> 00:05:23,285
to view your running Node.js application

104
00:05:23,285 --> 00:05:27,320
running in that container, which is running in that pod,

105
00:05:27,320 --> 00:05:29,710
which was created by Kubernetes

106
00:05:29,710 --> 00:05:32,170
based on the deployment we created

107
00:05:32,170 --> 00:05:34,410
and sent to the Kubernetes cluster.

108
00:05:34,410 --> 00:05:37,700
And because of this Kubernetes service which we created,

109
00:05:37,700 --> 00:05:40,983
we can view it as on this address here.

110
00:05:41,840 --> 00:05:45,840
And these are a couple of crucial steps.

111
00:05:45,840 --> 00:05:47,480
Now, we will later switch away

112
00:05:47,480 --> 00:05:50,700
from this imperative approach, which we're using here,

113
00:05:50,700 --> 00:05:53,460
but nonetheless, these are huge steps forward.

114
00:05:53,460 --> 00:05:55,700
And with the pod, the deployment,

115
00:05:55,700 --> 00:05:57,860
and the service object type,

116
00:05:57,860 --> 00:06:00,840
we learned about some of the most important types

117
00:06:00,840 --> 00:06:04,673
which we'll use all the time when working with Kubernetes.

118
00:06:05,510 --> 00:06:08,403
So now let's see what else we can do with Kubernetes.

