WEBVTT 0:00:02.660000 --> 0:00:10.260000 In this video, I'm going to demonstrate how to deploy a website to an 0:00:10.260000 --> 0:00:11.700000 Azure Kubernetes service. 0:00:11.700000 --> 0:00:12.940000 This is pretty straightforward. 0:00:12.940000 --> 0:00:16.860000 That is really what the list of topics are is a straight demonstration. 0:00:16.860000 --> 0:00:20.900000 But I'll be taking some time as we go through this in particular to go 0:00:20.900000 --> 0:00:25.820000 through an example of a Kubernetes deployment file. 0:00:25.820000 --> 0:00:29.580000 And other than the Kubernetes deployment file, as you'll see, deploying 0:00:29.580000 --> 0:00:34.320000 a solution into Kubernetes, the deployment process itself is really, really 0:00:34.320000 --> 0:00:38.380000 simple. So let's go ahead and let's take a look at this. 0:00:38.380000 --> 0:00:44.620000 I'm going to start out going into what I need to do to actually deploy 0:00:44.620000 --> 0:00:46.400000 things into Kubernetes. 0:00:46.400000 --> 0:00:51.500000 And this is where having Kubernetes in Azure makes life really pretty 0:00:51.500000 --> 0:00:59.540000 simple. Okay, Kubernetes has its own, let's see if I can bump up the font 0:00:59.540000 --> 0:01:00.220000 here a little bit. 0:01:00.220000 --> 0:01:03.160000 There we go, make it a little more visible. 0:01:03.160000 --> 0:01:09.980000 Okay, Kubernetes has its own CLI, a cube control, and you can deploy that, 0:01:09.980000 --> 0:01:12.880000 but you need to authenticate into Kubernetes. 0:01:12.880000 --> 0:01:21.760000 The really cool thing is, if it is an AKS, I've got this Azure CLI statement, 0:01:21.760000 --> 0:01:23.560000 as long as it says, okay, let me go ahead and download the credentials 0:01:23.560000 --> 0:01:28.760000 and use the credentials for that particular Kubernetes implementation. 0:01:28.760000 --> 0:01:33.220000 So it'll log those and that'll be the one that your Kubernetes commands 0:01:33.220000 --> 0:01:38.060000 go again. So I'm going to take that, I'm going to copy that, and I'm going 0:01:38.060000 --> 0:01:42.720000 to go over here to PowerShell, and I'm going to run that. 0:01:42.720000 --> 0:01:46.620000 And that's it right there. 0:01:46.620000 --> 0:01:48.880000 So it merged that as the current context. 0:01:48.880000 --> 0:01:54.260000 And so now, if I wanted to do something such as, let's see if I get this 0:01:54.260000 --> 0:02:05.620000 right here, kubectlgetnode, should give me a list of nodes, and those 0:02:05.620000 --> 0:02:11.040000 are the nodes that are running for that AKS that I have deployed. 0:02:11.040000 --> 0:02:17.840000 And I can do other things, and this is not a Kubernetes CLI course, but 0:02:17.840000 --> 0:02:22.680000 the point is that I have with really little to no effort, provisioned 0:02:22.680000 --> 0:02:27.680000 in AKS solution service, and I can now interact with it, right? 0:02:27.680000 --> 0:02:33.920000 And I can see information and control it simply by downloading the connection 0:02:33.920000 --> 0:02:37.980000 credentials, and I can do that automatically. 0:02:37.980000 --> 0:02:41.160000 So it's very cool stuff, makes your life a lot easier. 0:02:41.160000 --> 0:02:45.280000 All right, now, what I want to do is I'm going to take a look at how you 0:02:45.280000 --> 0:02:48.800000 will typically deploy solutions into Kubernetes. 0:02:48.800000 --> 0:02:52.920000 Now, I should tell you that there are some user interfaces that you can 0:02:52.920000 --> 0:02:54.160000 run on top of Kubernetes. 0:02:54.160000 --> 0:02:57.180000 I'll give you a web-based interface for Kubernetes, but I'm going to go 0:02:57.180000 --> 0:03:01.640000 down to what is most common when it comes to the point into Kubernetes, 0:03:01.640000 --> 0:03:04.540000 and that is to use a YAML file. 0:03:04.540000 --> 0:03:11.520000 YAML is a really very pared-down data standard that is entirely built 0:03:11.520000 --> 0:03:14.100000 around indentation. 0:03:14.100000 --> 0:03:18.340000 And so, for example, I've ever worked with Python, YAML is going to be 0:03:18.340000 --> 0:03:22.480000 fine for you. But unlike Python, which is a programming language, YAML 0:03:22.480000 --> 0:03:28.880000 is simply a really declarative text standard, and it lets you define really 0:03:28.880000 --> 0:03:30.520000 a hierarchy of settings. 0:03:30.520000 --> 0:03:34.120000 And in this case, that hierarchy of settings is going to represent what 0:03:34.120000 --> 0:03:36.120000 I want to deploy into Kubernetes. 0:03:36.120000 --> 0:03:40.280000 And this is by no means going to be an exhaustive coverage of a Kubernetes 0:03:40.280000 --> 0:03:44.600000 YAML file. The file that I'm going to have, honestly, I took from an example 0:03:44.600000 --> 0:03:50.460000 that was on the docs.markself.com site, and I've modified it so that it 0:03:50.460000 --> 0:03:53.060000 matches what I actually want to deploy. 0:03:53.060000 --> 0:03:57.360000 I've got two images. 0:03:57.360000 --> 0:04:02.580000 I've got a web app image, and I've got a background process image, and 0:04:02.580000 --> 0:04:07.700000 I have both of those as containers, and I want to deploy those into a 0:04:07.700000 --> 0:04:09.380000 Kubernetes solution. 0:04:09.380000 --> 0:04:13.240000 So let's take a look at that process. 0:04:13.240000 --> 0:04:19.680000 So here is my Kubernetes file, and I wasn't all the way up at the top. 0:04:19.680000 --> 0:04:23.920000 With the Kubernetes file, you've got different deployments. 0:04:23.920000 --> 0:04:26.720000 Now there's different kinds, and you'll see that. 0:04:26.720000 --> 0:04:33.200000 This is a deployment, which is telling me is deprecated by V1 beta 2, 0:04:33.200000 --> 0:04:36.440000 but I'm fine with V1 beta 1 for now. 0:04:36.440000 --> 0:04:38.480000 Now I can also deploy a pod. 0:04:38.480000 --> 0:04:41.840000 And a pod would be typically associated with a container. 0:04:41.840000 --> 0:04:45.860000 However, even if you really are just going to deploy one pod, you typically 0:04:45.860000 --> 0:04:49.360000 want to use a deployment instead for a number of reasons. 0:04:49.360000 --> 0:04:53.100000 The, to me, greatest reason is that you can specify the number of replicas, 0:04:53.100000 --> 0:04:54.780000 and you can change the number of replicas. 0:04:54.780000 --> 0:04:58.160000 So how many instances of your container do you want to run? 0:04:58.160000 --> 0:05:01.720000 So I've got the API version, the kind, which is deployment. 0:05:01.720000 --> 0:05:03.880000 I've got metadata, which is not really that. 0:05:03.880000 --> 0:05:04.600000 Well, in this case, it is. 0:05:04.600000 --> 0:05:06.180000 I've got the name of the deployment. 0:05:06.180000 --> 0:05:09.000000 And then I've got the specifications. 0:05:09.000000 --> 0:05:10.680000 It's pretty easy to follow. 0:05:10.680000 --> 0:05:12.120000 I'm one replica. 0:05:12.120000 --> 0:05:17.380000 And then the template that I want to use, I've got just a label for that. 0:05:17.380000 --> 0:05:20.580000 The specs for the template. 0:05:20.580000 --> 0:05:23.100000 So I've got the spec of the deployment, and then I've got the spec of 0:05:23.100000 --> 0:05:24.920000 the template inside of that. 0:05:24.920000 --> 0:05:29.020000 And you'll notice, again, there's indentation, and I'm in VS code right 0:05:29.020000 --> 0:05:32.960000 now. And so VS code picks that up and lets me do things like collapse 0:05:32.960000 --> 0:05:38.660000 and expand. And so this is going to be beta Kubernetes IOS Linux. 0:05:38.660000 --> 0:05:40.780000 And then it's going to have a container. 0:05:40.780000 --> 0:05:43.020000 I'm going to name this container service. 0:05:43.020000 --> 0:05:50.820000 I'm going to base it on an image that is in my Azure container registry. 0:05:50.820000 --> 0:05:55.260000 And I've already given this Kubernetes service access to that container 0:05:55.260000 --> 0:05:58.160000 registry in order to be able to pull images. 0:05:58.160000 --> 0:06:00.480000 So it should be able to pull that image no problem. 0:06:00.480000 --> 0:06:04.500000 Now, this has resources. 0:06:04.500000 --> 0:06:08.160000 And this is something, and I don't even have this complete, you will typically 0:06:08.160000 --> 0:06:14.000000 want to limit your resources, both CPU and memory, right? 0:06:14.000000 --> 0:06:20.580000 Because otherwise you could kind of exceed what's available and have containers 0:06:20.580000 --> 0:06:24.420000 have to wait. And then I can also specify environment variables. 0:06:24.420000 --> 0:06:31.000000 The container that I'm deploying is based on ASP net core MVC application. 0:06:31.000000 --> 0:06:34.460000 It's got some configuration options that it's going to pull from its standard 0:06:34.460000 --> 0:06:38.240000 configuration, which in the case of running on top of Linux, actually 0:06:38.240000 --> 0:06:40.760000 Windows as well, can pick up environment variables. 0:06:40.760000 --> 0:06:44.920000 So I'm basically passing some configuration to my application. 0:06:44.920000 --> 0:06:47.080000 Then I've got another deployment. 0:06:47.080000 --> 0:06:49.420000 The first deployment is a service. 0:06:49.420000 --> 0:06:53.640000 My second deployment is actually my UI. 0:06:53.640000 --> 0:06:55.940000 And so really kind of very similar. 0:06:55.940000 --> 0:07:00.280000 One thing that's different here, I'm specifying the container port. 0:07:00.280000 --> 0:07:05.540000 So I want this to actually have an exposed port 80. 0:07:05.540000 --> 0:07:09.300000 And then we'll go down through here, environment variables. 0:07:09.300000 --> 0:07:11.040000 And then I have a third deployment. 0:07:11.040000 --> 0:07:14.400000 This time though, the kind is service. 0:07:14.400000 --> 0:07:19.040000 And you can think of a service as really giving you an endpoint for your 0:07:19.040000 --> 0:07:22.440000 containers. A little more complex than that, but that will give you an 0:07:22.440000 --> 0:07:24.120000 endpoint for your container. 0:07:24.120000 --> 0:07:28.100000 And let's see if it actually services a named abstraction. 0:07:28.100000 --> 0:07:31.520000 It actually gives you this consisting of a local port that proxy listens 0:07:31.520000 --> 0:07:36.620000 on. And the select determines which pods will answer requests. 0:07:36.620000 --> 0:07:40.740000 So the spec for this, it's going to be a standard load balancer. 0:07:40.740000 --> 0:07:42.120000 It's going to listen on port 80. 0:07:42.120000 --> 0:07:51.140000 And it's going to then hand off to a pod named I-N-E-Load UI, which is 0:07:51.140000 --> 0:07:52.760000 this pod right up here. 0:07:52.760000 --> 0:07:57.940000 So that is my actual yaml file. 0:07:57.940000 --> 0:08:01.420000 Now as far as applying the yaml file, it's really simple. 0:08:01.420000 --> 0:08:04.520000 I just have to go and run kubectl. 0:08:04.520000 --> 0:08:05.660000 And I'm going to apply. 0:08:05.660000 --> 0:08:08.280000 And the file I'm going to apply is this demo file. 0:08:08.280000 --> 0:08:11.880000 So I'm going to copy that. 0:08:11.880000 --> 0:08:14.500000 And pop over here. 0:08:14.500000 --> 0:08:19.020000 First of all, let's make sure that file is here. 0:08:19.020000 --> 0:08:20.900000 I believe it is. 0:08:20.900000 --> 0:08:24.860000 And there's my I-N-E-Demo yaml. 0:08:24.860000 --> 0:08:25.960000 I-N-E-Demo yaml. 0:08:25.960000 --> 0:08:28.840000 There we go. And I apply that. 0:08:28.840000 --> 0:08:31.380000 All right. Notice how quickly that was applied. 0:08:31.380000 --> 0:08:32.240000 That's pretty awesome. 0:08:32.240000 --> 0:08:35.820000 However, that doesn't mean that it's all actually there. 0:08:35.820000 --> 0:08:49.140000 OK. So if I go kubectl get and I want to get deployment, I can see I've 0:08:49.140000 --> 0:08:50.620000 got two deployments. 0:08:50.620000 --> 0:08:54.600000 Now those deployments created pods. 0:08:54.600000 --> 0:08:58.540000 All right. So I've got two pods. 0:08:58.540000 --> 0:09:00.340000 Those pods are running. 0:09:00.340000 --> 0:09:07.480000 And then I also have the service that got deployed. 0:09:07.480000 --> 0:09:09.620000 Now, one thing with the service. 0:09:09.620000 --> 0:09:13.440000 Notice that it says pending under external ID. 0:09:13.440000 --> 0:09:16.120000 So I've got the I-N -E-Load UI service. 0:09:16.120000 --> 0:09:17.820000 And over here it says external ID is pending. 0:09:17.820000 --> 0:09:22.680000 So it has not yet been assigned an external ID. 0:09:22.680000 --> 0:09:25.700000 And so I can go and get that again. 0:09:25.700000 --> 0:09:31.600000 And I can also, I believe it's, I just forgot. 0:09:31.600000 --> 0:09:34.980000 I will cheat. Help. 0:09:34.980000 --> 0:09:36.680000 Throw the help out there. 0:09:36.680000 --> 0:09:40.000000 I can't remember if it's wait or monitor. 0:09:40.000000 --> 0:09:44.600000 Field file name. 0:09:44.600000 --> 0:09:48.560000 By the time I apologize, by the time I find this. 0:09:48.560000 --> 0:09:56.000000 OK. Watch is what it is. 0:09:56.000000 --> 0:09:59.400000 OK. We're going to go with watch. 0:09:59.400000 --> 0:10:01.000000 Which again, it's probably took enough time. 0:10:01.000000 --> 0:10:01.960000 That's probably already there. 0:10:01.960000 --> 0:10:03.440000 No, but it's still pending. 0:10:03.440000 --> 0:10:09.140000 All right. So I'm going to watch this until that public IP gets assigned. 0:10:09.140000 --> 0:10:10.900000 And it'll show up automatically. 0:10:10.900000 --> 0:10:14.500000 All right. And now I have an external IP. 0:10:14.500000 --> 0:10:20.460000 I can see this 1332, or 1392, 115, 135. 0:10:20.460000 --> 0:10:23.380000 I'm going to go ahead and hit that and control C out of this, because 0:10:23.380000 --> 0:10:27.280000 I don't need that anymore. 0:10:27.280000 --> 0:10:32.340000 And now, the moment of truth. 0:10:32.340000 --> 0:10:36.460000 Apparently I did not actually copy it. 0:10:36.460000 --> 0:10:38.440000 That would be the first mistake there. 0:10:38.440000 --> 0:10:41.080000 Let's try that again. 0:10:41.080000 --> 0:10:47.320000 Always good to remember how to use the tools that you're working with. 0:10:47.320000 --> 0:10:50.760000 There we go. There is my web app. 0:10:50.760000 --> 0:10:58.400000 And should be working properly, I believe, that I can even annoy my service. 0:10:58.400000 --> 0:10:59.900000 That may take a moment. 0:10:59.900000 --> 0:11:01.720000 Not sure I fully set that one up. 0:11:01.720000 --> 0:11:07.380000 There we go. I ping the service and it came back to me with a sassy reply 0:11:07.380000 --> 0:11:10.880000 there. But I've got a fully functional system. 0:11:10.880000 --> 0:11:15.960000 It means that not only did the container with my web app work, but I've 0:11:15.960000 --> 0:11:20.020000 deployed a web app, I've deployed a service that's monitoring the queue. 0:11:20.020000 --> 0:11:23.560000 The way that little interchange work is my web app drops a message on 0:11:23.560000 --> 0:11:27.760000 a queue. The server is the service is monitoring the queue. 0:11:27.760000 --> 0:11:32.160000 It pulls that message off and then puts a message into another queue that 0:11:32.160000 --> 0:11:33.420000 the web app is looking for. 0:11:33.420000 --> 0:11:35.640000 So kind of a standard queue -based communication. 0:11:35.640000 --> 0:11:40.380000 But the point is not that I can get snarky answers from a service. 0:11:40.380000 --> 0:11:45.480000 The point is that I now really have a fully functional, if somewhat useless 0:11:45.480000 --> 0:11:47.800000 solution in Kubernetes. 0:11:47.800000 --> 0:11:50.120000 And before we go, I want to show you a couple other things, because this 0:11:50.120000 --> 0:11:52.540000 is pretty cool with Kubernetes. 0:11:52.540000 --> 0:11:58.800000 Now, if I go to the resource group where I have dropped Kubernetes, where 0:11:58.800000 --> 0:12:01.840000 I created Kubernetes, the only thing that I see in this resource group 0:12:01.840000 --> 0:12:11.780000 is my service. However, when you provision a Kubernetes service, it actually 0:12:11.780000 --> 0:12:15.280000 creates a secondary resource group. 0:12:15.280000 --> 0:12:17.880000 And it gives itself rights to that resource group. 0:12:17.880000 --> 0:12:20.520000 And if I look at what I have, I've got an availability set. 0:12:20.520000 --> 0:12:22.720000 I've got some disks. 0:12:22.720000 --> 0:12:24.580000 I've got a load balancer. 0:12:24.580000 --> 0:12:26.340000 I've got network interfaces. 0:12:26.340000 --> 0:12:30.700000 I've got a network security group, IP address for the load balancer. 0:12:30.700000 --> 0:12:35.800000 I've got built-in route table, virtual machines, and the virtual network. 0:12:35.800000 --> 0:12:42.480000 And if I go, for example, to the load balancer, and if I go to load balancing 0:12:42.480000 --> 0:12:49.340000 rules, I will see that this should be the load balancing rule for my, 0:12:49.340000 --> 0:12:52.480000 for my 80. That's my port 80 load balancing rule. 0:12:52.480000 --> 0:12:54.540000 It's going to drop port 80. 0:12:54.540000 --> 0:12:56.640000 It's just pushing port 80 back to those VMs. 0:12:56.640000 --> 0:12:58.820000 It doesn't really care what the VMs did. 0:12:58.820000 --> 0:13:03.980000 Likewise, I have a relatively restrictive network security group. 0:13:03.980000 --> 0:13:09.220000 The cool thing is, when I pop over there, I have this inbound security 0:13:09.220000 --> 0:13:10.600000 rule for port 80. 0:13:10.600000 --> 0:13:14.320000 So Kubernetes automatically added this rule. 0:13:14.320000 --> 0:13:19.260000 It's managing all of this infrastructure for me. 0:13:19.260000 --> 0:13:22.220000 And it's automatically provisioned three virtual machines. 0:13:22.220000 --> 0:13:25.100000 It's put those three virtual machines in an availability set. 0:13:25.100000 --> 0:13:26.660000 So I've got high availability. 0:13:26.660000 --> 0:13:28.420000 I've got load balancing. 0:13:28.420000 --> 0:13:33.980000 And all I need to be able to do is, I need to be able to define what it 0:13:33.980000 --> 0:13:38.740000 is I want to deploy in a yaml file and then deploy that. 0:13:38.740000 --> 0:13:42.660000 And that really, if you think about it, is pretty amazing. 0:13:42.660000 --> 0:13:47.080000 The workload that I just provisioned, okay, it was one container of two 0:13:47.080000 --> 0:13:49.780000 different, or one instance of two different containers. 0:13:49.780000 --> 0:13:52.960000 But I could very easily modify this. 0:13:52.960000 --> 0:13:57.020000 And in fact, I could reapply this if I wanted to bump it up to three instances 0:13:57.020000 --> 0:14:02.220000 per deployment. I could do that by simply change that number and reapplying 0:14:02.220000 --> 0:14:03.460000 the same yaml file. 0:14:03.460000 --> 0:14:08.420000 So a lot of functionality, a lot of capability here for what I have to 0:14:08.420000 --> 0:14:12.220000 say is pretty much the minimum effort that you could pretty much do. 0:14:12.220000 --> 0:14:16.740000 And I hope to have to put out to manage a clustered environment.