1
00:00:01,583 --> 00:00:03,870
Now for this module,

2
00:00:03,870 --> 00:00:07,939
I got another demo application which you find attached.

3
00:00:07,939 --> 00:00:11,020
And this application actually consists

4
00:00:11,020 --> 00:00:15,690
of three different back end APIs which will work together.

5
00:00:15,690 --> 00:00:19,070
Three different containers in the end.

6
00:00:19,070 --> 00:00:21,530
it's a Node.js application

7
00:00:21,530 --> 00:00:23,870
and you can definitely dive into the code.

8
00:00:23,870 --> 00:00:26,840
But it will just be a dummy application.

9
00:00:26,840 --> 00:00:29,140
We have this auth API,

10
00:00:29,140 --> 00:00:32,930
which in the end is dealing with verifying tokens

11
00:00:32,930 --> 00:00:36,743
and generating tokens for authenticated users.

12
00:00:37,610 --> 00:00:39,530
We got the users API,

13
00:00:39,530 --> 00:00:44,240
which is dealing with creating users and logging users in

14
00:00:44,240 --> 00:00:47,300
and all of that happens in a dummy mode.

15
00:00:47,300 --> 00:00:49,280
I'm not using a database here,

16
00:00:49,280 --> 00:00:51,380
I'm not storing data in files,

17
00:00:51,380 --> 00:00:54,900
we're just working with dummy data which is not stored.

18
00:00:54,900 --> 00:00:58,330
Because this module is not about storing data.

19
00:00:58,330 --> 00:01:01,980
It's about connecting these different services.

20
00:01:01,980 --> 00:01:04,780
And indeed this user is API

21
00:01:04,780 --> 00:01:08,880
will eventually reach out to this auth service here,

22
00:01:08,880 --> 00:01:11,900
to for example, get this token

23
00:01:11,900 --> 00:01:16,120
which is generated when a user is logging in for example.

24
00:01:16,120 --> 00:01:18,310
And then we get this tasks API,

25
00:01:18,310 --> 00:01:22,230
it's another very straightforward Node.js application.

26
00:01:22,230 --> 00:01:25,460
And in there, we basically can return a list

27
00:01:25,460 --> 00:01:29,400
of stored tasks and we can store a new task.

28
00:01:29,400 --> 00:01:32,690
And indeed, this will be stored in a file,

29
00:01:32,690 --> 00:01:36,010
which still only acts as a dummy storage Of course.

30
00:01:36,010 --> 00:01:39,640
A database would be a better storage in reality

31
00:01:39,640 --> 00:01:41,870
but again it's not about the storage.

32
00:01:41,870 --> 00:01:45,960
But instead this API also actually will receive

33
00:01:45,960 --> 00:01:49,400
a token, which identifies a logged in user.

34
00:01:49,400 --> 00:01:51,380
And therefore it will also reach out

35
00:01:51,380 --> 00:01:55,273
to this auth API to verify this token.

36
00:01:56,250 --> 00:02:00,370
So here's the general structure of our demo application.

37
00:02:00,370 --> 00:02:03,510
We have these free Node.js APIs,

38
00:02:03,510 --> 00:02:06,370
which will be in a cluster.

39
00:02:06,370 --> 00:02:09,509
And the users API for example,

40
00:02:09,509 --> 00:02:12,120
talks to the auth API.

41
00:02:12,120 --> 00:02:14,840
When we send the request to the users API

42
00:02:14,840 --> 00:02:16,660
to create a new user,

43
00:02:16,660 --> 00:02:19,970
the users API will talk to the auth API

44
00:02:19,970 --> 00:02:22,940
to generate a token for that user.

45
00:02:22,940 --> 00:02:26,640
These two containers the auth and users API,

46
00:02:26,640 --> 00:02:28,670
each runs in their own container

47
00:02:28,670 --> 00:02:31,420
will actually be created in the same pod.

48
00:02:31,420 --> 00:02:34,930
At least at the beginning of this course module.

49
00:02:34,930 --> 00:02:38,640
And we'll have pod-internal communication here

50
00:02:38,640 --> 00:02:40,950
because the auth API will actually

51
00:02:40,950 --> 00:02:44,550
not be reached from outside the cluster

52
00:02:44,550 --> 00:02:48,740
but only from inside that first pod.

53
00:02:48,740 --> 00:02:51,860
And the tasks API will run in another pod.

54
00:02:51,860 --> 00:02:54,360
And both pods will actually be reachable

55
00:02:54,360 --> 00:02:56,020
from the outside world.

56
00:02:56,020 --> 00:02:57,500
But as I just mentioned,

57
00:02:57,500 --> 00:03:01,180
the auth API will actually not directly be reached,

58
00:03:01,180 --> 00:03:03,157
it will not directly handle the requests

59
00:03:03,157 --> 00:03:04,980
from the outside world.

60
00:03:04,980 --> 00:03:07,290
Instead, only the users API will

61
00:03:07,290 --> 00:03:10,000
and will have this pod-internal communication

62
00:03:10,000 --> 00:03:11,473
in that pod then.

63
00:03:12,400 --> 00:03:14,390
Now this will not be the final picture

64
00:03:14,390 --> 00:03:17,310
we're going to refine it throughout this module.

65
00:03:17,310 --> 00:03:19,290
But that's what we're going to start with

66
00:03:19,290 --> 00:03:23,870
and actually, I'm going to start with an even simpler setup.

67
00:03:23,870 --> 00:03:26,920
I just wanna start with the users API,

68
00:03:26,920 --> 00:03:30,550
for the moment not communicate with the auth API

69
00:03:30,550 --> 00:03:34,330
and just ensure that the users API is able

70
00:03:34,330 --> 00:03:36,890
to handle incoming requests.

71
00:03:36,890 --> 00:03:39,860
Now before we translate this into Kubernetes,

72
00:03:39,860 --> 00:03:43,030
you can absolutely play around with this API

73
00:03:43,030 --> 00:03:45,330
because I do provide Docker files

74
00:03:45,330 --> 00:03:47,723
and a Docker compose file already.

75
00:03:48,700 --> 00:03:52,830
So of course you can run Docker compose up -d --build

76
00:03:52,830 --> 00:03:55,050
and this application will be built

77
00:03:55,050 --> 00:03:56,530
the images will be built

78
00:03:56,530 --> 00:03:59,030
and these free containers will be startup.

79
00:03:59,030 --> 00:04:01,403
And all the code should already work then.

80
00:04:02,610 --> 00:04:05,660
And you could then use postman to send the request

81
00:04:05,660 --> 00:04:09,270
to localhost 8080/login for example,

82
00:04:09,270 --> 00:04:12,610
with some dummy email and password body data.

83
00:04:12,610 --> 00:04:15,510
And that would reach the users API

84
00:04:15,510 --> 00:04:20,130
which is listening on this port 8080

85
00:04:20,130 --> 00:04:22,280
and that's the port I mapping here

86
00:04:22,280 --> 00:04:24,590
in the Docker compose file too

87
00:04:24,590 --> 00:04:28,290
and then for the log in requests which are just sent here.

88
00:04:28,290 --> 00:04:30,300
This will then indeed,

89
00:04:30,300 --> 00:04:33,260
extract email and password briefly verify it

90
00:04:33,260 --> 00:04:34,660
in a very simple way.

91
00:04:34,660 --> 00:04:37,820
And then reach out to the auth API

92
00:04:37,820 --> 00:04:40,650
to actually send my password there

93
00:04:40,650 --> 00:04:43,400
and a hashed version of the password

94
00:04:43,400 --> 00:04:45,980
of course just using some dummy hashing data.

95
00:04:45,980 --> 00:04:48,460
And then we'll get back a token

96
00:04:48,460 --> 00:04:51,730
which is actually sent back with the response

97
00:04:51,730 --> 00:04:55,691
and that's the token you see here in the response.

98
00:04:55,691 --> 00:04:58,260
Now you can also try sending a request

99
00:04:58,260 --> 00:05:01,470
to the auth API directly and this will fail

100
00:05:01,470 --> 00:05:04,840
because it's not exposed publicly in this setup,

101
00:05:04,840 --> 00:05:07,530
only other containers are able to talk to it.

102
00:05:07,530 --> 00:05:11,200
And you can try fetching tasks initially that fails

103
00:05:11,200 --> 00:05:14,700
but if you do store a new task by sending a post request

104
00:05:14,700 --> 00:05:18,250
to localhost 80/tasks with a body

105
00:05:18,250 --> 00:05:20,790
that contains a text and a title.

106
00:05:20,790 --> 00:05:23,500
If you do that then this task will be stored

107
00:05:23,500 --> 00:05:25,820
and there after if you send a get request

108
00:05:25,820 --> 00:05:28,100
to localhost 8002 tasks

109
00:05:28,100 --> 00:05:30,083
you can see that task here.

110
00:05:32,850 --> 00:05:35,400
Now whenever you run Docker compose down,

111
00:05:35,400 --> 00:05:36,920
all the data will be lost

112
00:05:36,920 --> 00:05:39,070
because I'm not using volumes here.

113
00:05:39,070 --> 00:05:41,070
Because again, the data storage

114
00:05:41,070 --> 00:05:43,500
is not the thing I wanna focus on here.

115
00:05:43,500 --> 00:05:47,380
Instead it's the container and service interaction.

116
00:05:47,380 --> 00:05:49,082
Now Feel free to dive deeper into the code

117
00:05:49,082 --> 00:05:52,120
and play around with that a little bit.

118
00:05:52,120 --> 00:05:55,420
But for the moment, I will actually not do that.

119
00:05:55,420 --> 00:05:57,610
I will run Docker compose down

120
00:05:57,610 --> 00:06:00,830
because of course I don't wanna use Docker compose here

121
00:06:00,830 --> 00:06:03,620
instead the goal is to use Kubernetes.

122
00:06:03,620 --> 00:06:05,380
And that's what we're going to get started

123
00:06:05,380 --> 00:06:07,647
with in the next lecture therefore.

