1
00:00:02,250 --> 00:00:04,160
Now besides making changes easily,

2
00:00:04,160 --> 00:00:07,530
you can also merge multiple files into one easily.

3
00:00:07,530 --> 00:00:09,230
For example here, you could of course

4
00:00:09,230 --> 00:00:11,200
argue that this service

5
00:00:11,200 --> 00:00:13,750
is closely related with this deployment

6
00:00:13,750 --> 00:00:17,100
and having multiple files could be what you want.

7
00:00:17,100 --> 00:00:18,640
It can have advantages.

8
00:00:18,640 --> 00:00:21,710
For example, it's clear where the service is defined.

9
00:00:21,710 --> 00:00:24,460
But you could also argue that you wanna have one file

10
00:00:24,460 --> 00:00:27,310
with all the related things in it.

11
00:00:27,310 --> 00:00:32,310
So we could add a new file, maybe master-deployment.yaml.

12
00:00:33,610 --> 00:00:35,550
The filename is up to you of course.

13
00:00:35,550 --> 00:00:37,280
And then you could grab the content

14
00:00:37,280 --> 00:00:40,513
from the deployment.yaml file and move it in here.

15
00:00:41,520 --> 00:00:44,270
And you can move another resource definition

16
00:00:44,270 --> 00:00:45,600
into the same file.

17
00:00:45,600 --> 00:00:48,180
You can have as many resource definitions

18
00:00:48,180 --> 00:00:50,720
in one of the same file as you want.

19
00:00:50,720 --> 00:00:53,590
So in this case the service.yaml configuration,

20
00:00:53,590 --> 00:00:56,960
I copy that and go to master-deployment

21
00:00:56,960 --> 00:01:01,270
and I add it above my deployment config here

22
00:01:01,270 --> 00:01:03,520
and the only thing you need as a separator

23
00:01:03,520 --> 00:01:06,450
is these three dashes.

24
00:01:06,450 --> 00:01:08,330
And it must be three dashes.

25
00:01:08,330 --> 00:01:11,200
Not two, not four. It must be three

26
00:01:11,200 --> 00:01:13,890
because this is a YAML-specific syntax

27
00:01:13,890 --> 00:01:18,890
which basically means a brand new object starts thereafter.

28
00:01:18,960 --> 00:01:20,840
So you have these three dashes

29
00:01:20,840 --> 00:01:23,250
between all your resource definitions

30
00:01:23,250 --> 00:01:26,390
and you can then have as many resource definitions

31
00:01:26,390 --> 00:01:28,890
in this file as you want.

32
00:01:28,890 --> 00:01:30,250
As a little side note,

33
00:01:30,250 --> 00:01:32,680
if you combine a service and a deployment

34
00:01:32,680 --> 00:01:34,460
in one of the same file,

35
00:01:34,460 --> 00:01:37,680
it is a good practice to put the service first

36
00:01:37,680 --> 00:01:40,340
so that this resource is created first

37
00:01:40,340 --> 00:01:43,630
because resources are created from top to bottom

38
00:01:43,630 --> 00:01:46,000
because since it has the selector,

39
00:01:46,000 --> 00:01:48,610
it will then dynamically add any parts

40
00:01:48,610 --> 00:01:51,100
which are created thereafter.

41
00:01:51,100 --> 00:01:53,620
It would also work in the other order,

42
00:01:53,620 --> 00:01:56,630
but that is considered to be a better practice.

43
00:01:56,630 --> 00:01:58,920
And as a side note, it is really important

44
00:01:58,920 --> 00:02:01,980
to keep in mind that these objects

45
00:02:01,980 --> 00:02:04,930
are living organisms in the cluster.

46
00:02:04,930 --> 00:02:06,600
When a service is created,

47
00:02:06,600 --> 00:02:09,350
it's not created and analyzed once,

48
00:02:09,350 --> 00:02:12,500
but it continuously monitors all the parts

49
00:02:12,500 --> 00:02:16,000
which are created and removed in your application

50
00:02:16,000 --> 00:02:18,490
and if a new part is created

51
00:02:18,490 --> 00:02:20,680
which matches this label selector,

52
00:02:20,680 --> 00:02:23,720
it will be added to this service.

53
00:02:23,720 --> 00:02:27,110
That's why creating it first is no problem here,

54
00:02:27,110 --> 00:02:29,143
but is instead recommended.

55
00:02:30,100 --> 00:02:32,680
Well and with that let's actually

56
00:02:32,680 --> 00:02:35,740
delete our deployed resources

57
00:02:36,610 --> 00:02:39,800
and then apply this merged file.

58
00:02:39,800 --> 00:02:44,590
Now to delete something we can simply run delete -f

59
00:02:44,590 --> 00:02:47,170
and point at the files we wanna delete

60
00:02:47,170 --> 00:02:51,010
so here deployment.yaml and then another -f command

61
00:02:52,630 --> 00:02:54,500
to also delete what was created

62
00:02:54,500 --> 00:02:57,260
because of the service.yaml file like this.

63
00:02:57,260 --> 00:02:59,250
And now you see the respective deployment

64
00:02:59,250 --> 00:03:01,650
and service was deleted.

65
00:03:01,650 --> 00:03:06,650
And then we can simply apply this one single file

66
00:03:07,440 --> 00:03:10,140
with this command here

67
00:03:10,140 --> 00:03:15,140
so Q+Control apply -f equals master-deployment.yaml

68
00:03:15,930 --> 00:03:18,380
and now both the service and the deployment

69
00:03:18,380 --> 00:03:20,283
is created simultaneously.

70
00:03:21,670 --> 00:03:23,880
Now I just wanna expose the service again

71
00:03:23,880 --> 00:03:26,423
by running minikube service backend.

72
00:03:28,010 --> 00:03:28,960
Something we need to do

73
00:03:28,960 --> 00:03:31,200
in this local development environment

74
00:03:31,200 --> 00:03:33,990
and then again it's this URL

75
00:03:33,990 --> 00:03:36,870
which you can use to view your running application.

76
00:03:36,870 --> 00:03:40,380
And that's how you can merge multiple files together

77
00:03:40,380 --> 00:03:41,563
into one file.

