1 00:00:01,250 --> 00:00:04,230 In this video we're going to start to write out a config file for a deployment. 2 00:00:04,280 --> 00:00:05,140 So let's get to it. 3 00:00:06,070 --> 00:00:06,580 Back inside. 4 00:00:06,580 --> 00:00:11,670 My code Ed I'm going to delete the post dot gamble file if you want to. 5 00:00:11,680 --> 00:00:14,160 You can back up this file or just change the extension. 6 00:00:14,160 --> 00:00:17,520 Something like that you want to make sure you don't have this file anymore. 7 00:00:17,530 --> 00:00:22,570 So if you want to keep a backup I would encourage you to add on a like dot old or something like that 8 00:00:22,570 --> 00:00:24,450 extension to the very end. 9 00:00:24,630 --> 00:00:30,330 Going to delete that file because we don't want to create an individual pod anymore and then inside 10 00:00:30,330 --> 00:00:37,950 my aids directory I'm gonna make a new file called Post dash devil dot yellow devil on there indicates 11 00:00:37,950 --> 00:00:39,810 that this file is going to create a deployment. 12 00:00:40,020 --> 00:00:41,950 So devil is just deployment for short. 13 00:00:42,000 --> 00:00:45,450 That's all inside if you're ever gonna write out. 14 00:00:45,460 --> 00:00:49,720 Once again some config to create a deployment inside this config we're going to say that we want to 15 00:00:49,720 --> 00:00:53,560 run some number of pods that are going to run our post image. 16 00:00:53,560 --> 00:00:55,040 So let's get to it a lot. 17 00:00:55,060 --> 00:00:59,110 The code or configuration we're going to write inside of here is going to be very similar to the stuff 18 00:00:59,110 --> 00:01:01,630 that we just wrote out for a pod. 19 00:01:01,790 --> 00:01:07,400 Well first start off with an API version and in this case they're going to put an apps slash V1. 20 00:01:08,080 --> 00:01:12,630 So remember there are certain buckets of different types of objects we have access to. 21 00:01:12,810 --> 00:01:18,810 In this case the deployment is inside this bucket of different objects called Apps slash be one a pod 22 00:01:18,840 --> 00:01:24,560 as you will recall was inside of just the one will then specify the kind of object that we're trying 23 00:01:24,560 --> 00:01:25,480 to create. 24 00:01:25,490 --> 00:01:28,930 It's a deployment will then set up some metadata. 25 00:01:29,030 --> 00:01:31,260 And in this case we're just going to assign a name to it. 26 00:01:31,720 --> 00:01:37,060 So let's say posts dash devil that is going to be the name of my deployment again I'm putting on the 27 00:01:37,060 --> 00:01:41,740 dash depot here so that if I ever print out some logs or something like that about all the objects inside 28 00:01:41,740 --> 00:01:43,280 my cluster I'll see double. 29 00:01:43,300 --> 00:01:50,480 And know that this is a deployment after that I'll put in a spec section but this is going to specify 30 00:01:50,480 --> 00:01:56,660 exactly how this deployment should behave the first property will designate inside of here is replicas 31 00:01:58,110 --> 00:02:03,480 and I'm gonna give it a one for right now replicas is the number of pods we want to create running some 32 00:02:03,480 --> 00:02:09,400 particular image so in this diagram over here I'm showing three separate pods. 33 00:02:09,400 --> 00:02:15,530 Right now we're not going to run three separate pods we're going to run just one by itself. 34 00:02:15,590 --> 00:02:19,030 Now the next a little piece of configuration here is going to be just a little bit mysterious. 35 00:02:19,070 --> 00:02:24,170 So we'll write it out and then take it right out a little bit additional config after that and we'll 36 00:02:24,170 --> 00:02:27,120 talk about how these two parts of config kind of work together. 37 00:02:27,230 --> 00:02:37,960 So going to say selector then match labels and then app post remember that inside of a gamble file indentation 38 00:02:38,020 --> 00:02:38,910 is a big deal. 39 00:02:38,920 --> 00:02:45,000 So you need to make sure that you've got one level of indentation on selector then two and then three. 40 00:02:45,020 --> 00:02:47,450 So again we'll talk about what this is in just a second. 41 00:02:47,450 --> 00:02:54,740 First we're gonna write out another little bit of config I'm gonna say template then metadata labels 42 00:02:58,020 --> 00:03:01,400 and then app notes all right. 43 00:03:01,460 --> 00:03:06,170 So these two sections right here the selector thing and this metadata thing right here are really working 44 00:03:06,170 --> 00:03:06,970 together. 45 00:03:06,980 --> 00:03:13,730 This might sound really in it's funny it might sound like crazy but to be honest with you a deployment 46 00:03:13,730 --> 00:03:18,890 kind of has a hard time figuring out which pods it should manage inside of our cluster. 47 00:03:18,920 --> 00:03:23,870 In other words if a set of pods get created we have to somehow give the deployment some information 48 00:03:23,900 --> 00:03:25,910 and tell it hey these pods over here. 49 00:03:25,920 --> 00:03:31,210 These are the ones you need to manage and that's what the goal of this selector and metadata labels 50 00:03:31,270 --> 00:03:36,200 app thing is all about the selector right here is saying take a look at all the different pods that 51 00:03:36,200 --> 00:03:41,270 have been created by an all the pods with a label of app os. 52 00:03:41,660 --> 00:03:45,340 So this right here is what I refer to as a label as essentially well a label. 53 00:03:45,350 --> 00:03:51,230 It's a key value pair that is just applying some arbitrary information to a pod app right here doesn't 54 00:03:51,230 --> 00:03:52,420 really have any special meaning. 55 00:03:52,520 --> 00:03:57,290 We can set up labels with any structure you can imagine so we can have a label of like that right there. 56 00:03:59,120 --> 00:04:03,080 So in this case we are telling the deployment that we wanted to find all the different pods with the 57 00:04:03,080 --> 00:04:09,800 label of app hosts and those are the pods that it should be in charge of then inside this template section. 58 00:04:09,800 --> 00:04:15,560 The template is where we specify the exact configuration of a pod that we want this deployment to create 59 00:04:16,640 --> 00:04:20,610 so this right here is some configuration that is going to be applied to the pod that the deployment 60 00:04:20,610 --> 00:04:21,960 is going to make. 61 00:04:21,960 --> 00:04:25,580 We are saying that we want the pod to have a label of app posts. 62 00:04:26,250 --> 00:04:30,630 So again this part right here and this part right here are really working together to tell the deployment 63 00:04:30,750 --> 00:04:38,480 about which pods it should try to manage after that will then set up a spec this back again. 64 00:04:38,480 --> 00:04:43,640 Everything inside this template thing right here can be really thought of as a pod spec or a pod config 65 00:04:43,640 --> 00:04:48,710 file very similar to the pod config file we had just a moment ago to the spec section right here is 66 00:04:48,710 --> 00:04:54,350 describing the specification or the configuration options where the pod that we're trying to make so 67 00:04:54,400 --> 00:04:59,730 we will designate containers we're going to have one container so containers is an array remember and 68 00:04:59,740 --> 00:05:03,310 inside of a gamble we designate an array entry with a single Dash. 69 00:05:03,760 --> 00:05:10,220 We'll say that the container should have a name of post and it should run the image of your dock or 70 00:05:10,220 --> 00:05:17,130 I.D. so not mine whatever your Docker I.D. is flash posts and then version 0 0 1. 71 00:05:17,180 --> 00:05:19,940 Like so and that's it. 72 00:05:19,940 --> 00:05:22,190 That is our deployment config. 73 00:05:22,190 --> 00:05:26,060 Now over time you're going to see that there are many other options or pieces of configuration we can 74 00:05:26,060 --> 00:05:27,220 specify in here. 75 00:05:27,230 --> 00:05:34,040 This is about as barebones a configuration as we can get when we are creating a deployment let's save 76 00:05:34,040 --> 00:05:34,980 this. 77 00:05:35,150 --> 00:05:39,440 And then finally we're going to go back over to our terminal and we're going to try to apply this to 78 00:05:39,440 --> 00:05:40,580 our cluster. 79 00:05:40,580 --> 00:05:44,690 Remember anytime we want to make a change or a cluster recreate those config files then we will run 80 00:05:44,690 --> 00:05:49,600 that cube GTL apply command that we saw that we used just a moment ago to create a pod. 81 00:05:49,970 --> 00:06:00,080 So to apply this config file we will run cube Seitel apply dash F and then post devil dot yellow and 82 00:06:00,080 --> 00:06:01,340 that's it. 83 00:06:01,340 --> 00:06:05,360 Now the deployment has been created but what does that really do for us. 84 00:06:05,360 --> 00:06:06,830 Well let's take a quick pause right here. 85 00:06:06,860 --> 00:06:11,150 We're gonna come back the next video and we'll see what creating the deployment really did to our cluster.