1
00:00:02,360 --> 00:00:04,860
So now that we saw all these different ways

2
00:00:04,860 --> 00:00:07,850
of connecting pods and containers,

3
00:00:07,850 --> 00:00:11,670
the question of course is, which approach is the best one

4
00:00:11,670 --> 00:00:14,170
and how can we finalize this picture

5
00:00:14,170 --> 00:00:17,960
and make sure the tasks API also works?

6
00:00:17,960 --> 00:00:20,610
Well regarding the best approach,

7
00:00:20,610 --> 00:00:22,620
it of course depends on whether you wanna

8
00:00:22,620 --> 00:00:25,650
have two containers in the same pod or not.

9
00:00:25,650 --> 00:00:29,020
And in most cases you don't wanna

10
00:00:29,020 --> 00:00:31,170
have multiple containers per pod.

11
00:00:31,170 --> 00:00:33,940
You can have it, but you should really only do that,

12
00:00:33,940 --> 00:00:36,830
if two containers are tightly coupled,

13
00:00:36,830 --> 00:00:41,140
with each other, if some container also interacts

14
00:00:41,140 --> 00:00:44,740
with another container in another pod, like we have it here

15
00:00:44,740 --> 00:00:47,330
you definitely do wanna have that container

16
00:00:47,330 --> 00:00:50,280
in a separate pod, which is why we are working

17
00:00:50,280 --> 00:00:51,820
with free pods here,

18
00:00:51,820 --> 00:00:55,700
and not just to pause as planned initially.

19
00:00:55,700 --> 00:00:57,870
Now, when it comes to connecting pods

20
00:00:57,870 --> 00:01:01,680
with each other, then we got three different options,

21
00:01:01,680 --> 00:01:04,340
we of course need services for the different pods,

22
00:01:04,340 --> 00:01:05,710
that's always the case

23
00:01:05,710 --> 00:01:08,435
because that gives us stable IP addresses,

24
00:01:08,435 --> 00:01:12,520
even if it's just a cluster internal IP address,

25
00:01:12,520 --> 00:01:14,860
but then when it comes to sending requests

26
00:01:14,860 --> 00:01:18,720
to that service, we can either look up the IP address

27
00:01:18,720 --> 00:01:21,490
on our own and then use it in our code.

28
00:01:21,490 --> 00:01:23,833
For example, through an environment variable,

29
00:01:24,780 --> 00:01:29,640
or we use the automatically generated environment variables,

30
00:01:29,640 --> 00:01:32,980
a feature Kubernetes has built in, to give us access

31
00:01:32,980 --> 00:01:35,890
to the IP addresses, of the different services

32
00:01:35,890 --> 00:01:37,263
our cluster has,

33
00:01:38,300 --> 00:01:42,390
or we use the automatically generated domain names,

34
00:01:42,390 --> 00:01:45,690
these names are all generated for every service,

35
00:01:45,690 --> 00:01:47,300
which is launched in a cluster,

36
00:01:47,300 --> 00:01:51,340
and we can use that domain name from inside the cluster

37
00:01:51,340 --> 00:01:53,460
to send the request there.

38
00:01:53,460 --> 00:01:55,870
So these are the different options we got there,

39
00:01:55,870 --> 00:01:58,840
and the domain names are the most common way

40
00:01:58,840 --> 00:02:01,070
of connecting pause here,

41
00:02:01,070 --> 00:02:04,380
because they are easy to remember, easy to add,

42
00:02:04,380 --> 00:02:07,260
you don't need to fiddle around with environment variables,

43
00:02:07,260 --> 00:02:11,840
if you don't want to hear, I do want to make this work both

44
00:02:11,840 --> 00:02:14,580
in Kubernetes and with docker-compose,

45
00:02:14,580 --> 00:02:16,930
but even then, it's simply a bit easier

46
00:02:16,930 --> 00:02:19,900
than looking up an IP address manually,

47
00:02:19,900 --> 00:02:24,770
or typing this longer auto-generated environment variable.

48
00:02:24,770 --> 00:02:27,760
Ultimately of course, you can choose your favorite approach

49
00:02:27,760 --> 00:02:29,240
and then connect the pods

50
00:02:29,240 --> 00:02:32,143
and containers as it best works for you,

51
00:02:33,420 --> 00:02:36,740
with that however we are, of course not done,

52
00:02:36,740 --> 00:02:41,740
we also want to deploy this tasks, API, the tasks container

53
00:02:41,740 --> 00:02:46,310
and make sure it's able to talk to the auth API as well.

54
00:02:46,310 --> 00:02:49,630
And I would say that's a great exercise for you,

55
00:02:49,630 --> 00:02:51,250
so definitely try doing this

56
00:02:51,250 --> 00:02:54,330
on your own first, create a deployment for that,

57
00:02:54,330 --> 00:02:57,150
create a service, make sure to tasks API

58
00:02:57,150 --> 00:02:59,570
can be reached from outside the cluster,

59
00:02:59,570 --> 00:03:03,880
but also make sure it's able to talk to the auth API.

60
00:03:03,880 --> 00:03:07,343
We're going to implement it together in the next lecture.

