you need to learn Kubernetes RIGHT NOW!!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you need to learn kubernetes right now but why well kubernetes can deploy 100 docker containers with one command [Music] in this video i'm going to teach you kubernetes we're going to walk through what it is how do you use it and you'll even get a chance to lab this up for free thanks to our sponsor lenode they're giving you a hundred dollar credit for 60 days so check that out link below i'm going to walk you through a lab in lenode all right let's do this kubernetes kubernetes k-8s however you say it it's amazing because it solves a huge problem we have with docker containers or any kind of container like let me show you because you and i we're gonna create a a website a coffee website we're gonna sell network chuck coffee and we're gonna deploy it on a docker container why because docker docker's awesome isolated environment better resource utilization all kinds of stuff if you want to learn more if you have no idea what that is go watch this video right here you'll want to know more about docker before you try and learn about kubernetes because they go hand in hand so i'll deploy my website in our docker container let's go check it out there it is beautiful so professional i mean gosh who professionally designed this and guess what people are buying our coffee like crazy the website's doing so great a little too great actually we're getting so much traffic to our site that it can't handle it it's crashing not only that but the host it's running on it's gone down a few times we've had a few outages so what do we do about that how do we solve it pretty simple right let's set up another host so we get another one so we set up our second container running another host and with docker it's so easy just one easy command boom and done but hold up we're not done yet because we have to make sure that when people hit network shock dot copy when they visit the website that it could go to this server or this server we typically do that with a load balancer so we have to you know figure out how to do a load balancer so we throw that in there okay we're awesome both servers are being used because they're load balanced if one goes down one's still up we're solid well we were because now people they love our coffee man they're they're visiting the website like crazy we're getting so many views and visits and purchases it's almost like we're putting something in it and our servers can't handle it they're crashing again so what do we do we keep scaling out this time we're gonna be prepared so we're going to add not one server but two servers but now the process is kind of getting cumbersome i have to go in and set up another container on that server and then on this new server and oh dang it i have to set up the load balancer to load balance between all these guys so i gotta set that up so we're gonna add these suckers in there okay we should be good now right wrong turns out we're the amazon and coffee we're awesome and we have to add a ton more servers a ton more containers we're talking just astronomical numbers business is good so i have to set up and install all those machines and now i have two more little balancers to handle everything this is too much i can't do this oh crap i have to update my website now we got some new coffee which is great but we have to make a change to every one of our containers in every one of our servers okay i'm done i got two options i can either hire another engineer to do this for me because i'm done with this or i need another solution i need to somehow automate this or hmm maybe orchestrate this somehow maybe some kind of container orchestration know any good ones what about kubernetes let's try that this is where kubernetes comes in it will handle all this junk for us so let's call it kubernetes say you know man i need some help we're starting over i can't do this anymore can you help us and he can now we scaled back a bit just to start so we have our three servers here now the good news is that part of the setup is already done kubernetes is a container orchestrator so we're still going to have our servers and we'll still need some type of container runtime which in our case will be docker it could be something else container d rocket or whatever so just so you know to clear that up it's not kubernetes or docker it's yes both we're gonna use both kubernetes is gonna help us make docker better so what do we do where do we start we first introduce a new server someone who's going to call the shots our master this guy he's the boss he calls the shots with all these servers he tells them what to do keeps them in line make sure they're not acting up now we do need to make our servers part of the team part of the workforce so we'll install kubernetes on these servers that's going to involve two components we'll have our cube proxy and our cubelet i love the names with those two components installed along with their container runtime which in our case is docker they are now part of the team they are team kubernetes they are now worker nodes now what these components do we'll cover here in a moment but just know it's a way for the master to control them and make all this kubernetes goodness happen now the master he's a server just like these guys right here but he's got some special components some special roles that we gave him these are his four jobs or his four components and we'll cover that here in a moment but for now i don't know about you but i want to do something theory is fun until it's not so let's actually start making this let's take our network chuck copy website and let's let's orchestrate it now hold on one second typically setting up kubernetes is kind of hard so in our environment here we have four servers we have our master server which we have to install those four components making it the kubernetes master and then we have our three servers here which are our worker nodes where our containers will run we'll install docker the cube proxy and the cubelet again it's kind of a not really straightforward process but i do have good news for you we have an easier way you see kubernetes is big in the cloud many cloud providers have kubernetes baked in and it's really easy to get it set up one of those is lenode the sponsor of this video and through their cloud platform we can go in there and create a kubernetes cluster this is called a cluster basically for free they give you a hundred dollar credit to use for the first 60 days and you can go crazy well not too crazy and then make it so stupid simple let's go do it right now so go ahead and use my link below get signed up and logged in and we'll go through this right now so once you're in la node on the left side here we have a panel if you scroll down just a little bit you'll see right here there it is kubernetes hit that click it and they want us to add our first kubernetes cluster let's do that so we'll click create let's label it it's just a name we're going to give it i'll name my network coffee where do i want it to be i want it to be close to me so in dallas and then version i'll just select the latest version 1.17 and now we're on to how many servers do we want how many worker nodes do we want to have in our cluster for my lab i'm going to go with the smaller version the node 2 gigabytes i'm going to add three worker nodes by hitting that plus sign right there keeping in mind it will be ten dollars a month so kind of do that math with your 100 credit you have so click on add to add those three notes to my cluster and as i scroll down and get my cluster summary three worker notes 30 bucks a month that's what i'm doing i'll click create cluster and now we wait coffee break let's enjoy our product all right if i scroll down to the bottom here my three nodes are ready they're running awesome now hold on a second though i see one two three worker nodes uh where's my master node where is it this is what's cool about doing kubernetes on lenode in the cloud you pay for everything you use which is a great model so i've got my three worker nodes and those are costing me ten dollars a month so you would probably assume that with our master node that would be another server that would cost us 10 a month no good guy lenode says you know what don't worry about that we're going to throw in the master for free which is super cool but still where uh where is he how do we use them well if you look at this link right here this url the kubernetes api endpoint that's him that's our master looking back at the master components one of his components is the kubernetes api server that's one of the big ones that we care about because that's how we talk to our master that's how we tell him what to do i mean he's the master but we're the master master we're the master of masters okay cool the kubernetes api servers how we communicate with them but then how do we use that it's really easy actually so there's a tool we can install on any machine really i think it's available for windows mac and of course linux it's a tool called cube ctl or cube cuddle it's a command line tool that when we install it we can then run our commands very very similar to docker and make things happen tell our master what to do and then he tells the worker nodes what to do so let's get that cube cuddle set up so here we're going to install it on linux so i've got my kali linux going you can use ubuntu or whatever you want to use first we'll download the latest release of cube ctl or cuddle cube cuddle i have that link and these steps in the description below so go ahead follow that paste that in there i'll hit enter and it downloads the release if i hit ls to list my files and directories there it is right there cube cuddle next we want to make sure that file is executable so i'll use the command chmod for change modification and then i'll do plus x to make it executable and i'll do period forward slash cube ctl that's the file we're going to be editing right now and done and then i'll move that command to my path this is important if you want to be able to use it so we'll do sudo mv remove dot forward slash cube ctl that same file we're looking at and move that to the forward slash user slash local slash bin slash cube ctl and hit the enter button put in your pseudo password and done so cube cuddle is installed but how do we access our new cluster we created in lenode let's do it real quick get back to your lenode dashboard and we scroll up to right here we see cube config it's a yaml file and it gives us all the information we need to know to connect to our cluster here you can either download the file or do what i'm going to do right now and that's open up this little paper looking thing here and look at the code i'm going to copy mine so i'll hit copy and then i'll get back to my linux box my cali box and we'll create our cube config file i'm going to use nano to create that new file so i'll hit nano and then cube config.yaml.yaml i'll paste that in there hit control x and then y to save and then one last command to get this ready we'll use a command export cube config all uppercase equals that file cube config config.yaml done so you're done you're able to connect to your cluster and and do stuff but what do we do now let's try it out so the first command we're going to do is we're going to look at our worker nodes make sure they're there okay alive are you guys okay it'll be cube ctl get nodes this is going to get the 411 on our worker nodes that we just created in lenode let's check it out there they are awesome there's their names they are ready only 24 minutes old so young let's enter one more we'll do cube ctl cluster dash info and we get some cool information right here cube dns we're not going to cover that right now but there's our master right there i told you that was the master okay so now we have our kubernetes cluster ready the master the worker nodes we even have our workstation ready we have the cube cuddle or cube ctl tool installed so we can communicate and talk to our master through the kubernetes api server but what do we do now how do we deploy our website that was the whole point right like how do we solve our problems the good news is that it's very very similar to docker we'll use a command that looks like this cube ctl and we'll say run just like our docker run command and we'll create our container now hold on one second i got to add one more term for you to know when we create a container in kubernetes we're creating something called a pod and inside that pod we have our container so when you think about kubernetes think about pods as containers now technically the containers are inside the pods and you can even have multiple containers inside these pods like we could add another one and another one but typically you'll have one container per pot which sounds weird i know but let's create one real quick the command will be cube ctl run like i just said i'll name my pod just name it network chuck coffee and then i'll specify my docker image that i'm going to use so i'll do image equals and then the image i'm going to pull down which if you're going to follow along it'll be this image right here it'll be the network chuck ford slash nc coffee and then colon pour over and then we'll open up ports dash dash port equals 80. the website port you know http so we'll do that real quick and go created done if we use a command cube ctl git pods we see it's happening right now so the container is creating inside that pod let's do it again just kind of oh it's done it's running but it's just done we just created our first kubernetes pod running our container our website which seems weird and kind of confusing i know trust me but looking back at our diagram this is what happened using cube ctl we said hey master i want you to run with this i want you to create a container for me which i know will be inside a pod so i said cube ctl run blah blah do this and he did using his scheduler component he goes hmm which one of my worker nodes gets this pod you know what this guy right here he's not doing anything hey hey roger hold him roger roger i want you to run this application go and he did now i want to look inside this pod i want to see what's going on i want to know so looking back at our linux box we can use a command called describe it'll be cube ctl describe and we'll just put in pods and let's see what happens boom we get the whole low down on what this guy's doing a lot of information we got the name network chuck coffee we got his ip address every pod is assigned its own ip address notice it's not public it's a private ip address in fact it's so private it's only accessible from kubernetes nodes we'll talk more about that here in a second and all this stuff above this line was more pod information below here we now have our container information so the container is network.coffee there's the id the image that we pulled down the ports that are open and a bunch of other stuff logs and such it's great now for our coffee company we don't want to only deploy one container or one pod we want to deploy a bunch how do we do that with kubernetes that's what he's supposed to do right let me show you so what we just used the cube ctl run command that's more for like ad hoc like let me just create a pod real quick we're now going to try something more more powerful more organized more intentional it's called a deployment with our deployment we're going to say hey master i don't only want just one pod i want three three of what one want three network coffee websites and i want port 80 open now the deployment instead of just telling him in one command i want this to happen we'll actually describe what we want to happen in a file and we'll tell them to look at that file and i've already got the file built out let's go look at it real quick this is our deployment file it's a yaml file just like our cube config earlier these files that describe how kubernetes can create our pods and design our infrastructure we often call these manifest notice that kubernetes is all very uh ship themed the word kubernetes is actually the greek word for a helmsman or a captain a person who steers the ship and of course ship manifest things like that so it's all very nautical and this particular manifest the kind is obviously going to be a deployment so here in this file just a few things i'll show you real quick we named it this is going to be a deployment the app will be named nc coffee replicas how many of these suckers do we want out there we specified right here we want three and then down here we're specifying what container we want to use we're naming our container nc coffee and then there's our container that we're pulling from the docker hub and then of course we want to use port 80 because that's the website port so here's what we're going to do we're going to copy all this mess i'll have that a link to the file below we're going to hop back into our terminal here in linux i'll create the file do nano nc coffee deployment you can name here whatever you want to name it dot yaml and then i'll paste that stuff in there and then control x y enter to save and it's ready and the command is very simple now before we do this i want to delete our pod that we had earlier because if i do cube ctl get pods he's still sitting there let's delete him real quick so i'll do a cube ctl delete pods and i'll just specify his name network chuck coffee and he's gone i do get pods again he sure is gone so now let's deploy our deployment the command will be cube ctl apply dash f and then we'll specify that file name nce coffee deployment dot yaml and that's it i mean it's pretty simple right all the work all the know-how is in that file and i'll hit enter done so if i do real quick i want to go fast cube ctl get pods look they're creating so and they're already done they're already done okay cool and just like that three containers three pods created and here's the cool part about kubernetes it's the concept of desired state that manifest file that deployment is saying hey kubernetes uh master i want there to always be three pods with this image running always not two not four not twelve i want three and he will constantly make sure that's the case be going okay does that manifest out okay yeah okay we're good and he's always making sure it's that state our desired state now if you were to change that manifest file we can like let's say you know three isn't cutting it for me anymore i want i want 10. let's do 10. we can edit that first let me do ctrl l to clear it out here i'll do cube ctl edit deployment and whatever we named our deployment which i believe was nc coffee deployment is that what it was no that's not what it was let me do a cube ctl get deployments there it is right there that's another cool command right we can see our deployment right there three up to date three available awesome so now let's actually edit it ctl edit network chuck coffee dash deployment oh i gotta specify deployment there so let's scroll down to the replicas right here i'm gonna hit i to insert and start editing i'll delete the three and let's put in 10. so this is going to be vi not nano so i'll hit escape colon wq to write and quit and enter it's been updated so let's let's do this real quick cube ctl get pods it already started creating them look at that that's amazing right and just like that 10 pods running because the the commander the helmsman kubernetes the master he was like oh we got to update a manifest let me check it out oh g willow curse we need 10. he talks like that we need 10 of these these 10 going right now and he does it now 10 we only have three servers right like we looking back at our diagram here we have three servers how can we have 10 containers and pods well that's the thing you can have a bunch of pods of the same type on one node that's fine that's part of the scheduler's job the master with a scheduler component will look at all his worker nodes figure out how busy they are and assign things give them jobs again if roger's over there just kind of chilling out he goes hey you know roger can afford to do a few extra things i'm going to give him something another cool view of our pods is a cube ctl and get pods dash oh and wide and we can see their name and their ip address and what server they're running on or what worker node they're uh they're running on so notice this guy right here he's running on blah blah the end of its 233 this guy's running on blah blah blah the end of it's 712 and they're all distributed kind of evenly right and it's the job of the masternode to keep monitoring that process to make sure that any one worker node isn't overworked and if they are overworked he'll take away those pods they'll say hey you know what you're too busy let me take some of that work off you he'll remove the pod and then give it to someone else now we still have a problem here though things are awesome actually we we ran our deployment and we've got a million pods out there 10 but every one of these pods has an internal ip address an ip address that we can't access like like we can't go to our web browser and and put the ip address then it won't happen like right now your stuff your website our website cannot be accessed how do we fix that well we have to expose it this is where the true power of kubernetes comes in i know at this point it's like okay chuck i'm not seeing the big picture how is kubernetes helping us with all this stuff we're about to unwrap it here right now it's cool that we can deploy pods like crazy we can even say if our pods start to get stressed out let's say they go over 75 percent of utilization on the cpu i want you to scale out i want you to go from 10 to 20 or 20 to 30. the master can monitor the metrics of your your cluster and make sure your website is doing great if your website isn't well then we better get some more stuff going but anyways let's talk about how we can get our website accessible to the outside world so in order for johnny right here to buy our coffee to get to our websites and get to our pods we have to expose them but right now they're not exposed in kubernetes when you want to expose a pod or a group of pods to a network we're going to deploy a service this will expose our pods to the internet like we want and it'll actually be a load balancer so when johnny tries to access it'll hit that service and the service will expose the pods and also load balance between the pots so let's deploy that service right now and just like our deployment our service will be described in a yaml file another manifest basically just a set of instructions to give our master saying hey master make this happen buddy so a few things here real quick the kind it's a service we're naming it coffee service and then down here in the server specs we have what type of service is going to be it's going to be a load balancer we're load balancing port 80 on both the load balancer and the pod website traffic and then here's the important part and the killer thing about this the selector which pods are we going to load balance it'll be any pod that has the app label nc coffee this is important because if you look back at our deployment where we deployed our pods our app label for our pods was nc coffee so any pods that has the app label nc coffee that load balance is going to load balance between those so here here's what's killer about that is that if we create two pods it's going to low balance that as long as it has a label and see coffee if we create 2 000 pods as long as it has the label nc coffee it's going to low balance between those 2 000 pods it's just automatic we don't have to worry about it once we create it so let's do it so just as before i'm going to copy all this code here this yaml and i'll get back into my linux box i'll create a new file nano coffee dash service dot yaml paste that in there and do a control x to save y for yes and get out of there and then we'll apply that service and all we have to do is uh cube ctl just like before we'll do apply dash f to specify our template our manifest and it'll be coffee dash service dot yaml yaml and let's do it now it's doing something very exciting i'm gonna okay i'm just gonna enter this command cube ctl get services this is a service we're looking at now and there it is right there coffee service and it's already done crazy fast now what's cool about this is that it created a load balancer in kubernetes but it also created a load balancer in our cloud provider remember i told you that kubernetes loves cloud providers and then the love goes both ways so when i do this command it actually created what's called a node balancer in lenode let's go check it out real quick in the node i'll go back to my side menu here and right here is a node balancer it's just their their clever name for their load balancers they click on that there it is right there my node balancer was created you see the ip address right there it's the same exact one is what we're seeing here in uh in the kubernetes master the external ip right there and we can see in the lenovo portal in our backend status we have three nodes up which is our three worker nodes but in kubernetes it's load balancing between 10 pods let's see if it worked let's go to our website i'm going to copy the ip address open up a new tab and see if it worked bam there's our coffee website being low balance across 10 pods in kubernetes it's running it's working it's alive and we can go in here and buy all the coffee we need and so you believe me about the kubernetes stuff i want to show you how to look at that service and verify it's going between your 10 pods if we do cube ctl get services and we'll specify our coffee service we'll get the lowdown oh i'm sorry not get describe we want to describe that service so describe services describe is always getting more detail coffee dash service and there's all the beautiful information you want to see about this and then right here our end points these few suckers and then seven more it's going to be low balancing uh four so cool amazing oh now hold on you know what i realized looking at our coffee we get a new coffee in peru decaf and all we have is peru so now we have to update our website not too bad with kubernetes let's try it out real quick we've already got the docker image out there the docker image is ready to go all we have to do is pull it and put it out to our what 10 containers now 10 pods let's do that right now back at our linux box i'm going to edit my deployment so i'll do cube ctl edit deployment and it was network chuck coffee dash deployment why'd i make it so long there we go okay two things i want to change right now first is i want instead of 10 servers i want to go to 20 servers why not and then i'm going to change the image i'm looking for instead of network coffee nc copy colon pour over the new label i'm going to use is vac pot that's our latest version so i'm changing the image it's going to pull from if you want to follow along you can do the same thing right now i'm going to hit escape colon wq to write and quit and hit enter it's been updated it's been edited and what should be happening now is if i do cube ctl get pods i should have a bunch of new pods now see it's creating some new ones and terminating old ones because it's updating the existing ones and now just like that look at that ah it's so crazy so now we have 20 pause the 10 we already had or updated they were killed brought down terminated you're fired and we created 10 new ones with that new image and then we added 10 more with that new image and if we look at our load balancer if i do cube ctl get services and i look at my load balancer again so i'll do cube ctl describe services coffee dash service look at that my endpoints it's automatically load balancing between the 20. that's powerful i save myself a lot of time now when i update my website i update it in one place my my docker image and then i just update my manifest file and the rest is history how great how amazing is that let's see if the website works though by the way let's see if our peru decaf has been added so i'll just refresh this page there it is there it is oh my gosh how exciting is that kubernetes truly container orchestration container automation now i just scratched the stinking surface with kubernetes so much i glossed over and so much you can do if you want to dive deeper it's right here on your website first of all if you don't know what a docker container is go watch my video that's a link to that what i use to go a bit deeper with kubernetes is first this pluralsight course by nigel whatever his name is great fantastic check that out and then a book called kubernetes in action it is insanely detailed and amazing go check that out and of course if you want to support more of what i'm doing go check out this is it and support the mission now if you haven't already you can do this lab yourself go sign up for a free account with lenod you get a hundred dollars of credit just to play with and use and you can do this so check it out link below and thanks to lenon for doing that and for sponsoring this video now real quick if you did it already make sure you clean up after yourself and what i mean is you don't want to leave this running open-ended because you'll you'll see a bill if you leave it going forever so what i would do is uh once you're done playing get to your lenovo dashboard go to the kubernetes cluster and you can click your little dots here at the bottom right and say delete you'll see are you are you sure you really want to do this and yeah i do so just put your cluster name in there network copy and click on delete and it goes away it goes away so no more money being charged to you and then also don't forget about the node balancers that will not go away by itself i don't believe so if you go to the left panel here go to node balancers there's the one you should have there same thing click on the dots and click delete and it goes away that node balancer also does cost money i think it it's about 10 bucks a month as well and that's kubernetes uh it's kind of an intense thing to learn because you already have to know about docker containers and then you build on that knowledge by learning about container orchestration which is really cool like it's amazing but it can be very complex now if you want to play with kubernetes more of course you can do that in the cloud most cloud providers have kubernetes built in that's one of the reasons you should learn kubernetes because it makes you more valuable when you're going down that cloud path if you know how to operate and use kubernetes valuable skill but as far as having your own lab you can run kubernetes in your own lab on bare metal servers on virtual machines or even just on your one computer they have what's called mini cube and you can just run kubernetes on one workstation it's pretty cool so there are options but anyways let me know what you think in the comments below let me know if you're able to go through the lab if you think kubernetes is amazing just let me know below i i love seeing your comments and it really encourages me to keep going and keep making videos like this well that's all i got um this video took a lot i had to learn kubernetes from the ground up but it's fun learning new things and i encourage you to do what i did when you learn something new like this turn it around and make a video about it or make a blog post teach someone about it it really two things happen you learn it better when you teach it and also you're helping people you're helping someone else who's coming behind you to learn that same technology and then third kind of bonus it shows future employers that you can first of all communicate and learn something new you're you're hungry for knowledge anyways yeah that's that's really all i got i'm gonna stop talking now um if you haven't already hit that like button if you like the video it does help subscribe notification bell you know all that stuff and if you want to help me do more of this make training make videos make certification stuff check out this is it or hit the join button on the youtube thing below or you know what you can buy some network shut copy because it's a legit thing go to networkchuck.com you can actually go to my real website well guys that's all i got i'll catch you later [Music] you
Info
Channel: NetworkChuck
Views: 426,104
Rating: 4.9530888 out of 5
Keywords: kubernetes tutorial, kubernetes for beginners, learn kubernetes, cloud computing, kubernetes tutorial for beginners, learn kubernetes step by step, kubernetes architecture, docker tutorial, k8s, kubernetes explained, kubernetes networking, kubernetes deployment, kubernetes service, kubeadm, linode, kubernetes linode, kubectl, kubelet, kubeproxy, kubernetes vs docker, docker on kubernetes
Id: 7bA0gTroJjw
Channel Id: undefined
Length: 29min 34sec (1774 seconds)
Published: Tue Sep 08 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.