Kubernetes Tutorial For Beginners - Learn Kubernetes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on guys assalamualaikum welcome to my channel in this video i'm hoping to teach you kubernetes in about 10 minutes so this video is actually a cut down version of the kubernetes queries that i'm actually recording right now so if you want to enroll and gain a certificate go ahead and enroll in my website absolutely for free also in the coming weeks i'll be posting more videos around devops so i've done a survey early in january and you guys wanted to learn about kubernetes aws dockers and so forth so uh yeah so i'm just bringing content that you want without further ado let's kick off this video let's understand the problem that kubernetes tries to solve let's say that we have this web application written in spring boot and react and we want to deploy it into a node so here i've got vm with 8 gigs of ram and 4 cores and inside what you do is deploy a container so usually this is what we do we deploy containers into nodes now let's say that this is the version one of our application now if we have more users visiting our application then we need to scale so here we create yet another node with the same with the same application running so at this point we're just using containers even worse is if we have a new version of our application so let's say that we have a version 2 that we want to deploy then we have to create new node before destroying the version one so hold on you can see that we have a problem right so the problem is that we have 12 cores 24 gigs of ram for three containers which is really insane well this is when kubernetes comes into play now kubernetes in the other hand will take a single node and then utilize the resources in the correct manner so instead it will actually fill the node with as many pods and we talk about ports in our containers in kubernetes but you can think of of a pod as a container but you'll learn more about pods later it will fill the node with as many pods as it can so here you see that we have a couple of pods and and now instead of having one container per node we have multiple containers in one node and then we let kubernetes orchestrate the cluster for us so kubernetes aka kate where the eight is the eight letters in between k and s is an application orchestrator so in this picture you can see that we have kubernetes and kubernetes orchestrates all of these applications when we are talking about applications we mainly refer to containers so kubernetes deploys and manages our containers it also scales up and down according demand it performs zero downtime deployments rollbacks and much more so knowing kubernetes will set you apart from many software engineers because right now the demand for people that understand kubernetes is quite high and the salary as well is super high so known kubernetes will take you a long step in your career now when we talk about kubernetes we need to first understand what a cluster is so a cluster is a set of nodes where a node can be a vm or a physical machine and these can be running on the cloud such as aws azure or google cloud or even on premises now when we talk about the kubernetes cluster we have to understand the difference between the master node and the worker node so the master node is simply the brains of the cluster so this is where all of the decisions are made and then the work nodes this is where all the heavy lifting work happens such as running your applications and both the master and the worker node they do communicate to each other via the cubelet which i'm going to teach you in a second now within a cluster you often have more than one worker node and for this particular cluster we have four nodes in total one master node and three worker nodes right so you saw the architecture around kubernetes so you've got the master node and then you've got worker nodes so within the master node we've got a couple of components that make up the control plane so more on that but i think for now just remember that the master node is like the brains and the worker nodes they actually do all the heavy lifting stuff so they've got the muscles and this is where your applications do run but don't worry too much about the entire architecture because i'll be explaining this in the following weeks this is all for now let's move on so to run kubernetes locally ie to create a local cluster we're going to use a mini cube and this is because municube has a great community lots of add-ons and features and it has great documentation and also you'll see plenty of tutorials out there based off mini cube now the installation process it's really simple all you need is to have docker installed and then mini cube and off you go then once you have a local cluster up and running with mini cube then we need to be able to interact with our cluster from our local machine and this is when cubectl or cubecattle or cubecontrol is used for so cubectl is a command line tool and we can run commands against our cluster we can deploy applications we can inspect we can edit resources we can debug our cluster we can view logs and a bunch more and you're going to learn lots of commands throughout this course but cube ctl will be the command line tool that we're going to use for most of this course in order to learn kubernetes and also cube ctl is what you're going to use in order to connect your cluster whether it's running in production or any environment so you need to be really familiar with cube ctl so in my terminal i do have docker installed so docker dash dash and then version you can see the version there i also have mini cube installed so mini cube and then version and finally i also have cube ctl and then version and there we go so now let's go ahead and quickly start a cluster with two nodes so for that let me clear the screen and we're going to say minicube and then start dash dash and then nodes equals to two enter and there we go so this will take a while and you can see that it's actually pulling a base image so we're running two nodes of docker containers and there we go so that took a while and you can see that it says done cube ctl is now configured to use minicube so here what i'm going to do is i'm going to clear the screen and i'm going to type mini cube and then status and check this out so we have two nodes so this is the first one which is the master and has the control plane running host cubelet api and keep config configured and then we have a second node right here and this is the work node so here what i'm going to do is i'm going to say docker and then ps and you'll see that we have two containers right here so one for the master and then this one right here for the work node so this is why we installed docker in the first place if you want to interact with the cluster let me just clear the screen first and then type cube ctl get and then nodes and you can see that we have two nodes so this is the control plane master and this is the work node now let's go ahead together and see all the pods available within our cluster cube ctl get and then pods dash capital a which means all parts in all namespaces so let me clear the screen run that and you can see that we have a bunch of pods in here so all of these pods they make up the control plane so here for example you have the cube api server and this is the api which is exposed for external and internal communications so when we type cube ctl then this is the api server which is handling the request for us next let's go ahead and learn about pods so in kubernetes a pod is the smallest deployable unit and not containers now to visualize what a pod is i've got this really nice diagram so this is a pod so within a pod you will always have one main container and the main container represents your application whether it's written in node.js javascript or golang whatever language that you want then you may or may not have in its containers and more on in its containers but they are containers which are executed before the main container and then we might or might not have some side car containers so you could have one or two and also here whatever language that you want now sidecar containers are containers that support your main container so for example you might have a container which acts as a proxy to your main container also within pods we can have volumes and this is how containers share data between them now the way that these containers communicate to each other within a pod is using localhost and then whatever port that they expose the port itself has a unique ip address which means that if another pod wants to talk to this pod it uses the unique ip address the smallest deployable unit for docker are containers and for kubernetes are pods right now let's go ahead and deploy this full stack web application using kubernetes so right here i'm using vs code and i've got this extension in here called kubernetes right here which has one million downloads and this will give me auto completion when writing yamls for kubernetes so if you want to follow along go ahead and create a deployment.yaml somewhere in your file system and what i'm going to do here is i'm going to type deployment right here and this is how you should create your pods because deployments are high level construct that gives you a bunch of features and provides declarative updates to your applications so i'm just going to press enter and i get auto completion now i want to leave everything as is so metadata name my app selector match labels app and then my app and then for the same thing in here so template i'm going to leave everything as is and i'm going to change the image so the image go ahead and type amigos code forward slash kubernetes column and then spring boot dash react dash full stack dash v1 so this is a public image that i have in my docker registry so also for resources i'm going to give my application a bit more memory so here let's change this to 5 and then 12. and then finally for the port so the container this one right here is listening on port 8080. so here 8080 and there we go so don't worry too much about this configuration because in the course you will learn everything about this and what all of this means and finally what i want to say is i want two replicas of this application so here i'm going to say replicas and this will be two and the final thing that i want to do is to create a service which will allow us to access the pods so here a service you can think of it as a load balancer i'm going to press enter and then type service and make sure you have the three dashes and there we go auto completion there and in here leave everything as is my app and then port this can be 80 and this will map to 8080 so this is the port that the container is listening on so this selector right here app and then my app it will match any port that has this label right here which is app my app now the last thing that i want to do is i'm going to change this service i'm going to say type and then here we have couple types so let's choose node port and again more on this this will expose a random port on both nodes now let me go back to my terminal and in here type cubectl get and then pods no resources found in the default namespace now in order for us to apply the yaml configuration that we've just created using cubectl type cube ctl and then apply dash f and then the name of the file so deployment.yaml enter and you can see deployment and service my app created so let me type get pods again and this time check this out we have two pods and they are both running so one out of one is running so remember i said that a pod is a collection of one or more containers and now in order for us to access our application let's type together let's type cube ctl first and then get and then service so svc and in here you can see that we have my app type node port cluster ip and then the ports so this is the random port which was assigned to it and here it's forwarding to 80. so the service remember we exposed 80. so it's this guy here so this one right so 480 and then that will forward to our container on 8080. so in order to access this service let's type together minicube and then service and then the name of the service my and then app press enter and this will open up your web browser with the application just give a second and there we go and you can see that we have this url in here and if i open up my web browser and then paste the url enter check this out so we have our full stack application up and running within kubernetes and there you have it you've managed to deploy a full stack application in kubernetes in about 15 minutes and to be honest this is it so you saw how kubernetes it's so so powerful and to be honest i just gave you a taste of the entire course and if you want to enroll to this course and learn everything that you need to know about kubernetes so that you can go off and deploy your applications or if you are getting started as a devops engineer and you want to learn about kubernetes orchestration then i highly recommend to enroll to this course on my website where i'm going to give you a certificate this is all for now i had fun teaching you about kubernetes if you're new to my channel go ahead and subscribe give me a thumbs up so i can keep on recording courses like this and comment down below let me know what you thought about this video that's all for now i'll catch you on the next one you
Info
Channel: Amigoscode
Views: 168,076
Rating: undefined out of 5
Keywords: amigoscode, kubernetes, microservices architecture, kubernetes tutorial for beginners, kubernetes tutorial, what is kubernetes, kubernetes explained, kubernetes architecture, kubernetes networking, kubernetes for beginners, kubernetes basic concepts, kubernetes service, kubernetes vs docker, kubernetes deployment, kubernetes 101, kubernetes pods, learn kubernetes, k8s, kubernetes explained simply, kubernetes course, kubernetes basics, Helm charts Kuberentes
Id: yznvWW_L7AA
Channel Id: undefined
Length: 17min 47sec (1067 seconds)
Published: Sun Apr 11 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.