Putting the ".NET" into "Kubernetes"

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right we are back we've got Elton and Elton is gonna talk to us about putting the dotnet into kubernetes two of my favorite topics these days dotnet and kubernetes right on you near me okay you know yes you can hear me now perfect I'm still trying to figure out these buttons I'm gonna have it all figured out when it's my turn to leave the studio and be replaced by somebody else and then I'm gonna keep it tribal knowledge whenever you're ready okay just to share my screen ready to go yep okay excellent so let's do the right screen okay how's that looking perfect excellent okay so it's my powerpoint here so hey thanks for joining everybody my name is Elton I work for Tokyo this session is all about dotnet applications in humanities so I've been using dry joint docker I was a I was a yeah a consultant working on big dotnet projects I've been an MVP for ten years now I was working with dotnet from the very first version back in 2002 one of things I really liked about the framework is that it's it's longevity you know you can take those apps from 2002 and you can run them on all the newest platforms and this session is all about doing that with humanities so there's a couple things I'm gonna cover I start with a few slides I'm gonna talk about I'm gonna give you some 101 because I know this is this is a new topic for a lot of people I've been working with docker since the earliest versions so like if you if you if you're with me on there then the first few slides will be stuff you already know but I wanna get everyone on the same level talking about what docker is how it fits in what Windows containers mean in docker and in Cuba Nettie's and then most of the session is gonna be demos so I'm gonna do a bunch of demos running some brand new net core three point nor amps building them in docker running them locally on my machine and then running that exact same inhumanities with the issue of cuban IT service so I'll do that with a brand new Tom eight core three app running Linux containers and then I'll use the exact same process tools and the same frameworks to do it with a very old dotnet app running on Windows so that's that that's the session today okay so the very first thing so if you're not familiar with docker look primarily it is a packaging distribution and runtime for applications so what you do with docker is you have your windows server or your linux server you've installed docker on it and you don't install anything else because everything else this can that your application needs it's didn't come through the container the way you make that happen is you write this script which which is basically an installation script that says all the bits and pieces that your app needs that's called a docker file and what that might look like for an old let's say a dotnet web forms out it's basically a list of all the components that you need so I'm a Windows app so I need to start on a version of Windows Windows server core I'm a web app so I need is I'm a dotnet up so I need net I'm I'm asp.net so I need a speed on net installed and configured and then right at the top there I package my own web application which would be the binaries or the content the HTML and JavaScript and any configuration that I need so I write this thing called a docker file which describes all those steps I run this command docker image build and that produces this thing called an image which is just a static package that contains everything in my application and I can share that now that docker file that I talked about the dozen of those steps could be something as simple as this so this docker file it it actually is the previous the previous diagram so this requires is and dotnet and asp.net but that first line that from line says use somebody else this docker image this happens to be a Microsoft image and that's already got everything I need so it's got is it's got dotnet it's got asp.net already configured so everything my application needs is already there right in that first line so and then the next stage imagine this is an old application I've already got a build process that gives me an installer a Windows MSI I wanted to see how that looks in docker this is literally all I need to do I copy in my MSI and that run command this all happens within docker is doing a run MSI exact to deploy my application from my MSI you not necessarily going to do this with your new applications but it's a good way to see how they have your old applications your old windows apps I can I looked in containers for a newer it's gonna look something more like this so it's the same syntax it's the same few commands that you need to understand the words in blue they're there the docker syntax most of what you're gonna do though is it's just run script inside that inside this docker file this is a bit more complicated this is my brand-new dotnet core application and this does a bit more than previous example firstly there are two parts to this so the first part is going to compile on my application from source code so you see here the from line is saying use an image that Microsoft own so there's a public images Microsoft maintain them every time there's a Windows Update or a dotnet update they push out new versions this is using your version this is using an image that's got net core installed and it's the SDK so it's got everything you need to build and package your applications the rest of the lines here copying the source code from whichever machine this running docker and then run dotnet publish which is exactly what you would do if you were building it in in a CI system or locally on your machine this what happens within docker and then the second stage starts from the dotnet runtime so this has got asp.net this doesn't help the SDK so I can't build on out because when I'm running my container in production there's no need for me to have the SDK I just need the runtime so this starts from the asp.net runtime it specifies what to do when the application starts so that entry point line says run net with my DLL and then it copies everything that was built in the previous stage so the but the the previous term the previous example that I showed you you need to have a bunch of stuff fast so you need to have something a process in a machine that can build your MSI but it's very quick to get up and running this version you don't need anything at all because all you need is docker and your source code and everything you need to build your app and compile your app and run your app is going to come from docker so it's a really nice way to make everything super portable okay so when I built my image and I've run through that docker file so what docker will do is effectively execute each line in that docker file and it will build me this thing called a called a docker image that lives on the machine where I did the docker build and I can push it to a thing called a registry so that's docker hub or as your container registry or a local registry or whatever you're doing or github packages which is just the store for all these images so I can share that now and then anyone who is access to that image because I could make it public or private anyone who's access can do a docker Rawdon and that will bring that container image onto their machine which brings everything with this everything that you've packaged comes down with that container image and then the container will starts your application will start the actual process for your app is going to run on the server directly because that's the way containers work but everything the application needs comes packaged with that container image so my server doesn't need is or.net and if I'm running several containers with different versions of.net they're all completely isolated so that's the kind of basics of containers and of course it's the same with Linux to the commands are the same the docker file syntax is the same when you run your container it's as in its container it needs to run on a linux server but the syntax is the same I bring that down this may be based on Debian or a lightweight linux version as your deck or installed an asp.net core and my web app and the application that's running is the dotnet runtime but it's exactly the same set of tools same set of artifacts to run your your Windows apps aren't on their framework or your new apps running on on Linux okay so that's your introduction to docker now what you then end up with is because your Linux containers have to run on Linux servers and your windows contain yourself to run on Windows servers you end up needing to kind of join these things together that's where Cuba Nettie's comes in so what kubernetes can do is that you can take a bunch of servers click bunch of Linux machines a bunch of Windows machines you install docker on all of them and then what you end up with is a bunch of isolated machines that can all run containers individually but then you deploy cuba Nettie's and you turn the whole thing into a cluster you can treat it like one big one big platform where you just can throw your apps and it can decide what to do with them now I'm you're going to do an IDs in any depth but basically what it is is it's a container Orchestrator so it manages where the containers run so you you manage it out your humanity's toaster remotely so I can use my laptop I can connect to my community's toaster I want to deploy an application I send Cuba Nettie's a description of what the pieces that the app needs in a Yama farm go to application manifest that says I need this clean tech I need this this container and I want five of them I need this container I want ten of them this one has to run on Windows this one has to run on Linux you throw that to cuba Nettie's and it makes all the choices for you about what's gonna run where so it might run for someone one server and someone another server and then it monitors the whole thing and guarantees you your the service levels that you specified so if I need ten containers running my web app to get to get scale and and failover if three of those are running on one of my Linux servers and that server dies then Cuba natives will see that service gone it's taken three containers with it so I need to start up another three somewhere else on the cluster to maintain the service level so the reason why Cuban is so exciting and why people are really interested in it is if you if you build your app and package your app with docker to be to be self-healing then you can get these kind of autonomous systems where you throw them the application manifest they work out what to do with it they keep it up and running they keep a healthy for you and so that kind of self operated ok and this is what that application manifest looks like in cuba Nettie's this is a simplified version just the cuban at ease the Cuban at ease manifests back is quite involved but there's there's two parts to this there's at the top let the top element here is a service which is basically just something that will let network traffic from the outside world into your containers so this is saying I'm listening on port 8081 so any traffic that comes into Cuba Nettie's from the outside world on that port it's going to go into a container on port 80 and in this case the container is going to be this dotnet conf to-do list which is my rotten egg or container so the second part is the deployment that says this is the container that I want to run that's going to deal with the traffic that comes into the service there's way more to humanities well this is just to give you a bit of a a bit of a grounding so that the demos make sense and then all the rest of this session is gonna be demos until we come back and recap at the end ok so I'm gonna move on to my demos no that's open vs code so first demo is I'm gonna take a I don't like all three-point not app and I'm gonna run it locally and then I'm gonna push it up to a KS my as your cube identities tossed there and see how it looks in Azure so that all the code I've got is on github the final slide I've got is a whole bunch of links that will show you where all this stuff is you don't really need any prereqs in order to do this yourself you just need docker desktop which runs on Mac or Windows you can get the source code you can try it all yourself and then there's actually in the in the readme for today's session there's instructions how to spin up an 80s cluster so you can ah yes - okay so this is the docker file for my donate core up there are two parts to it like in the example I showed you it starts from the dotnet core SDK Microsoft own and maintain that it's got all the tools a copy of my source code I do a restore to get my packages and then I do a dotnet publish there's this thing here which is about the runtime ID and I'm using advantage of a new dotnet core 3 feature which is in here then I can publish a single file and I can publish it trimmed and those two things together mean I don't need the dotnet core framework deployed in my container at all I'm just gonna get a single binary which has got my whole application this happens to be an asp.net core application but I don't need asp.net core deployed to my container because everything's in my application so this gives me a super super lightweight container on time ok so the way I do this is I'm gonna I'm connected to a Linux machine so I'm running on Windows here but I'm connected to doc out on Linux which means I can build this to run on Linux I clear this down and just do a build so that's gonna run through all the steps in my chakra file and you'll see was it was like ridiculously suspiciously fast because I've already run it today and if nothing changes if none of the source code changes if none of the dockerfile changes and all that stuff comes from the cache so you'll see all these lines here each of these lines from the docker file says using cash now if I run this without the cash so I can say no cash you'll see a bit more familiar output so each of these steps are gonna be executed now this is running on my Linux machine you'll see I've come into the dotnet restore part so I copy in the CS proj file into my docker image that's all I copied to start with and then run the restore because that might be a time consuming process and then I copying the rest and then I go and do the build and you'll see now the build engine starts it's doing the dotnet publish which is gonna actually do the single file packing and the trimming and all that stuff so that that takes a little while so you'll see this is just and the output here all these lines of output are just what you would normally see in Visual Studio or vs code if you're doing this as part of your CI CD pipeline then you will see all this in the output - so it's nothing different it's just a different way of actually running these things ok I'm gonna kill this because the compression of all the bits Pease it takes a little while and I already have a version that's built so I'm gonna run that container from the version that actually I'm going to show you I'll show you the difference between some of these these new options that you've got with Dominic core 3 so I've built a few of these images already I've built them with different variations of those single file and trimmed stuff so this is the the biggest version if I run that without the single file and without the trim then it ends up being 200 or megabytes if I include the single file and the trimmed Flags then it comes down to 170 megabytes well that means it's that entire package which has got Debian it's got the Linux operating system it's got my binary from my application it's got enough bits of net core to be able to run the website it's got all my all my dependencies or my configuration the whole thing comes in at 170 megabytes which is pretty much as small as you're gonna get a full asp.net core app ok so that's the difference those new Flags mean so if I run this so I'm gonna do a docker container run so imagine I could put I could share this now with with the docker hub I see already have so if you want to try this yourself you can these flags here just mean it's a background container so detach it put it in the background it's gonna keep running and this flag means I want to send traffic into my host on port 80 98 and that's gonna go into the container on port 80 so again I'm sipping through this I was doing you get a feel for how this stuff works okay so I'm gonna run this container and then I'm gonna open Firefox and browse to that app this is the machine that I'm connected to my newest machine and they said I'm afraid to say it's another to do list application they're really easy to write they're good they're good for demos I've got nothing in here right now and this is connect this is running on a local sequel light database that's inside the container I've got to-do list here it's all empty I could put some new items in but if you're a Diagnostics page which is really handy for me to see what's going on this is the name of the container this is the version of.net that's running so I can see it's a running on preview 9 actually I've got the operating system architecture and the description so I know it's Linux I know it's running on Intel I know it's running on dotnet tour ok so that's looking pretty good if I want to deploy this to Cuba Nettie's let's go back here there was this down here's my application manifest so what this is saying is again it's a slightly more elaborate version of the one I showed you in the slide but it's the same principle I've got a service here which is the entry point to my app so Cuba Nettie's will listen on port 8081 it'll send traffic into my to-do-list container on port 80 when I scroll down here this is describing how humanity should run that container so this is the version of my container that I've already pushed to docker hub so I've done the docker image push this is all ready to go I've got my ports that I'm exposing there are a few other bits and pieces here so I'm taking I'm taking configuration from the cluster so I've created some configuration settings in Cuba Nettie's now this is one of the great things about these platforms is that you can separate your application from the runtime config so the app has enough logic inside it to look in this particular path and if it finds a bunch of config files it will use them and those confit files aren't there in the docket image they are provided by the runtime so Cuba Nettie's has this has this configuration deployed when the container runs that configuration gets injected from Cuba 90s into the application it sees linearity configures itself so I've got one docker image that I can run in dev in test in UAT in production and just apply the configuration from the platform so this thing is really portable so that's that's an important thing to have okay so I'm gonna go over to as you're here I'm see if my cloud shell it's still running yet okay cool so I've got a resource group here with a bunch of things for today's demo so I've got a cuban IT service that has some windows and some linux nodes i've got a sequel server database that I'm gonna use later and I've also got a Postgres database which I'm using for my to-do-list application so there's a two out that I'm running locally I've just run it in a container using sequel Lite it also has enough logic using EF core to go and talk to post Prez and that's what I'm using in as you are I say my cloud shell here yeah I'm gonna kill this sleep I'm ready to switch between Linux and windows I'm ready to deploy this because I've already got everything set up so if I do a cube cut' or cube catalyst the command line to deal with cuban at ease cube other people pronounce two different ways it's officially pronounced cube shuttle don't let anyone tell you different so cube shuttles get nodes will tell me what machines are running in my cluster now to a to linux machine to Windows machine so I can run a variety of different applications whether were I deploy them and manage them it is all exactly the same so if I look at the secrets that I've got these are the configuration items that I've deployed so I've already got one set up I've got my in here in my to-do-list config I've got a all the information to connect to Postgres so if I describe that particular secret which is taught to do list romping inside here there are two files with JSON files and inside the secrets Jason is the connection string to Postgres so as the cuban areas administrator i can go and look at that but no one else can see that stuff okay so now I would go and deploy my amp and I've already got that that same yeah more file that I've just shown you it's already on here let's see where I am Tromp attacks look okay so I can so the way I deploy my application I've got this yeah more farm and I do cube cuttle applied and what that does is it's it's a desired state system so Cuba nighties is gonna take the description that I've got in this yam or file that's my desired State it'll look at what's currently running and anything that needs to change it will change so I can say I've already created the service because that service creates me and as you're know balancer with a static IP address I want to keep that but my deployment is new so it's deploying my application now if I do a cube cut or yeah all you will see I've already got a few things running so here's my new thing which is my to-do list web application which has started 25 seconds ago all these bits and pieces of our communities does the different layers of my application so that's all up and running that all looks good and if I browse to this application no I find you chimp chuckles just to be sure yes service these are the these are the external entry points so here's my to-do list web this is the load balancer so who gets created by IKS integrates with the rest of us your Creator a real as your load balancer gets me an external IP address and it tells me what ports I can use so if I switch back to my test browser this is now am i hitting my IKS version which is talking to post race is a brand-new deployment this is a brand-new container using the contain an image that I've run locally I've already pushed it to docker hub Cuba Nettie's is able to pull that down because of the the secrets inside the configuration it's already set up to connect to post pres and Postgres awesome data already in there so I've already been putting stuff in here the one good thing about this to-do list is it really suits my workflow you can put new items in but you can remove them so if you've got a workload like mine this is this is perfect for you if I go to diagnostics here you'll see actually this is a slightly different version because I'm running the release version of.net or 3 but I'm running x64 I'm running Linux so it's the same app it's connected to post grows because it's getting the config it needs from Cuba Nettie's so same same workflow but a really nice way to do the deployment ok so that's a brand new app so that's fairly straightforward what about my OLAP so as part of my my kind of taking the oldest apps I can find I've got a docker file here there's been a package up nerd inner like the original nerd inner from 2006 or whatever it was the docker file syntax is the same this there's a few more pieces in here because it's more complicated but actually the structure is exactly the same I'm starting from a dotnet framework image so again Microsoft owned this they keep it up to date this is based on Windows server core and it's got the full dotnet framework for me I'm copying in the package chomping and doing and you get restore so exactly the same patterns excuse me same patterns to build my application copying the rest of the source code and run msbuild so all fairly straightforward the application image has already got asp.net 4 7 installed and then I'm doing all this weird stuff which is to do with setting up is so I can get the logs out of the container I then copy in my application down here I run some PowerShell to set up my app I do that again this is a weird thing that you have to do because it's a 10 year old application and sometimes there are weird steps and then the last thing I've got here is I've got a health check which is which tells doctor how to check the application inside the container is still healthy and then I copying me up the application so there's a few bits going on here but it's still 48 lines half of them are whitespace lines compare this to a 30 page Word document with lots of pictures that say now click here and now installed on there and the asp net rage command this is much neater and it's much more portable because all you need to build this is docker and the source code so I would do a docker image build to make to make this happen but you've already seen that process exactly the same process I would run it on a Windows machine docker image build gets me the bill package dock image push to share it and then I'm then I'm ready to run it so again I already have this deployed to my cuba Nettie's cluster so if I go and check this out unless I haven't shown you the Amal file so similar thing to deploy this to cuba Nettie's its build its own service because in this case i'm listening on a different port but of course i could have i would ordinarily use the standard HTTP port and i would do things by domain name if I was running several apps on one cluster so this is listening on 8080 I've got my container image here but I want to use this is the one that I've built and pushed I'm saying which ports to use I'm using exactly the same pattern to get the configuration out of out of the communities cluster and into my app now the first app that I showed you use the dotnet standard config system with JSON files this is using the old dotnet framework configuration system with the XML config files it's exactly the same as far as kubernetes is concerned I'm gonna deploy those XML files as a secret in cuba Nettie's and make them available to my app in this location and the app is configured to pull bits of the applicant bits of bits of the config from there okay and then the last thing I've got here that I need to point out is this node selector so this is a docker image is pushed to docker hub cuba Nettie's doesn't know at this point when i ask you to run the app whether it's for Windows or Linux so I given this hint to say this is the Windows app so make sure you run it on one of my windows notes okay so let's have a look at this so I've already deployed this to make sure that the demos didn't take all afternoon morning or evening depending on where you are so that's what you can see here I've all your a deployment that I'd like to prove hour or so ago it's running minored in a web application and like I say there's a service here and there's my external IP so exactly the same thing I've only got a if I do the cute cuddle described secret and what was it called no dinner config then you'll see the same thing I've uploaded this secret with my sequel server connection string it's the connection strings config file exactly the same principle that I would use for an ordinary dotnet app but a web config file that's looking elsewhere for the connection strings this is already deployed so this is now running up in up in kubernetes so I can browse to this go back to my test browser and if I look at this there we are there's no dinner so this is my ten-year-old application it was originally written with with MVC like many many moons ago I can log in this is all connected to my sequel server database I've already put some information in here so this is connected to sequel as your it's getting the data that I've already run if I run a new pod it'll connect to the same container and I'll get the same thing out so exactly the same kind of workflow for an old Windows app or a brand new donate core app running on Linux okay so let's go back to our slides okay so those are the demos that's nothing to get help you can check it out so just there just to kind of recap what I did just it's not a very long session I've got my cuba Nettie's class that's now the great thing about cuba nineties is it's the kind of the same everywhere there are different implementations for different parts of humanities but the yeah more descriptions are always turn on the same so I can throw this on on my local machine I can throw on VMs I can run up on aks in Azure I've got my cluster I've deployed my application deployed my old Windows application so inside the communities cluster there are the secrets that have my credentials for my database and my windows container and cumulated is listening at the top on a particular port and it will send my my request into the container and the container will use the secret to get the connection string and go to sequel as York I also have my brand-new dotnet core application exactly the same principles totally different technologies back so again humanities listening on a public port pass this traffic to my document core container which is running on Linux that uses a secret to find the connection string for post pres and it all works in the same way now the beauty of this is you've got an awful lot of consistency across all your applications so all the artifacts are the same every app has a docker file and an application Yama file that describes it the docker if it's are more complicated that I've shown you sing apps for the sing a component if it's a more complicated mob micro-service type application you just have more docker files a docker file for each part and the application yang will file brings them all together the pipeline is always the same and it's really simple it's a bunch of command line instructions that you can plug into as your dev ops or Jenkins or github actions or whatever you're using docker image build dock an image push cube title applied to deploy it to your cluster and then we've got a consistent platform so for developers who were working where administrators who are managing the stuff in production we're using the same set of tools the same set of artifacts the same platform so it's docker everywhere Cuba Nettie's in my tests and production environments and it's not met all the way through so it's a really nice way to get consistency across a whole range of different apps okay and then here is the big list of a big list of links so today's demo is all on github if you're interested in how this stuff works and you want to go right back to the beginning if you follow that link that for dotnet that's the workshop that I do at various conferences but all the contents online you can go to that website and follow along and you know take this whole thing much more slowly I'm in the process of writing a book learned docker in a month of lunches that's the link to the book the first five chapters are done if you were and the final thing is going to give you a discount to go and buy the whole book when it's when it's ready so um thank you very much for listening we'll take some Q&A if we've got any but yeah that's what we've got I can see you pushing buttons here I can hear you now okay perfect thank you that was awesome in terms of questions and I know you're you just put up some links here but I think there's a lot of confusion about kubernetes and not just how to pronounce it so you know somebody who's maybe played around with docker understands the concept of containers what where would you point them to learn about kubernetes so starting with what the heck is it because it gets pretty deep pretty quickly right yeah it's a really good point so I mean if you look at the learning curve for these things like the learning care for docker is is pretty straightforward you can spend a couple of days looking at it and find some good samples and you'll be up and running you know with your own applications running containers in a few dates Cuba natives are learning curves are very much steeper because it is there are so many abstractions there it's got a very pluggable framework there are different ways of doing the same thing differently it moves so quickly the East knee release brings all these interesting features there in terms of resources so the the docker docks are always always great and it's really you know there's some good examples of how to get that stuff started again acute the the main community stocks are pretty good if you're looking for something this specific dotnet I don't think that's out there yet so that link back for dotnet that's an evolving workshop and I'm adding more and more humanities content the trouble is is this big gulf between I get the idea of containers I'm running them locally and then humanities which is which is massively more complicated the bit in between which most people don't do is docker swarm so docker swarm is another container Orchestrator it's much simpler than kubernetes because it doesn't have all the features the community stars but it's way easier to get started with so actually is it a really good learning learning journey is to learn how to docker eyes your applications using a single containers then learn about docker compose which tells you how to deal with multi application multi container applications then learn docker swarm which you may not use in production but it's it's much easier to learn cuba Nettie's when you've got swarm windows form an understanding of swarm because the the main kind of clustering concepts are the same and docker swarm uses docker compose as the format to describe all these multi container apps so yeah it's a good good learning path is docker then compose then swarm thank you manatees and somewhere along that journey you may say I've got everything I need and then I can stop so you don't have to go to humanities the big advantage with kubernetes is it but because it has so many integration points all the Clarins that are that are giving you a hosted cuban IT service integrate really nicely with the rest of that platform so you know as you I get my load balancer I get my public IP addresses I don't have to do anything else I spin up my cares cluster I know what care of the rest for me so yeah so that's why you know that's why Cuba nineties is the kind of a poster child for a cloud of negative stuff but yeah there is a steep learning curve and you're gonna have to decide whether you need to go all the way all right perfect thanks so much for doing this oh you're welcome place for me yeah thank you so much we're gonna get the next speaker up who's the next speaker that's Mike what is he gonna be talking about Mike is gonna be talking about modernizing dotnet applications with dotnet corn sweet or awesome thanks so much everybody we're gonna stay here we we shut off the video so because people were wanting that the links cuz the way we do the video overlay they could see you so I kind of shut it off halfway through it so thank you so much we'll be right back with more Dom p.m.
Info
Channel: Microsoft Visual Studio
Views: 6,513
Rating: 4.9741936 out of 5
Keywords:
Id: GBOPBfcJ2zM
Channel Id: undefined
Length: 31min 46sec (1906 seconds)
Published: Fri Oct 04 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.