1
00:00:02,120 --> 00:00:03,230
Now, first of all,

2
00:00:03,230 --> 00:00:06,000
as always ensure that you've got your minikube up

3
00:00:06,000 --> 00:00:08,920
and running with minikube status,

4
00:00:08,920 --> 00:00:11,270
and if it would not be up and running

5
00:00:11,270 --> 00:00:15,260
start it with minikube start and pick a driver,

6
00:00:15,260 --> 00:00:16,239
and then of course,

7
00:00:16,239 --> 00:00:19,220
make sure you got no ongoing deployment steer

8
00:00:19,220 --> 00:00:21,830
with kube control gets deployments,

9
00:00:21,830 --> 00:00:24,530
maybe also check that you got no services,

10
00:00:24,530 --> 00:00:26,740
except for that default service.

11
00:00:26,740 --> 00:00:28,533
And you should be good to go.

12
00:00:29,480 --> 00:00:33,410
And with that let's now move this application,

13
00:00:33,410 --> 00:00:37,110
these different containers onto kubernetes.

14
00:00:37,110 --> 00:00:39,460
And we're going to get there step by step.

15
00:00:39,460 --> 00:00:43,540
And I wanna start with just the users-api here.

16
00:00:43,540 --> 00:00:45,700
I'll start with just that

17
00:00:45,700 --> 00:00:46,830
because first of all,

18
00:00:46,830 --> 00:00:49,740
wanna dive into a concept we already learned about

19
00:00:49,740 --> 00:00:52,300
the kubernetes services.

20
00:00:52,300 --> 00:00:54,820
Now to start with the users-api,

21
00:00:54,820 --> 00:00:58,250
we should first of all, go to the users-app.js file

22
00:00:58,250 --> 00:01:00,520
and tweak it a little bit,

23
00:01:00,520 --> 00:01:01,900
because in there I am,

24
00:01:01,900 --> 00:01:06,600
of course already sending requests to this off service.

25
00:01:06,600 --> 00:01:11,070
And initially, if we start with just a user's-api,

26
00:01:11,070 --> 00:01:12,363
this will not work.

27
00:01:13,270 --> 00:01:16,900
Therefore take these lines of code

28
00:01:16,900 --> 00:01:19,550
where we use access to send the request

29
00:01:19,550 --> 00:01:22,320
to this off service and copy them,

30
00:01:22,320 --> 00:01:25,460
then comments them out and here

31
00:01:25,460 --> 00:01:29,840
In the signup post functions so to say,

32
00:01:29,840 --> 00:01:34,840
replace this call to access get with a dummy string.

33
00:01:37,190 --> 00:01:40,650
So simply some dummy text instead of the real response

34
00:01:40,650 --> 00:01:42,240
from making that request.

35
00:01:42,240 --> 00:01:45,040
Because for the moment we don't wanna make that request.

36
00:01:46,210 --> 00:01:49,760
And in this login route functioned here,

37
00:01:49,760 --> 00:01:51,790
we wanna do something similar.

38
00:01:51,790 --> 00:01:55,420
Copy this code, where we send our access request

39
00:01:55,420 --> 00:01:59,800
and comment it out and then replace the response here,

40
00:01:59,800 --> 00:02:01,990
not with a string, but with an object,

41
00:02:01,990 --> 00:02:05,450
an object where you should add a status field

42
00:02:05,450 --> 00:02:09,960
with a code of 200, because we're checking for that here.

43
00:02:09,960 --> 00:02:12,630
And you wanna add a data field

44
00:02:12,630 --> 00:02:14,880
with a number nested object in there

45
00:02:14,880 --> 00:02:18,573
where we have a token field where you can store some string.

46
00:02:20,370 --> 00:02:23,800
These are just minor tweaks, which will reverse later,

47
00:02:23,800 --> 00:02:25,410
but which i wanna use for now

48
00:02:25,410 --> 00:02:27,810
to make this user's app independent

49
00:02:27,810 --> 00:02:30,653
from any other containers for this moment.

50
00:02:32,700 --> 00:02:35,440
So with all of that, we should be fine.

51
00:02:35,440 --> 00:02:37,870
And now of course, we wanna to build our image

52
00:02:37,870 --> 00:02:39,530
and move it to Docker hub

53
00:02:39,530 --> 00:02:42,760
so that we can use it on a kubernetes cluster.

54
00:02:42,760 --> 00:02:44,840
So as always on Docker hub,

55
00:02:44,840 --> 00:02:47,300
make sure you create a new repository

56
00:02:47,300 --> 00:02:51,393
and all named kub-demo users.

57
00:02:52,890 --> 00:02:57,240
The name is up to you, of course, create this repository

58
00:02:57,240 --> 00:02:59,090
and then we need to create an image

59
00:02:59,090 --> 00:03:02,220
off that name and push it.

60
00:03:02,220 --> 00:03:07,220
So therefore I will now go to my terminal here

61
00:03:07,750 --> 00:03:11,790
and move into that user's-api folder

62
00:03:11,790 --> 00:03:13,920
with the cd command

63
00:03:13,920 --> 00:03:16,610
and then run docker build dot

64
00:03:16,610 --> 00:03:19,770
and with dash t give it a name of academind slash

65
00:03:19,770 --> 00:03:21,760
or in you case of course,

66
00:03:21,760 --> 00:03:25,410
your Docker hub account name slash,

67
00:03:25,410 --> 00:03:28,410
and then the name you picked for this repository

68
00:03:28,410 --> 00:03:31,203
and then a wide space between that name and the dot.

69
00:03:32,970 --> 00:03:37,970
Now with that we built this image for the user's-api

70
00:03:38,150 --> 00:03:42,270
and once it was built, we of course push it by,

71
00:03:42,270 --> 00:03:45,050
well, just pushing this image name,

72
00:03:45,050 --> 00:03:48,200
like this, and now it's pushed to Docker hub

73
00:03:48,200 --> 00:03:50,363
to this newly created repository.

74
00:03:53,390 --> 00:03:55,790
Once it was pushed, we are of course,

75
00:03:55,790 --> 00:03:58,540
ready to get started with Kubernetes.

76
00:03:58,540 --> 00:04:01,500
And for that, I will actually create a new sub folder here,

77
00:04:01,500 --> 00:04:04,120
kubernetes, which you don't have to create,

78
00:04:04,120 --> 00:04:06,910
but where I wanna store all my yaml files

79
00:04:06,910 --> 00:04:09,030
to have them all in one place.

80
00:04:09,030 --> 00:04:13,580
And in there I'll add my users-deployment.yaml file,

81
00:04:13,580 --> 00:04:16,029
which as the names suggests should set up

82
00:04:16,029 --> 00:04:18,762
that deployment for the users container.

83
00:04:19,709 --> 00:04:20,543
Now, as you learn,

84
00:04:20,543 --> 00:04:23,520
you could merge all your Kubernetes configuration

85
00:04:23,520 --> 00:04:26,660
in one big yaml file, but to keep it easier

86
00:04:26,660 --> 00:04:31,050
to manage and find i will use multiple files here.

87
00:04:31,050 --> 00:04:34,890
So in here as always, we need to specify an apiVersion,

88
00:04:34,890 --> 00:04:37,000
which should be apps/v1

89
00:04:37,000 --> 00:04:41,770
for a deployment, the kind is deployment of course.

90
00:04:41,770 --> 00:04:43,770
And then we can add metadata

91
00:04:43,770 --> 00:04:45,640
where we give this deployment a name,

92
00:04:45,640 --> 00:04:48,253
for example, user-deployment.

93
00:04:49,780 --> 00:04:53,290
with that done, we need to set up a specification

94
00:04:53,290 --> 00:04:55,750
and that's the specification for the deployment,

95
00:04:55,750 --> 00:04:57,290
as you learned.

96
00:04:57,290 --> 00:05:00,210
And here I wanna deploy one replica.

97
00:05:00,210 --> 00:05:04,650
So only one instance of a pod for a given container,

98
00:05:04,650 --> 00:05:06,860
and then set up the pod template

99
00:05:06,860 --> 00:05:11,800
with that template option, here for this pod template,

100
00:05:11,800 --> 00:05:14,750
we wanna add metadata and give it a label.

101
00:05:14,750 --> 00:05:17,520
For example, app users,

102
00:05:17,520 --> 00:05:20,030
as always, the label is up to you

103
00:05:20,030 --> 00:05:23,730
both the key name as well as the value here.

104
00:05:23,730 --> 00:05:26,320
And with that added, we can already add a selector

105
00:05:28,560 --> 00:05:32,460
and on this selector here we can use match labels

106
00:05:32,460 --> 00:05:35,000
and then match this app users label.

107
00:05:35,000 --> 00:05:36,890
We just add it.

108
00:05:36,890 --> 00:05:38,390
This is how we set up a deployment.

109
00:05:38,390 --> 00:05:40,970
And of course that's nothing new.

110
00:05:40,970 --> 00:05:44,280
Next, we set up the specification for this part

111
00:05:44,280 --> 00:05:47,880
and there , I wanna add my containers.

112
00:05:47,880 --> 00:05:50,430
And for the moment it's just one container,

113
00:05:50,430 --> 00:05:53,360
hence one dash here with a name of,

114
00:05:53,360 --> 00:05:56,280
let's say, users, of course,

115
00:05:56,280 --> 00:05:58,360
this name is up to you.

116
00:05:58,360 --> 00:06:03,360
Using an image which is named academind/kub-demo-users

117
00:06:04,090 --> 00:06:04,923
in my case.

118
00:06:04,923 --> 00:06:07,220
So does image, we just pushed,

119
00:06:07,220 --> 00:06:11,290
of course, make sure you use your image name there.

120
00:06:11,290 --> 00:06:12,633
And that is it.

121
00:06:13,610 --> 00:06:17,820
With that, I'm setting up this deployment

122
00:06:17,820 --> 00:06:20,663
and now of course we can apply it,

123
00:06:22,290 --> 00:06:24,990
by running kube control apply.

124
00:06:24,990 --> 00:06:27,480
And now of course you wanna apply it to our cluster

125
00:06:27,480 --> 00:06:30,340
with cube control apply users dash,

126
00:06:30,340 --> 00:06:33,210
deployment dot yaml as a file name.

127
00:06:33,210 --> 00:06:35,010
And I'm in the wrong folder.

128
00:06:35,010 --> 00:06:38,250
Of course, we need to see the out of the user's-api first

129
00:06:38,250 --> 00:06:41,460
and then cd into the kubernetes folder in order

130
00:06:41,460 --> 00:06:43,550
to be able to run this command like this

131
00:06:43,550 --> 00:06:45,503
otherwise this file wouldn't be found.

132
00:06:46,750 --> 00:06:49,660
Now this deployment is created as always,

133
00:06:49,660 --> 00:06:51,280
this of course means that eventually

134
00:06:51,280 --> 00:06:53,550
we'll have one pod up and running

135
00:06:53,550 --> 00:06:55,523
with that user's container in it.

