1 00:00:00,056 --> 00:00:03,421 [Intro Music] 2 00:00:04,914 --> 00:00:06,726 Hello and welcome to this lecture. 3 00:00:07,291 --> 00:00:10,815 In this lecture, we will discuss about Kubernetes Deployments. 4 00:00:12,680 --> 00:00:15,486 For a minute, let us forget about PODs 5 00:00:15,549 --> 00:00:18,830 and ReplicaSets and other Kubernetes concepts, 6 00:00:19,156 --> 00:00:22,578 and talk about how you might want to deploy your application 7 00:00:22,680 --> 00:00:24,135 in a production environment. 8 00:00:24,775 --> 00:00:25,877 Say for example, 9 00:00:26,268 --> 00:00:30,344 you have a web server that needs to be deployed in a production environment. 10 00:00:30,883 --> 00:00:35,346 You need not one but many such instances of the web server running 11 00:00:35,502 --> 00:00:36,822 for obvious reasons. 12 00:00:37,539 --> 00:00:41,494 Secondly, whenever newer versions of application builds 13 00:00:41,596 --> 00:00:43,893 become available on the Docker registry, 14 00:00:44,319 --> 00:00:47,998 you would like to upgrade your Docker instances seamlessly. 15 00:00:48,398 --> 00:00:51,258 However, when you upgrade your instances, 16 00:00:51,563 --> 00:00:55,268 you do not want to upgrade all of them at once as we just did, 17 00:00:55,768 --> 00:00:59,004 this may impact users accessing our applications, so 18 00:00:59,403 --> 00:01:01,918 you might want to upgrade them one after the other, 19 00:01:02,546 --> 00:01:05,724 and that kind of upgrade is known as rolling updates. 20 00:01:06,578 --> 00:01:11,172 Suppose one of the upgrades you performed resulted in an unexpected error, 21 00:01:11,359 --> 00:01:13,986 and you're asked to undo the recent change, 22 00:01:14,510 --> 00:01:18,723 you would like to be able to rollback the changes that were recently carried out. 23 00:01:19,766 --> 00:01:22,563 Finally say for example, you would like to make 24 00:01:22,682 --> 00:01:24,682 multiple changes to your environment, 25 00:01:24,852 --> 00:01:27,955 such as upgrading the underlying web server versions, 26 00:01:28,424 --> 00:01:33,252 as well as scaling your environment and also modifying the resource allocations, etc. 27 00:01:33,766 --> 00:01:38,791 You do not want to apply each change immediately after the command is run, instead 28 00:01:39,213 --> 00:01:41,984 you would like to apply a pause to your environment, 29 00:01:42,023 --> 00:01:44,531 make the changes and then resume, so that 30 00:01:44,627 --> 00:01:46,768 all the changes are rolled out together. 31 00:01:47,695 --> 00:01:51,881 All of these capabilities are available with the Kubernetes Deployments. 32 00:01:52,406 --> 00:01:55,344 So far, in this course, we discussed about pods, 33 00:01:55,578 --> 00:01:59,010 which deploy single instances of our application, 34 00:01:59,127 --> 00:02:01,400 such as the web application in this case. 35 00:02:02,190 --> 00:02:04,916 Each container is encapsulated in pods. 36 00:02:05,494 --> 00:02:10,705 Multiple such pods are deployed using ReplicationControllers or ReplicaSets, 37 00:02:11,549 --> 00:02:14,414 and then comes deployment, which is a Kubernetes 38 00:02:14,525 --> 00:02:17,305 object that comes higher in the hierarchy. 39 00:02:18,065 --> 00:02:20,955 The deployment provides us with the capability 40 00:02:21,258 --> 00:02:25,846 to upgrade the underlying instances seamlessly using rolling updates, 41 00:02:26,174 --> 00:02:30,035 undo changes, and pause and resume changes as required. 42 00:02:31,250 --> 00:02:33,088 So how do we create a deployment? 43 00:02:33,830 --> 00:02:38,395 As with the previous components, we first create a deployment-definition file. 44 00:02:38,854 --> 00:02:41,127 The contents of the deployment-definition file 45 00:02:41,244 --> 00:02:44,602 are exactly similar to the replicaset-definition file, 46 00:02:45,018 --> 00:02:48,580 except for the kind, which is now going to be Deployment. 47 00:02:49,273 --> 00:02:52,861 If we worked through the contents of the file, it has an apiVersion, 48 00:02:52,955 --> 00:02:55,294 which is apps/v1; 49 00:02:55,738 --> 00:02:58,068 metadata, which has name and labels; 50 00:02:58,123 --> 00:03:01,461 and a spec that has template replicas and selector. 51 00:03:02,260 --> 00:03:05,275 The template has a pod definition inside it. 52 00:03:06,375 --> 00:03:08,859 Once the file is ready, run the kubectl 53 00:03:08,977 --> 00:03:12,291 create command and specify the deployment-definition file. 54 00:03:13,078 --> 00:03:16,629 Then run the kubectl get deployments command 55 00:03:16,629 --> 00:03:18,629 to see the newly created deployment. 56 00:03:19,160 --> 00:03:22,109 The Deployment automatically creates a ReplicaSet, 57 00:03:22,367 --> 00:03:25,277 so if you run the kubectl get replicaset command, 58 00:03:25,465 --> 00:03:29,842 you will be able to see a new ReplicaSet in the name of the Deployment. 59 00:03:30,586 --> 00:03:33,203 The ReplicaSets ultimately create pods; 60 00:03:33,460 --> 00:03:36,140 so if you run the kubectl get pods command, 61 00:03:36,580 --> 00:03:41,041 you will be able to see the pods with the name of the deployment and the ReplicaSet. 62 00:03:42,047 --> 00:03:44,619 So far, there hasn't been much of a 63 00:03:44,619 --> 00:03:47,200 difference between ReplicaSet and deployments, 64 00:03:47,641 --> 00:03:49,682 except for the fact that deployment 65 00:03:49,806 --> 00:03:53,211 created a new Kubernetes object called deployment. 66 00:03:54,178 --> 00:03:56,803 We will see how to take advantage of the deployment 67 00:03:56,935 --> 00:04:01,391 using the use cases we discussed in the previous slide in the upcoming lectures. 68 00:04:02,953 --> 00:04:05,664 And one more note before we end this lecture 69 00:04:05,906 --> 00:04:08,547 to see all the created objects at once 70 00:04:09,033 --> 00:04:11,729 run the kubectl get all command, 71 00:04:12,471 --> 00:04:15,336 and in this case, we can see that the deployment 72 00:04:15,578 --> 00:04:18,327 was created and then we have the ReplicaSet 73 00:04:18,572 --> 00:04:22,548 followed by three pods that were created as part of the deployment. 74 00:04:22,611 --> 00:04:24,572 [No Audio] 75 00:04:24,644 --> 00:04:27,379 That's it for this lecture, we will now head over to a demo 76 00:04:27,473 --> 00:04:29,281 and I will see you in the next lecture. 77 00:04:29,312 --> 00:04:30,648 [Outro Music] 78 00:04:30,648 --> 00:04:32,811 [No Audio]