Should You Use Kubernetes and Docker In Your Next Project?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so what am I here to talk about today I'm Libby I'm here to talk about you know why do we use these Cuban eighties being why is it so popular why is everyone you know so interested about deploying containers are using containers or you know machine learning or web applications so but before we dive into that let's let's have a look a little bit of a background right what what do we do and when when do we need we deploy applications well back in the day is right we used to have large applications right and and we used to build this large application but you know in the recent past what what happened is we we basically decided that it was a much better idea to just you know break this large application to smaller components and each component would have like you know a single focus we will have an API a front-end and each of those would be independent right and and we thought it was it a good idea because we could have quicker deployments right everything would be separate said and we could could be released independently we said you know each team could work on a single feature so that's a good idea and we it's also overall less risky right because if a component goes down is just that component it doesn't take down the entire system and you know it's developers we said this is a great idea we should keep doing it as much as we can however there is something else going on right so there is you know some of us were perhaps more into the infrastructure side of things are saying these kind of things and and thinking well it is great but when I have a single when I have a single application that I could just bring that single application and put it inside a box and that would just run okay but we did now we don't have a single entity anymore we have you know these individual individual components so we we should drop each individual component it's in its own box right what we call virtual machines for example but you're RT is that as developers we like you know we don't just break things in for we tend to be you know little bit more you know we take things to the extreme sometimes and and we end up with a lot of applications so a lot of application actually they introduced quite a lot of challenges on the infrastructure side of things and if we look at it some of the challenges the first challenge that we can we can think about is you know when we had this picture when we these computers right with computing units then those tend to be like quite large computers that could run a lot of things right and if you look at the ratio things that we're using the operating system and in a space which was usable for you for running the application there was a tiny bit using the operating system was using a tiny bit at the rest you can use yourself now if you had only a few applications then you know you would have this split and overall the the memory and CPU used by your operating system be a tiny bit right so if you think about it two to three percent to run the operating system it's okay right it's very small but when we switch to something like you know smaller components and a lot of them what happens is we tend to run smaller application and smaller which machines and the ratio between what is used by the operating system and what's used by your application like your your web application changes quite a lot right so we're seeing some some shifts from two to three percent to more than double to say from six to ten percent and if you think about it if you have a bill on GCP for example of a thousand dollars then you're spending a hundred dollars in running operating system so some money that you'll never see back right it just lost the other challenges usually when we build this application we we used to put this application inside these boxes and everything will be fine right we will have Noddy box and another box and if the application was smaller than there would be just a little bit of gap right which wasn't easily we couldn't use lines and it was still okay but now with this application that we're building showing much more very much much much focused right compared to what we had before we have you know all different shapes and sizes so if we deploy them in in these boxes then there is a lot of white space right which we didn't have before and now we do which is kind of a problem and the last sort of issue that we get that we inherit from this sort of development that we know we do is that yes all these micro services we like to pick languages there we okay but it turns out that we really really like them so if you if you go and look at these you know micro-service architecture or you know if you go in a company you will find that someone is watching go someone is writing in no js' there is you know I'm gonna say some legacy in Ruby but I don't want to offend anyone okay but in general morning general is we have a lot of applications right different languages but even if you are in one of these companies really rigid saying we do just Java okay really serious they still have the same problem right because they have different runtimes it's never just matches the same so even even if they pretend to be better they are not okay so what can you do that's one solution okay but let's let's take it stay back right so we talked about so all of these some of these problems were originated by by ourselves right so we picked these boxes we called envision machines and we play stuff inside but what if we change the story right what if instead of starting with virtual machine we started with something else so it turns out that in the mean time and the way some some features in the Linux kernel that you know they were quite interesting one of these was country groups which is basically when you launch an application you can define how much memory and how much CPU that process is going to use okay and then you can limit things like memory and CPU and then the other things you can do is you can you can launch a process like your web application your you know your binary and you can also set isolation so what the process can see can you see alt other processes can you see network packets from other processes as well so we just you know designing boundaries around our application what kind of things you can see and how much memory can use it turns out that this sort of stuff is quite interesting and someone said what if I combine three things you know these control groups namespaces and a little bit of magic okay and they they came up with this right what we call Dockers what we call containers so just a way to launch a process which has got some extra memory and some extra namespaces just to set isolation and end groups so generally we don't say this but let's say for the sake of the point we are trying to make but docker containers look like lighter virtual machines like lighter boxes that we've seen before so if before we had days right so we had the server and several bridge machines that are boxes inside now we basically if we'd run containers then we don't have these boxes anymore and then we can run the infrastructure much more packed right so everything is neatly tied you know neatly organized together which is good and the other benefit of this containers is that because these are just processes where we set limits right it's not slow as a virtual machine I mean you must have run VirtualBox and waited you know gone for a copy and and come back and still there booting and there is no hardware emulation this is just launching a process in the same way you launch your IDE right so that's the same thing at the docker container is the same same thing and then the best part is that when you launch a virtual machine is going to pre allocate some memory right and CPU when you launch a process is just going to use the memory dynamically so this docker containers are basically just double-clicking on your IDE and then the first part part part which is also quite interesting is that this docker containers at the end of the day what they are are just archived like zip archive and and what they contain is not just the code that you run but all the dependencies and dependencies if you're running if you're running for example a JVM is going to be the runtime if you're running nodejs is going to be nano GS binary if you're running ruby is gonna be the MRI MRI if you're running go well you don't need any of that it is just a binary so we combined your runtime or your files all together with any other dependency of your god and we just wrap them up in a zipped file and we call that zipped file container okay so that's the magic of containers and and how they work but a powerful thing is that if you think about it in the past right if you had to deploy at anything like a Ruby on Rails application or nodejs do you need to go to someone else and say hey can I have a box can you go inside install a couple of binaries bla bla bla and if it was just one that was fine but when you had like several application it becomes really really complex right this this server needs to have no js' and ruby and so on so forth but we took a containers we don't need any of that because we'd wrap everything inside a container we don't we don't care what they look like from from the outside because they are just containers and we can just deploy them whereas containers so containers are great I hope you share share the same saying feeling but the thing is if we have a lot of virtual machines and we switch the containers we still have a lot of containers okay we haven't solved the problem on how do we use these containers so it's Christmas time okay so have the couple of wishes you know I'm gonna have a wishlist way with some things I want to solve this problem of containers so the first wish I had what if it could be something that could manage all of these containers and it could be it could be something that ideally I don't need to drink to go there and manage servers it's just gonna take everything is it just gonna take care of everything for me so it's gonna basically look at all of the things I've got and just make a single bundle okay so only I don't need to worry about where this application that I built are gonna end up and then ideally I want to also make sure that this is something that I I can program because I'm a developer and I like to write code okay and you might have used some of these tools in the past so it turns out that this technology that managed several containers and they've got these properties are called container orchestrators and the market has got a bunch of them okay so you might have heard of this ones but another another example is if you're using it up your ass is called AWS ECS which is the container Orchestrator and it's not a fair fight okay so cuba i this is de facto the container Orchestrator okay so this is fairly old graph but the trajectory is you can see the trajectory of cuba natives and so what why this cuban act is why is so popular well one of the reason why it is so popular is because you don't need to think about your service writing you don't need to think about this computer that you have to deploy your applications what cuban Ivies does is you install it on on one of those the other nodes inside your infrastructure will join the master node and and what happens is the cluster is just going to absorb memory and CPU or all the Nerds okay and he's going to become like a massive computer just single one which is much easier for us we only deal with one z single computer the other interesting thing is about Cuba nineties is that it's quite clever but clever is not the right word it is it's quite quite nice Tetris player so if you think that you know this boxes do we create it they come all different shapes and sizes right cumulative what it does it usually pay to play Tetris with your infrastructure you know as more containers come in unit we'll just find the best lot to place your containers right until the end you get something like this which is great if you like Tetris and it's also great if you like you know efficiency because as you can see here we're trying to maximize the space that we can get out of our servers and then the last one again I'm developer by trade so I like to program things and change things and so everything you're doing Cuban eight is just an API call ok so you've probably seen you know this is a cool quote request and I can query the API and I can query you know the application that I deployed and then the resource documentation so I can you know I can just read the documentation and create more endpoints so if I want to create if I want to create an application I can just say curl create an application you know curl create another node curl provision load balancer so everything in humanities is just an API call and that's why it's so cool so do you believe me I just made up everything it's demo time okay so before we do the demo though just just a quick description of what we're trying to do so ideally this is what we want to build right we want to build the red pages that people visit okay that's what we do all day however sometimes these red pages they become super popular right so we need two copies instead of one so what do we do to distribute the traffic between the two I hear lot Bansi from the crowd very well now we might have more than one application because awfully you know where we work they don't have like a single product or a single micro service they probably have more than one like like this what if I want to route the traffic to both micro services how do I distribute the traffic I hate a load balancer from the crowd not really but that's the thing okay so so we actually we have two layers of two to level two layers of load balancer easing and when we want to distribute the traffic between several services on an inner infrastructure so we have an external load balancer and an internal load balancer and then the applications so Cuba Navy's we do exactly the same thing we just like to call everything with different names okay so instead of calling look say the internal load balancer internal load balancer we call them services because you know in computer science that's a very specific term the service and then instead of calling the external load balancer the load balancer we call it the ingress okay this is really bit more specific thankfully and and why couldn't the application or container containers where you can call them pods so that's how we call them okay so that's that's basically how we deploy application in Kuban ages so let's have a look so we got we discussed about three three different things we discuss about the ingress the service and then our pods so the way it works is ooh first of all we create a container yes correct me so containing what it is we usually create container from a list of instructions so the list of instruction is usually called a document and this contains basically it's like a glorified eyes or in VirtualBox right you say I want to start with a boom - I want to start a couple of things and he stole my application that's the same thing we're doing containers in this particular case I built a hello world up in Ingo and just packaged inside a container then I can build a container with docker build - g4 the name I can gonna call it a load and then hopefully will not let me down okay so this is gonna take ages and we can move on so what we do when we have this container then we just define how we want to deploy it now everything we do in Cuban 8 is we actually drive this very nice yamo file okay so just to configure it a description of what we want the end product to look like and what the end product will look like is a single application okay what's the name hello world oops and what's the name of a container okay it's called demo I build the wrong one but you get the idea we're basically just describing what what that should look like then we have the service which is the antenna load balancer and the ingress if you think it's a lot of llaman yes it is a lot of llamo and Cuban of these engineers are usually called also yeah mall engineers because that's what we do all day okay so once we once we have those then I have a cluster running locally oh by the way this is just created a container it's it's local so wonderful when we have this these resources locally then what we do is and we have a cluster right our cuban edges cluster in this particular case i'm running a local they're called mini cube which is running on my machine because I was afraid that the internet would not work and and usually what we do is we send these Yama files to the cluster the cluster would read it and then create the resources on our behalf now to send these instructions we use a command to command line to record cube city L which everyone pronounced with a different name keep cattle queue control I say cube city L and then we say and we just send resources you can see that when we went to create these resources then the creative resources are we submit the request but it doesn't it doesn't wait right it's just going to return immediately but in the background what happens is queue areas will go and create these resources for us I can see hello ward here and then the ingress okay so I can see that created all of the resources can I see my application of who's gonna work yes I can okay so that's the application so you can see ckf GED what is that ckf Judy okay well good now the good thing is about Cuban eighties is that we generally have a single application but that's you know we like things to scale so generally what we do is we scale the number of replicas and we scale the number of instances of our application and the way to do that is by writing what we call a deployment which is what I just showed you generally the reason why we use deployments is because in Q&A is when you create the deployment then the deployment looks after your pods right Lucas after your application and in if one of those application was to go down then Cubans will bring it up ok so let's have a look at this one quickly so what I can do I can go in my deployment and I can change the number of replicas which is the instances of my up from one to five and I can see there are five new applications running now so what if I go and delete this one who then I do a get pause but are still five running again okay this is because as one is deleted communities will replace it with a new one okay so it's doing a lot of stuff for free for us okay but one of the things that we do very very frequently when we deploy application is with deployed application and then we have a better version okay with the void version one and then you know a couple of days later we just find a way to refactor everything right and redeploy it again now Kuban it is is quite interesting on this face because it automatically does what we called a rolling update right it's going to do an upgrade of your of your application with zero downtime so how do you do that well if you look at if you look at this at this particular deployment we have three application with a read page so when you say I want to upgrade from version one to version two this is what happens Cubans will create a new version of the application okay and we'll replace it with the old one create a new one replace it create a new one replace it okay because it's doing it one at a time then the traffic never goes down right we definitely we never had downtime so let's have a look at that as well so what would I should show you before we start is that the application exposes a version okay this is version one so what we can do [Music] hopefully this is going to work nope Oh um I'm pretending this is normal but it's actually not so very mind would be I got version 1 you can see version 1 running okay so what I do next I'm gonna go and change DS from version one to version two what would you expect to see now is this is going to continue to be one all the time what's your guess is you're gonna go to - yes hopefully I can have a free-throw X so the way we check that is we do a cube CTL apply - ah okay and it switch back to the sleep and we see what happens well mortu one in two two two okay eventually is going to switch the two right you can see now the whole traffic is going into version two so we just need a rolling update but just changing the version of the application in the specification and and that's basically and curators did a rolling update for us what is my mind okay so so that's basically why everyone is so excited about containers and kubernetes it's quite easy to create deployments it is quite easy to do rolling updates and and because everything's is encapsulated is very hot it's very easy to scale to several servers as Grau so who is using this and why so I think a good example of who is using Cuban eighties for the sort of large-scale processing is this company called open AI so what I do is back I think two years ago now they used to train machine learning models on on Cuba natives and the head like these what we call now medium sized at the time was really large size and we've tried twenty-five hundred nodes okay and then what kind of things they did they install basically something designed to scale the system right so when the application needs to train more models then we'll just create more instances of this model and we'll just you know process more more jobs and then that was combined with another thing in in G K which is the cluster autoscaler so when you run out of space like in this case it will just create more nodes and then keep doing this training of models so they it turns out that they are building a model to play dota which is quite cool and I don't know if you heard the news but I think this year in July they also managed to compete with repro players as well they run for this for competing with pro players later they run much larger cluster we are talking about more than 5,000 nodes of the cluster so it's very cutting edge stuff but at a time the reason why I mentioned in this is because at the time they basically shared what kind of configuration they had for wrong for their own cluster and and this is what's the configuration for the 2500 nodes so you can see that they used 256 P P 10 P hundred which I think RTP use and you know a bunch of the very CPUs this is everything in Google Cloud everything on GK can you guess how much money is this per hour No well it turns out there it's not a lot I mean he's a lot I mean objectively it is a lot so we're talking about US dollars here so it's probably sixteen hundred close to two thousand dollars but if you think about it you're right if you're a student more fear of students probably to experience it but if you are if you're a small research center right you have access to so much power right which normally would be just for you know large corporation or large companies now you can go in gke click on two buttons provision 500 note 5,000 node cluster pay pay two thousand dollars you know for an hour and just take it down this is unprecedented we never had you know such ability to create things so quickly and destroy them even if you're sitting in your room you don't know back home just just mining bitcoins or you know training models so I think this is pretty exciting it's pretty exciting for me so that's everything I wanted to show you today I hope it was 20 minutes ago more or less so we talked about micro-services how things have changed and in the since since from from where we started right from these monoliths we talked about these containers as light of en so just processes that have got memory and CPU limits and and we talked about Cuban eighties as one of these container orchestrators okay so that's everything I wanted to show you today yeah I think we usually run workshops on this kind of stuff we have one coming up the 27 on November but reality is that we're going to do a repeat of of the zero to Cuban 80s course which we have done in September and we're going to do in December what we're going to do in this session is we're gonna do the same three hours you're going to through go through building an application in Cuba next and deploying in okay so last time was quite popular I'm not sure about this time but yeah I think if you're interested these sort of space it's on the 7th of December I think it's on a Saturday so join me and hope you enjoy I think you might have very much for listening to me [Applause]
Info
Channel: Coding Tech
Views: 178,909
Rating: 4.9387794 out of 5
Keywords: kubernetes, containers, docker, deployment, continous integration, continous deployment
Id: u8dW8DrcSmo
Channel Id: undefined
Length: 28min 38sec (1718 seconds)
Published: Tue Nov 26 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.