Deploying an ASP.NET Core 3.0 Web API on AKS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome today I'll show you how to deploy a negative net cord 3-0 Web API on Android cornetist service also known as IKS you will learn how to create a container registry and an IKS cluster how to push your Web API container to a container registry how to generate cornetist general files to describe your deployment and service using visual studio code and how to deploy your Web API container to aks to follow the this video step-by-step you will need a few things first the hello a spinet called docker image created in my previous video container izing an asp.net called 3-0 web api if you had not seen it already please go to the steps on that one and then come back second docker which we will use to manage docker images in the dead box and to push a web api image to the container registry third the azure CLI which is needed to be able to manage our resources like container registries and cornetist clusters next visual studio code which we will use to generate and edit the required cornetist files you can of course use any other code editor that works best for you but you might miss the cogeneration piece and finally postman which is handy to query or web api once deployed on cornetist again you're welcome to use a browser instead for this if you prefer or any other tool that better suits your needs since we will be deploying our contained into an android coordinated service we will need a natural subscription if you don't have one already you can get a free one by going to assure that my guru comm slash free the free subscription will give you all you need to try out aks and any other actual resources once you have a natural subscription you can go to the Azure management portal at portal data sure calm and here is where you manage all eurasia resources and the one research that we need to get started is a container registry which is basically storage in the cloud for your local images we need to pull ashore hello internet core image to contain every history so that later or a KS cluster can pull it from there so it's going create a resource let's say container registry create and you can really use any name for this registry I'll just use my name and one you will pick your subscription here and then you have to either select or create a research group the research group is just a logical grouping or of resources in a sure that's very useful for creating about your resources at once or deleting all of them also at once this case we'll just assign the same name create brand new one just for the case of these in the registry and finally we'll pick an SKU here and the basic SKU should be good enough for this for this video we create and this will get at the deployment of this container is three historic well that happens let's switch to business to decode well we have already opened the folder where we have all these files of living working and since the previous video and we're going to do here is the first to login to the data description so to do that we do see our CLI this is done already and we'll do AC login this is going to open a browser window prompting us to authenticate to assure the right account and it's locked in so now let's close this tab come back to a visit to the code and now we are locked in and we will now just want to make sure that we have selected the right subscription among the the the bunch of ones we have available there so let's do a see I can't show let's see what subscription comes back we get BSF essentials so this is what that I actually created as a free trial for this video so we are in a good place now what we want to do now is to create what we call an azure a service principle the service principle is nothing more than an identity for an app or a service that in this case we will choose a to configure the kubernetes cluster so the cluster can authenticate and pool they images from the container registry and to create these a service principle what we can do is use the AC 80 SP create for our back command and then we'll do skip assignment and then hit enter so this is going to create a service principle and should come back up with all the details about the principle just created the most interesting details about this Ares principle are the app ID and the password I can see here so both them let's actually copy them to some location so we have them handy when we are going to create the AKS cluster alright so now we have done this let's go back to the portal and let's see deployment succeeded the container history is created so let's go to the resource and what we want to do now is grant access to this service principle that we just created into this container registry ok so that any value that indicates as that service principle can just pull the images that we have here so this scroll right and adderal assignment the role that we want that we want here is the ACR pool role there's a bunch of code rules you could pick here live in own or the most powerful one but really the only thing that that this identity is going to need is just to be able to pull emails from here so kind of a good security practice to only grant the right role the permissions that are needed in each case so now we need to pick that service principle so we will use the app ID for that please save so now if we go to role assignments we should be able to see let's refresh there is our service principle now has easier pool permissions of this container registry now it is time to create the ordinary service so to do that we'll go to create a resource let's do sure where net is akin a service create okay and same as before we'll need to pick a resource group in this case we'll use the same resource group that we are created earlier so let's open up this ok we'll need a cluster name I'll just give it that say name you could use a bunch of different names in there also I think that's the other thing that we need here is to pick a size or SKU and for the for the nodes that we're going to use in this cluster so there's a bunch of sizes available here and if you click on change size you're going to get a list of all the ones that are available for the for your subscription and for the location that you have selected since this is just like us trying to learn how this works I would encourage you to go for it cheapest one available in that case that's going to be the b2st you so fact let's scroll right yeah so that's the cheapest one available so you just call for that and that should work just fine and for node count we'll just do one since again this is just trying to learn things and let's go to next will not pick anything in this section let's go to authentication now here it's a very important part we need to configure the service principle that this code is cluster is going to use so click here select select use existing and we go back to that combo of app ID and in this case we also need the password ok and if we go to next networking we're not going to pick anything here or monitoring I will not be enabling monitoring for this video just for the sake of speeding things up and that being said the mentoring that's available here is really good so for your production clusters you totally want to enable this so let's actually go to review and create now let let it run the final validation and then we should be able to go ahead and create the cluster click create okay so well that happens and this is actually going to take a few minutes let's switch back to this code and this time let's let's actually start interacting with the container registry so it is time to push the image that we have locally so far and we need to set it to the cloud to the container history so first thing we'll have to do is to log in to the container registry that we created so to do that we will do a CAC our login - name and now in the name of that container is U so if we go back to the portal for a moment go home and let's go to here secondarily we created before and you can see the the login server name the and the container is still native we are going to use is the name of the contain every tree right there Julio one so back to be as code how to use that name so this is going to authenticate our hard talker engine that we have in the Box against that container a history the be succeeded so now we were able to start interacting with with that easier so let's let's actually browse the images that we have in the box right now to confirm that we have the image that we want to work with let's do this and here is hello infinite core v1 so this is the one that we want to send to ACR so P but before we can do that we need to retag this image with a repository name and tag that actually makes sense for that container registry so to do that we're going to do docker tag a the current current image name is hello SP net core p1 and we want to do is we tag it as the name of the login server let's go back to portal here's the login server copy ok login server slash repository name so the booster name is going to be hello SP Nate core and we'll lose the same tag hit enter and let's do docker images again so this time you see that we have a new what seems like a new image here with AC are looking name and then depository and attack and just but just notice that this new tag is just really another pointer or another kind of an alias of the same talker image if you see the image ID is exactly the same image that we had before but we need it in this format to be able to push it into the container registry so now that we have this we can go ahead and do darker push and then we'll do our new image name b1 okay so these go ahead and is going to start uploading all the layers that correspond to our docker image that includes the asp.net core 3 cedar runtime plus all the layers that involve our application so all the files all the binaries and any anything else that is involved in their inner image so the very first time that you do this it will take a while especially because of the a spinet call runtime image which at the same time is is based on some linux image so the bunch of things upload but the next time they upload is it will only upload any new layers that you have created all right so it is dawn now and if we go back to the azure portal and we now go to repositories for that container registry we can see that halo is finit color is right there in tag b1 so we have the container image ready where it should be so back to this code it is time to declare how we want to deploy our image into the Grenadiers cluster so to do that what we're going to do is a take advantage of the coordinators extension for BS code so that it can generate is the possibility for us so you have not done it already go to the extension hub you can type kubernetes here I will be the first option here so go ahead and install this extension and it includes a bunch of nice things and whatever we're going to use here is the ability to a generate Java files for us now one thing about this this extension is that at the time of this recording this video there was a bit of a bug in the in a dependent extension is called the camel extension which makes it or that conveys extension is not able to attend generate device so to make sure that you can do this go to find the general extension here and make sure that you're working with version 0 for 1 and if you don't have that variation just click on the year I can install another version and pick version 0 for one that's all it is close it so now let's go back to the files another brand new file see run new file let's call it blowing mint channel ok and secondly close the terminal for a while and let's just type deploy and as you can see popup menu over we show up right right here commands deployment we just have to click on it and right away it will generate and we shall skeleton for our deployment file so the first thing that we need to do here is to assign a name to these deployment and that we can set in the metadata name property here so we will call this employment Espie net core deployment right that's how we divide this deployment in increments now then the next thing that we're going to do is to set a name and I set a label for the for the parts that are going to be created by this deployment now a part is nothing more than a group of one or more containers that share a storage and or network and some sort of specification on how to run the containers so the label that we're going to assign to our pots is going to be hello SP net for what okay and now what we also have to do is to specify a how the deployment is going to select the pots that it's going to work with so usually what you do is a tape name of the pot and that's going to be the match label here that we're going to use in the selector okay so this means that a disappointment is going to work with all the parts that have the hello 8-minute core pot and label next we have specified let's look at the container section we have to specify first a name and a way to identify this container this hello a spinet quart container so we're going to name it hello SP net for container and then the interesting part here is the image that we're going to use this image should match exactly the image that we have deployed to the container registry so if we go back to contain the registry the the name that we're looking for is the name of a login server okay which I just copied and then slash like a positive name this case hello SP net core and the tag so the tag we're going to use is v1 okay so that's the image that needs to be deployed in these hello infinite core pots then we have a section for resource limits so these are the limits that will be set on on these containers the hello spirit call containers so that they don't try to go beyond those limits and reduce the amount of resources available for any other containers running in the in denote what we saying here is that we're going to set a limit of 128 me maybe bytes which is very similar to 128 megabytes and we're going to set 500 milli CPU on the containers which is equivalent to like 1/2 a CPU pretty much so 128 megabytes and half CPU is a maximum that these that these containers will be able to use now finally we have to specify a the port where the container is going to be listening to so that port as we did when we worked on the just on the container would be forward 80 now just a just doing this will allow us to create and create the part in coordinators but that's not going to be enough for for anybody to be able to query a hard Web API from the from the outside to enable this kind of a window into into the they running contain there's a running part in the closer we have to define what we call as a service so let's add another file here let's call it service actually let's call it service that channel we're going to type here service select canary service and there is so a service is just a logical a representation a logical object that allows a for the interaction between a different a different object synchronization also allows potential allows a external external communication with these with the bots so first thing we're going to do here is to assign a name to this service so let's call it hello SP net core service the important part here is a selector so just as we did before we didn't specify which are going to be the pods that are going to be interacting or or reachable by this service so those pots are going to be just as we said before the hello a spinet core pod that's a label that that other parts use and that's label that we have to use as a selector here then the port is going to be a the port that external colors can use to reach out a to to those pots so our port is going to be in this case 8080 and the target port should be the port that we defined when we expose the port over here port 80 that's going to be our target port one last piece is to define the type of service that we're going to deploy here which is C type load balancer so a lot balancer is a kind of the kind of service that actually requires a public IP from the from the cloud hosting provider and it assigns that that IP to the service and so that external colors can use therapy to communicate with the service and with the pods that are behind service so now we have these files ready so it's time to actually perform the deployment in code so first thing we're going to do is a but if I if the cluster is is now a partly deployed I took a while but let's see indeed deployment succeeded so let's go to that khones cluster so here is our holy one creates cluster so what we have to do now is a go back to the azure CLI and I love being a terminal new terminal and we're going to connect to the cluster so the way that did you connect to the cluster is via the AC aks get the ninetails command you have to specify the resource sirs group and where the cluster lives in our case the research group is Julio one and the name of the cluster which is also holy 0:01 okay hit enter however this does is it downloads the secret to be able to connect to the cluster into your box and it stores it into this config file in this location now if you're connected will be an easy way to tell if you're properly connected is to do it use the cube CTL - which by the way came and it should be installed with your doctor desktop installation if this if this tool is not being found I should just go ahead and close this code or close your terminal or your common line tool and open it again and because it should be in the path of your computer so it should be available right away now we would do cube CTO get loads and this as you can see it's listing the one node that we have available in IKS we have nodes so it's time to apply our deployment so let's do cube CTL apply - f4 file and first let's go with the deployment channel ok2say subliming created so let's see keep CTL here deployments and at least we have our hello eight-minute core deployment right they're still waiting to be ready and what we can also do is see the pots about created here so cube CTL ok but ok you can see the container is creating so it may take a few minutes depending on the size of the container image that we polished into the container registry right again alright so the container is now up and running it this ready means that one out of one container is running so this is this good now let's also deploy the service so Q CTL apply - f service gamma okay so let's do Q CTL okay services here is so now we have a hello a signet call service and is it at the type load balancer and you can see that it does have a closer IP so this is what we call the internal IP that resources within the cluster can use to communicate to each other but one that we are waiting for is the external IP that can be used to interact with the cluster from the outside so that will take that can take a few seconds or a few minutes to pop up because now echo names is talking back in this case - uh sure to request creation of a public IP and the assignment of that IP to the cluster let's write it again alright so now we have an external IP which we are going to copy at this point we should be able to go ahead and a query or Web API now running in a KS so to do that let's switch back switch into postman and then create a new request here so we're going to do HTTP the external IP the port that we're exposing just defining the service channel file and our huttle API which is weather forecast so it's sent and there is you can see the results of our our weather API right there so the coordinates cluster has succeeded at the container deployed successfully and and the Web API is up and running in khones if this video was useful please consider hitting the like button don't forget to hit subscribe and a notification bell to know ran away when I polish new videos also please leave me a comment below with any talks about this video thanks for watching see you next time [Music] you
Info
Channel: Julio Casal
Views: 14,801
Rating: 4.9691515 out of 5
Keywords: asp.net core, kubernetes, docker, aks, azure kubernetes service, containers, vscode, k8s, asp.net, .net, .net core, web api, asp.net core 3.0, .net core 3.0, microservices, tutorial, api, asp.net core 3, .net core 3, .net conf, beginner, c#, azure, cloud, cloud native, dotnetcore to kubernetes, dotnet k8s, asp.net core to kubernetes, asp.net k8s, asp.net core on k8s, dotnet to kubernetes, dotnet kubernetes, k8s on docker for windows, dockerize asp.net core, dotnetcore, julio casal
Id: vBx7WY25fM0
Channel Id: undefined
Length: 26min 7sec (1567 seconds)
Published: Mon Oct 07 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.