1 00:00:00,210 --> 00:00:01,530 ‫So now let's have a look 2 00:00:01,530 --> 00:00:04,860 ‫at the deployment of app updates. 3 00:00:04,860 --> 00:00:06,810 ‫So for this, let's go under configuration 4 00:00:06,810 --> 00:00:08,250 ‫on the left hand side, 5 00:00:08,250 --> 00:00:10,080 ‫and then we are in the prod environment. 6 00:00:10,080 --> 00:00:11,370 ‫We scroll down 7 00:00:11,370 --> 00:00:13,980 ‫and we are looking for updates, monitoring, and logging. 8 00:00:13,980 --> 00:00:15,930 ‫So we click on edit. 9 00:00:15,930 --> 00:00:17,850 ‫And underneath we have at some points, 10 00:00:17,850 --> 00:00:19,920 ‫rolling updates and deployments. 11 00:00:19,920 --> 00:00:21,660 ‫So we have the application deployments, 12 00:00:21,660 --> 00:00:24,780 ‫which is, okay, we deploy a new application version. 13 00:00:24,780 --> 00:00:27,810 ‫What is going to happen and how is it going to be deployed? 14 00:00:27,810 --> 00:00:31,800 ‫So here we have a couple of deployment policy. 15 00:00:31,800 --> 00:00:33,150 ‫We have all at once, 16 00:00:33,150 --> 00:00:36,630 ‫and all at once just gives your code update 17 00:00:36,630 --> 00:00:38,280 ‫to all the instances at one, 18 00:00:38,280 --> 00:00:40,770 ‫you will be down, but it will be the fastest. 19 00:00:40,770 --> 00:00:43,230 ‫As you can see, you can choose between fixed and percentage, 20 00:00:43,230 --> 00:00:45,150 ‫but actually these are disabled. 21 00:00:45,150 --> 00:00:47,640 ‫So these settings do not matter for all at once. 22 00:00:47,640 --> 00:00:50,400 ‫They're just remained within the UI for some reason. 23 00:00:50,400 --> 00:00:52,800 ‫For rolling, then these settings become available. 24 00:00:52,800 --> 00:00:55,650 ‫So we take down some instances, we upgrade them, 25 00:00:55,650 --> 00:00:58,110 ‫and then we go and move on. 26 00:00:58,110 --> 00:01:00,210 ‫So the batch size could be either a percentage, 27 00:01:00,210 --> 00:01:03,090 ‫for example, 30% of instances at a time 28 00:01:03,090 --> 00:01:06,390 ‫or fixed, for example, one instance at a time. 29 00:01:06,390 --> 00:01:07,920 ‫So this is one option. 30 00:01:07,920 --> 00:01:11,040 ‫Rolling with additional batch will add EC2 instances, 31 00:01:11,040 --> 00:01:13,890 ‫will deploy to those and then we'll keep on having a batch. 32 00:01:13,890 --> 00:01:16,890 ‫So we make sure that we maintain the same capacity 33 00:01:16,890 --> 00:01:18,870 ‫no matter what, but there is an increased cost, 34 00:01:18,870 --> 00:01:22,650 ‫because we are creating temporarily some EC2 instances 35 00:01:22,650 --> 00:01:24,360 ‫to perform this update. 36 00:01:24,360 --> 00:01:28,140 ‫And again, we can set up a percentage or a fixed. 37 00:01:28,140 --> 00:01:29,670 ‫Then we have immutable. 38 00:01:29,670 --> 00:01:32,670 ‫So immutable is creating a whole new set 39 00:01:32,670 --> 00:01:34,440 ‫of instances we deploy to, 40 00:01:34,440 --> 00:01:36,630 ‫and then we'll delete the old ones. 41 00:01:36,630 --> 00:01:38,070 ‫So that's what we'll be experimenting with. 42 00:01:38,070 --> 00:01:40,380 ‫And again, fixed and percentages don't make sense here, 43 00:01:40,380 --> 00:01:42,210 ‫so they're disabled sort of. 44 00:01:42,210 --> 00:01:43,440 ‫And then we have traffic splitting. 45 00:01:43,440 --> 00:01:46,350 ‫So to split traffic to a percentage 46 00:01:46,350 --> 00:01:48,960 ‫of new applications versions for X number of minutes 47 00:01:48,960 --> 00:01:51,030 ‫before upgrading everything. 48 00:01:51,030 --> 00:01:52,020 ‫So this is really cool. 49 00:01:52,020 --> 00:01:54,360 ‫Let's explore immutable. 50 00:01:54,360 --> 00:01:56,730 ‫Also, we have configuration updates. 51 00:01:56,730 --> 00:01:58,800 ‫So this is when you actually are updating 52 00:01:58,800 --> 00:02:01,140 ‫your EC2 instances internally 53 00:02:01,140 --> 00:02:04,050 ‫or making VPC configurations or whatever, 54 00:02:04,050 --> 00:02:06,510 ‫that should make your instances being replaced. 55 00:02:06,510 --> 00:02:09,090 ‫In that case, we can again choose a rolling 56 00:02:09,090 --> 00:02:10,650 ‫or immutable type of updates, 57 00:02:10,650 --> 00:02:12,600 ‫but the exam really doesn't test you on that part. 58 00:02:12,600 --> 00:02:15,240 ‫It tests you on the application deployment part. 59 00:02:15,240 --> 00:02:17,280 ‫So we'll explore immutable 60 00:02:17,280 --> 00:02:20,760 ‫and I will scroll down and I will apply this. 61 00:02:20,760 --> 00:02:23,970 ‫So now we apply some new configurations in our environments. 62 00:02:23,970 --> 00:02:25,200 ‫So anytime we do this, 63 00:02:25,200 --> 00:02:29,520 ‫Elastic Beanstalk is going to be updating the environment. 64 00:02:29,520 --> 00:02:31,680 ‫So in the meantime, let's go on Google 65 00:02:31,680 --> 00:02:35,793 ‫and type sample application nodejs Beanstalk. 66 00:02:36,630 --> 00:02:41,040 ‫And we are going to click on this, on those tutorials. 67 00:02:41,040 --> 00:02:44,130 ‫And then we're going to find the sample application 68 00:02:44,130 --> 00:02:46,110 ‫for Node.js. 69 00:02:46,110 --> 00:02:49,890 ‫So if we scroll down, Node.js is right here, nodejs.zip. 70 00:02:49,890 --> 00:02:52,290 ‫So you download the zip file and then you open it. 71 00:02:52,290 --> 00:02:54,420 ‫So here we have a couple of files 72 00:02:54,420 --> 00:02:56,130 ‫and we'll explore them in a second. 73 00:02:56,130 --> 00:02:59,580 ‫So this is how my application is packaged. 74 00:02:59,580 --> 00:03:03,120 ‫This is the Node.js specific part of the application. 75 00:03:03,120 --> 00:03:07,020 ‫Index of HTML is actually representing that welcome page. 76 00:03:07,020 --> 00:03:08,910 ‫So here we have couple of options. 77 00:03:08,910 --> 00:03:10,470 ‫We can set the style, 78 00:03:10,470 --> 00:03:13,140 ‫but we can also, for example, set the text, 79 00:03:13,140 --> 00:03:15,390 ‫for example, who says congratulations. 80 00:03:15,390 --> 00:03:17,460 ‫And then we have cron.yaml 81 00:03:17,460 --> 00:03:20,190 ‫which is to schedule some tasks if you wanted to. 82 00:03:20,190 --> 00:03:21,840 ‫This is to run some regular tasks 83 00:03:21,840 --> 00:03:23,610 ‫directly on our instances. 84 00:03:23,610 --> 00:03:26,130 ‫App.js, this is a Node.js part of it 85 00:03:26,130 --> 00:03:27,960 ‫where we actually create a server 86 00:03:27,960 --> 00:03:32,917 ‫and we're going to server the HTML content right here, 87 00:03:32,917 --> 00:03:34,110 ‫.gitignore we can ignore. 88 00:03:34,110 --> 00:03:37,680 ‫And then .ebextension is a way to customize 89 00:03:37,680 --> 00:03:40,350 ‫the way that Elastic Beanstalk is working 90 00:03:40,350 --> 00:03:43,835 ‫by creating configurations within that .ebextension, 91 00:03:43,835 --> 00:03:46,020 ‫.ebextensions directory. 92 00:03:46,020 --> 00:03:47,220 ‫So what we're going to do 93 00:03:47,220 --> 00:03:49,470 ‫is that we're going to change the background 94 00:03:49,470 --> 00:03:51,390 ‫from green to blue. 95 00:03:51,390 --> 00:03:54,120 ‫So the way we do it is that we find the right place. 96 00:03:54,120 --> 00:03:57,810 ‫So this is the one, background-color, textColumn, 97 00:03:57,810 --> 00:04:00,300 ‫and we're just going to enter blue. 98 00:04:00,300 --> 00:04:02,250 ‫So I can just click on blue right here, 99 00:04:02,250 --> 00:04:05,370 ‫or I can also, if this allows me to, 100 00:04:05,370 --> 00:04:07,440 ‫I can just type in blue 101 00:04:07,440 --> 00:04:08,850 ‫and it'll be good to go. 102 00:04:08,850 --> 00:04:10,740 ‫So whatever you wanna do, right? 103 00:04:10,740 --> 00:04:12,240 ‫But to set the background color, 104 00:04:12,240 --> 00:04:13,920 ‫and if you don't wanna do that, 105 00:04:13,920 --> 00:04:16,680 ‫I have packaged actually a zipped version of this, 106 00:04:16,680 --> 00:04:18,840 ‫because sometimes Elastic Beanstalk is not very happy 107 00:04:18,840 --> 00:04:20,040 ‫to how you zip thing. 108 00:04:20,040 --> 00:04:22,560 ‫I've packaged a zip version of your application 109 00:04:22,560 --> 00:04:24,030 ‫to use the blue background color. 110 00:04:24,030 --> 00:04:28,200 ‫So this is what I'm going to use in my course right now. 111 00:04:28,200 --> 00:04:30,630 ‫So let's go and deploy this new version. 112 00:04:30,630 --> 00:04:33,150 ‫So we're going to click on upload and deploy, 113 00:04:33,150 --> 00:04:35,550 ‫and then we have to choose an application file. 114 00:04:35,550 --> 00:04:38,910 ‫So under my code, find Elastic Beanstalk. 115 00:04:38,910 --> 00:04:43,783 ‫So under Beanstalk and then there is nodejs-v2-blue.zip 116 00:04:45,030 --> 00:04:46,560 ‫and we can have a version label, 117 00:04:46,560 --> 00:04:50,220 ‫for example, I'll call this one MyApplication-Blue. 118 00:04:50,220 --> 00:04:52,680 ‫And here we have deployment preferences. 119 00:04:52,680 --> 00:04:54,210 ‫So by default it's set to immutable, 120 00:04:54,210 --> 00:04:56,550 ‫because that's what we have currently set up, 121 00:04:56,550 --> 00:04:58,830 ‫but you can override it if you wanted to 122 00:04:58,830 --> 00:05:01,470 ‫with other kind of deployments, 123 00:05:01,470 --> 00:05:03,390 ‫for example, all at once, rolling, 124 00:05:03,390 --> 00:05:04,800 ‫or rolling with additional batch. 125 00:05:04,800 --> 00:05:06,030 ‫But we wanna use immutable 126 00:05:06,030 --> 00:05:09,240 ‫so we'll just submit and deploy this as immutable. 127 00:05:09,240 --> 00:05:12,423 ‫So we'll have a look at how immutable is actually working. 128 00:05:14,940 --> 00:05:16,530 ‫And so the way it works is that, 129 00:05:16,530 --> 00:05:18,150 ‫and we have to see in the events 130 00:05:18,150 --> 00:05:19,530 ‫how it's going to happen. 131 00:05:19,530 --> 00:05:23,010 ‫So let's refresh this and have a look. 132 00:05:23,010 --> 00:05:25,920 ‫So it says launching one instance with the new settings 133 00:05:25,920 --> 00:05:26,753 ‫to verify health. 134 00:05:26,753 --> 00:05:27,586 ‫So first, it makes sure 135 00:05:27,586 --> 00:05:30,810 ‫that like we can actually deploy this version 136 00:05:30,810 --> 00:05:32,190 ‫and it is working. 137 00:05:32,190 --> 00:05:33,990 ‫And this is going to be done 138 00:05:33,990 --> 00:05:36,510 ‫by creating a new auto scaling group. 139 00:05:36,510 --> 00:05:38,253 ‫So let's wait for a moment. 140 00:05:39,240 --> 00:05:43,440 ‫Okay, so now a temporary auto scaling group has been created 141 00:05:43,440 --> 00:05:46,800 ‫and this auto scaling group will have the new instance, 142 00:05:46,800 --> 00:05:48,030 ‫and, of course, we're immutable, 143 00:05:48,030 --> 00:05:50,220 ‫so we have to launch a new auto scaling group 144 00:05:50,220 --> 00:05:51,633 ‫and new instances within. 145 00:05:53,250 --> 00:05:55,980 ‫So now the instance is created 146 00:05:55,980 --> 00:05:59,820 ‫and then we have a new instance added to the load balancer 147 00:05:59,820 --> 00:06:02,490 ‫and we're waiting for the instance to pass the health check, 148 00:06:02,490 --> 00:06:03,540 ‫which it did. 149 00:06:03,540 --> 00:06:05,880 ‫So now that the instance are initialized, 150 00:06:05,880 --> 00:06:07,560 ‫we are detaching the new instances 151 00:06:07,560 --> 00:06:09,480 ‫from the temporary auto scaling group, 152 00:06:09,480 --> 00:06:12,240 ‫and we attach them to the permanent auto scaling group. 153 00:06:12,240 --> 00:06:14,280 ‫And then there's post-deployment configuration 154 00:06:14,280 --> 00:06:15,510 ‫on new instances. 155 00:06:15,510 --> 00:06:16,980 ‫And then at the end of this, 156 00:06:16,980 --> 00:06:19,380 ‫the old instances will just go away, 157 00:06:19,380 --> 00:06:21,510 ‫and immutable will have been performed. 158 00:06:21,510 --> 00:06:23,760 ‫So the deployment is complete 159 00:06:23,760 --> 00:06:26,160 ‫and things that happen is that the instance was removed 160 00:06:26,160 --> 00:06:27,420 ‫from the environment, 161 00:06:27,420 --> 00:06:29,940 ‫and then the new application deploy version was deployed, 162 00:06:29,940 --> 00:06:34,320 ‫and then everything was terminated, the old instances, 163 00:06:34,320 --> 00:06:36,270 ‫and the temporary auto scaling group. 164 00:06:36,270 --> 00:06:37,470 ‫So we're good to go. 165 00:06:37,470 --> 00:06:39,930 ‫So now if we open this in a new tab, 166 00:06:39,930 --> 00:06:42,360 ‫as we can see, congratulations is in blue. 167 00:06:42,360 --> 00:06:44,970 ‫And so we have successfully deployed this version update 168 00:06:44,970 --> 00:06:46,290 ‫into our environments. 169 00:06:46,290 --> 00:06:48,420 ‫So now the prod is displaying blue 170 00:06:48,420 --> 00:06:51,060 ‫and the dev is displaying green. 171 00:06:51,060 --> 00:06:52,830 ‫And one thing we can experiment with 172 00:06:52,830 --> 00:06:54,510 ‫is environment swapping. 173 00:06:54,510 --> 00:06:56,850 ‫So we can swap environment domains. 174 00:06:56,850 --> 00:06:58,770 ‫That means that the prod will become dev 175 00:06:58,770 --> 00:07:00,660 ‫and the dev will become prod. 176 00:07:00,660 --> 00:07:02,490 ‫And the reason we would do so 177 00:07:02,490 --> 00:07:05,430 ‫is, for example, you take this environment, 178 00:07:05,430 --> 00:07:06,840 ‫for example, prod. 179 00:07:06,840 --> 00:07:08,310 ‫First, you're going to clone it. 180 00:07:08,310 --> 00:07:11,220 ‫So you're going to create a copy of prod, 181 00:07:11,220 --> 00:07:13,980 ‫then you would deploy your new application 182 00:07:13,980 --> 00:07:15,570 ‫to the new environment 183 00:07:15,570 --> 00:07:17,760 ‫where you can perform some extensive testing. 184 00:07:17,760 --> 00:07:19,530 ‫Call it prod number two. 185 00:07:19,530 --> 00:07:21,210 ‫And then once you want prod number two 186 00:07:21,210 --> 00:07:22,980 ‫to become prod number one, 187 00:07:22,980 --> 00:07:24,750 ‫you would swap environment domains 188 00:07:24,750 --> 00:07:26,970 ‫and then the URLs will be swapped. 189 00:07:26,970 --> 00:07:29,700 ‫So I'm going to demo the swap environment domain, 190 00:07:29,700 --> 00:07:31,200 ‫but using prod and dev. 191 00:07:31,200 --> 00:07:34,260 ‫So this is blue and then this is green, 192 00:07:34,260 --> 00:07:37,110 ‫but let's swap environment domains and see what happens. 193 00:07:37,110 --> 00:07:42,110 ‫So we are going to swap this with dev and click on swap. 194 00:07:42,480 --> 00:07:46,140 ‫So swap environment domain has to do with DNS 195 00:07:46,140 --> 00:07:48,450 ‫and entries, and they're going to be modified. 196 00:07:48,450 --> 00:07:51,930 ‫So that one is pointing to the other and vice versa. 197 00:07:51,930 --> 00:07:53,670 ‫So this may take a bit of time 198 00:07:53,670 --> 00:07:56,520 ‫to be updated and also to reflect the updates, 199 00:07:56,520 --> 00:07:59,010 ‫because DNS updates can be slow sometimes. 200 00:07:59,010 --> 00:08:01,800 ‫So I'm going to wait five more minutes and get back to you. 201 00:08:01,800 --> 00:08:03,930 ‫So my update is now done, 202 00:08:03,930 --> 00:08:06,960 ‫and if I go onto my prod environment and refresh, 203 00:08:06,960 --> 00:08:07,830 ‫I see now green. 204 00:08:07,830 --> 00:08:09,840 ‫And if I go to my green environment and refresh, 205 00:08:09,840 --> 00:08:10,920 ‫I see now blue. 206 00:08:10,920 --> 00:08:13,320 ‫So indeed the environments have been swapped, 207 00:08:13,320 --> 00:08:15,660 ‫and everything is working as expected 208 00:08:15,660 --> 00:08:17,700 ‫which is, I think, pretty cool. 209 00:08:17,700 --> 00:08:19,740 ‫So that's it for this lecture. 210 00:08:19,740 --> 00:08:22,920 ‫What I'm going to do is just re-swap the environment domains 211 00:08:22,920 --> 00:08:26,580 ‫just to have the blue as prod, and the green as dev, 212 00:08:26,580 --> 00:08:27,600 ‫but we're good to go. 213 00:08:27,600 --> 00:08:29,190 ‫So we've seen all the deployment options. 214 00:08:29,190 --> 00:08:32,130 ‫We've seen about cloning, we've seen swapping URLs, 215 00:08:32,130 --> 00:08:33,420 ‫and I hope you liked it. 216 00:08:33,420 --> 00:08:35,170 ‫I will see you in the next lecture.