1
00:00:02,130 --> 00:00:04,800
So we now get started with the basics

2
00:00:04,800 --> 00:00:07,350
of Kubernetes and of interacting

3
00:00:07,350 --> 00:00:09,460
with our Kubernetes cluster.

4
00:00:09,460 --> 00:00:11,930
We learned how to create a deployment

5
00:00:11,930 --> 00:00:15,070
with the create deployment command.

6
00:00:15,070 --> 00:00:18,400
We of course, also learned how to update the image

7
00:00:18,400 --> 00:00:21,140
of deployment with the set image command.

8
00:00:21,140 --> 00:00:23,250
And we saw a couple of other commands

9
00:00:23,250 --> 00:00:25,960
like the expose command as well.

10
00:00:25,960 --> 00:00:30,210
But there's one potential problem with all these commands.

11
00:00:30,210 --> 00:00:33,180
For one, you of course have to memorize them.

12
00:00:33,180 --> 00:00:34,960
But that's not too difficult,

13
00:00:34,960 --> 00:00:38,590
since you'll use the same set of commands all the time.

14
00:00:38,590 --> 00:00:41,550
But you also have to repeat them all the time.

15
00:00:41,550 --> 00:00:44,650
It's a little bit like earlier in the course,

16
00:00:44,650 --> 00:00:47,320
where we always execute a docker run.

17
00:00:47,320 --> 00:00:51,750
And if we had a project with multiple containers in it,

18
00:00:51,750 --> 00:00:55,080
we had to run docker run quite a lot.

19
00:00:55,080 --> 00:00:58,400
That was when we learned about docker-compose,

20
00:00:58,400 --> 00:01:02,410
which all of a sudden allowed us to write down

21
00:01:02,410 --> 00:01:05,480
how containers should be built and started

22
00:01:05,480 --> 00:01:09,470
in a compose yaml file, and docker-compose up

23
00:01:09,470 --> 00:01:13,960
which then pick up that file and apply these instructions

24
00:01:13,960 --> 00:01:17,880
and build and start multiple containers at once.

25
00:01:17,880 --> 00:01:21,640
And therefore docker-compose could even be helpful

26
00:01:21,640 --> 00:01:25,550
if we just work with one container, because we can put all

27
00:01:25,550 --> 00:01:29,640
the run configuration into a file, and we don't have

28
00:01:29,640 --> 00:01:33,440
to type long docker run commands all the time.

29
00:01:33,440 --> 00:01:36,410
Now, that was earlier in the course,

30
00:01:36,410 --> 00:01:40,173
now we have kind of a similar problem with kubectl.

31
00:01:41,120 --> 00:01:43,970
Instead of writing all these commands manually,

32
00:01:43,970 --> 00:01:48,580
it would be nice if we could write down our deployment

33
00:01:48,580 --> 00:01:51,540
and Service Configuration into a file.

34
00:01:51,540 --> 00:01:55,590
And we could then just apply that file to our cluster

35
00:01:55,590 --> 00:01:57,750
to then create a new deployment based

36
00:01:57,750 --> 00:02:00,790
on the configuration in the file, for example.

37
00:02:00,790 --> 00:02:03,940
And Kubernetes supports that.

38
00:02:03,940 --> 00:02:06,310
Kubernetes allows us to create

39
00:02:06,310 --> 00:02:09,490
so called resource definition files,

40
00:02:09,490 --> 00:02:11,980
which looks something like this.

41
00:02:11,980 --> 00:02:15,050
And this is just one example of course.

42
00:02:15,050 --> 00:02:20,050
We can write down configuration options in a yaml file,

43
00:02:20,660 --> 00:02:22,690
and do that for different kinds

44
00:02:22,690 --> 00:02:25,400
of objects Kubernetes understands.

45
00:02:25,400 --> 00:02:29,850
For example, here on this slide for the deployment object

46
00:02:29,850 --> 00:02:33,830
to define how a deployment should be performed,

47
00:02:33,830 --> 00:02:36,560
which containers should be launched in this deployment,

48
00:02:36,560 --> 00:02:41,340
how many instances of our pods we want, and so on.

49
00:02:41,340 --> 00:02:43,560
And this is an alternative

50
00:02:43,560 --> 00:02:47,170
to the imperative approach we saw before.

51
00:02:47,170 --> 00:02:48,980
With the imperative approach,

52
00:02:48,980 --> 00:02:52,320
we always ran these kubectl commands,

53
00:02:52,320 --> 00:02:55,480
and we had to execute these individual commands

54
00:02:55,480 --> 00:02:59,203
to trigger different actions on our Kubernetes cluster.

55
00:03:00,270 --> 00:03:03,130
This is comparable to using only docker run,

56
00:03:03,130 --> 00:03:05,420
as I mentioned a second ago.

57
00:03:05,420 --> 00:03:08,700
Now with the declarative approach, it's different.

58
00:03:08,700 --> 00:03:10,970
There, we will run another command,

59
00:03:10,970 --> 00:03:14,500
which we haven't seen thus far, the apply command,

60
00:03:14,500 --> 00:03:17,170
and will simply point at a yaml file,

61
00:03:17,170 --> 00:03:19,620
which contains our configuration,

62
00:03:19,620 --> 00:03:22,430
which we want apply to the cluster.

63
00:03:22,430 --> 00:03:25,330
And that configuration could contain information

64
00:03:25,330 --> 00:03:27,230
about a deployment.

65
00:03:27,230 --> 00:03:29,610
And this conflict file is then used

66
00:03:29,610 --> 00:03:32,430
to define our desired target state.

67
00:03:32,430 --> 00:03:34,530
And whenever we apply it,

68
00:03:34,530 --> 00:03:37,810
Kubernetes will use that target state

69
00:03:37,810 --> 00:03:42,140
and do whatever it takes to make that the current state.

70
00:03:42,140 --> 00:03:45,300
And if we then for example, change a configuration file

71
00:03:45,300 --> 00:03:49,810
and reapply it, Kubernetes will have a look at what changed

72
00:03:49,810 --> 00:03:54,280
and make the appropriate changes on our running cluster

73
00:03:54,280 --> 00:03:56,640
and the running application there.

74
00:03:56,640 --> 00:03:58,380
And therefore data is comparable

75
00:03:58,380 --> 00:04:00,750
to Docker Compose in a certain sense,

76
00:04:00,750 --> 00:04:04,250
because now we can use our configuration files

77
00:04:04,250 --> 00:04:07,050
and we don't have to run a bunch of individual commands.

78
00:04:08,260 --> 00:04:09,943
So let's see this in action now.

