Kubernetes Crash Course for Beginners | Hands-On Tutorial + First Deployment
Read full transcript 15 segments
-
Welcome to this Kubernetes crash course Welcome to this Kubernetes crash course for complete beginners. My name is for complete beginners. My name is for complete beginners. My name is Misha. I'm a senior DevOps engineer from Misha. I'm a senior DevOps engineer from Misha. I'm a senior DevOps engineer from the Netherlands. I'm a Microsoft MVP and the Netherlands. I'm a Microsoft MVP and the Netherlands. I'm a Microsoft MVP and a certified [music] a certified [music] a certified [music] cubster. And I've taught Kubernetes to cubster. And I've taught Kubernetes to cubster. And I've taught Kubernetes to well over a thousand people at this well over a thousand people at this well over a thousand people at this point. By the end of this video, you're point. By the end of this video, you're point. By the end of this video, you're going to have an understanding of what going to have an understanding of what going to have an understanding of what Kubernetes is, what problems it's Kubernetes is, what problems it's Kubernetes is, what problems it's solving, and you'll even be deploying solving, and you'll even be deploying solving, and you'll even be deploying your first application. So, let's dive your first application. So, let's dive your first application. So, let's dive right in. I always teach my students right in. I always teach my students right in. I always teach my students that you have to learn by doing with that you have to learn by doing with that you have to learn by doing with Kubernetes [music] because Kubernetes is Kubernetes [music] because Kubernetes is Kubernetes [music] because Kubernetes is so broad. it is so much that you have to so broad. it is so much that you have to so broad. it is so much that you have to get hands on as soon as possible and get hands on as soon as possible and get hands on as soon as possible and that's what we're going to do in this that's what we're going to do in this that's what we're going to do in this video as well. So why Kubernetes? Well, video as well. So why Kubernetes? Well, video as well. So why Kubernetes? Well, the problem it's solving is managing the problem it's solving is managing the problem it's solving is managing containers at scale and let me just give containers at scale and let me just give containers at scale and let me just give you a quick explanation of that. So, you a quick explanation of that. So, you a quick explanation of that. So, traditionally you would have several traditionally you would have several traditionally you would have several virtual machines and each virtual virtual machines and each virtual virtual machines and each virtual machine would run one or more machine would run one or more machine would run one or more applications that would have your web applications that would have your web applications that would have your web server and maybe you would have a server and maybe you would have a server and maybe you would have a separate virtual machine for your separate virtual machine for your separate virtual machine for your databases and these together would be databases and these together would be databases and these together would be serving your application whether that is serving your application whether that is serving your application whether that is in the cloud or on on premises uh in the cloud or on on premises uh in the cloud or on on premises uh deployments. But then containerization deployments. But then containerization deployments. But then containerization came along and you might know this as came along and you might know this as came along and you might know this as docker containers. Well, docker containers. Well, docker containers. Well, containerization solves a few problems containerization solves a few problems containerization solves a few problems where you don't need as much resources where you don't need as much resources where you don't need as much resources per application. So now you're able to per application. So now you're able to per application. So now you're able to run many many containers on one virtual run many many containers on one virtual run many many containers on one virtual machine, which is great because then machine, which is great because then machine, which is great because then each container has its own little each container has its own little each container has its own little isolated environment and then it can isolated environment and then it can isolated environment and then it can share the resources from the virtual
-
share the resources from the virtual share the resources from the virtual machine OS or the kernel. Now this is machine OS or the kernel. Now this is machine OS or the kernel. Now this is great and this worked really well. But great and this worked really well. But great and this worked really well. But what if we want to have several what if we want to have several what if we want to have several containers uh across multiple virtual containers uh across multiple virtual containers uh across multiple virtual machines? How are we going to get the machines? How are we going to get the machines? How are we going to get the containers over there? Well, one one containers over there? Well, one one containers over there? Well, one one solution for that is for example Anible. solution for that is for example Anible. solution for that is for example Anible. You can do very intricate things with You can do very intricate things with You can do very intricate things with putting containers everywhere, but it putting containers everywhere, but it putting containers everywhere, but it gets quite messy very quickly and it's gets quite messy very quickly and it's gets quite messy very quickly and it's it's it's all imperative. You're saying it's it's all imperative. You're saying it's it's all imperative. You're saying put this container here and that's it. put this container here and that's it. put this container here and that's it. So what happens when a container dies So what happens when a container dies So what happens when a container dies and how are you going to um configure and how are you going to um configure and how are you going to um configure networking to load balance across these networking to load balance across these networking to load balance across these containers on multiple machines. These containers on multiple machines. These containers on multiple machines. These are all difficult problems that the are all difficult problems that the are all difficult problems that the Kubernetes project is solving. So this Kubernetes project is solving. So this Kubernetes project is solving. So this is where Kubernetes comes in. is where Kubernetes comes in. is where Kubernetes comes in. Like I said, it solves the problem of Like I said, it solves the problem of Like I said, it solves the problem of managing containers at scale. when you managing containers at scale. when you managing containers at scale. when you have many containers across different have many containers across different have many containers across different servers and when you are starting to servers and when you are starting to servers and when you are starting to look into scaling. Maybe you want your look into scaling. Maybe you want your look into scaling. Maybe you want your application to scale out when there are application to scale out when there are application to scale out when there are a lot of people active like a newspaper a lot of people active like a newspaper a lot of people active like a newspaper which is usually read in the morning and which is usually read in the morning and which is usually read in the morning and in the evening and in the middle of the in the evening and in the middle of the in the evening and in the middle of the day you don't need as much capacity for day you don't need as much capacity for day you don't need as much capacity for example and also how are you going to example and also how are you going to example and also how are you going to handle software updates when you have handle software updates when you have handle software updates when you have all these containers running everywhere.
-
all these containers running everywhere. all these containers running everywhere. So this is what Kubernetes solves. It's So this is what Kubernetes solves. It's So this is what Kubernetes solves. It's what you call a container orchestrator. what you call a container orchestrator. what you call a container orchestrator. It orchestrates the deployment of It orchestrates the deployment of It orchestrates the deployment of containers over multiple machines. And containers over multiple machines. And containers over multiple machines. And the simplest way that I can that I the simplest way that I can that I the simplest way that I can that I always use with my students is always use with my students is always use with my students is Kubernetes is basically a way of making Kubernetes is basically a way of making Kubernetes is basically a way of making all of these virtual machines talk to all of these virtual machines talk to all of these virtual machines talk to each other intelligently and having this each other intelligently and having this each other intelligently and having this sort of control center over it that sort of control center over it that sort of control center over it that manages all of the containers over all manages all of the containers over all manages all of the containers over all of these virtual machines and scales of these virtual machines and scales of these virtual machines and scales them out and make sure that everything them out and make sure that everything them out and make sure that everything is up and running. So that is the the is up and running. So that is the the is up and running. So that is the the simplest way that I can explain it. The simplest way that I can explain it. The simplest way that I can explain it. The benefits of this is that you get benefits of this is that you get benefits of this is that you get automation. So you can tell Kubernetes I automation. So you can tell Kubernetes I automation. So you can tell Kubernetes I want three containers running and then want three containers running and then want three containers running and then Kubernetes is handling the rest. This Kubernetes is handling the rest. This Kubernetes is handling the rest. This will help you to create scalability. You will help you to create scalability. You will help you to create scalability. You can scale in and out your application can scale in and out your application can scale in and out your application like I mentioned and high availability.
-
like I mentioned and high availability. like I mentioned and high availability. If one of your containers goes down due If one of your containers goes down due If one of your containers goes down due to an error. If you have multiple to an error. If you have multiple to an error. If you have multiple replicas running, then Kubernetes is replicas running, then Kubernetes is replicas running, then Kubernetes is automatically going to route all of the automatically going to route all of the automatically going to route all of the traffic to the ones that are online and traffic to the ones that are online and traffic to the ones that are online and it's going to try and it's going to spin it's going to try and it's going to spin it's going to try and it's going to spin up the other one that has failed. It's up the other one that has failed. It's up the other one that has failed. It's going to create a new one for that. So going to create a new one for that. So going to create a new one for that. So that's a bit of the theory that this is that's a bit of the theory that this is that's a bit of the theory that this is the problem that Kubernetes is solving. the problem that Kubernetes is solving. the problem that Kubernetes is solving. Now, how can we get started with Now, how can we get started with Now, how can we get started with Kubernetes? Well, I always recommend the Kubernetes? Well, I always recommend the Kubernetes? Well, I always recommend the tool Rancher Desktop for my students. tool Rancher Desktop for my students. tool Rancher Desktop for my students. This is because it is u you can it's a This is because it is u you can it's a This is because it is u you can it's a one-click install. You download it. You one-click install. You download it. You one-click install. You download it. You can download it for app for Mac OS both can download it for app for Mac OS both can download it for app for Mac OS both silicon and Intel for Windows and Linux. silicon and Intel for Windows and Linux. silicon and Intel for Windows and Linux. So, it runs everywhere. You download it, So, it runs everywhere. You download it, So, it runs everywhere. You download it, you start it, and then you have a you start it, and then you have a you start it, and then you have a Kubernetes cluster running. It's really Kubernetes cluster running. It's really Kubernetes cluster running. It's really that simple. There are several that simple. There are several that simple. There are several alternatives. I spent hours and hours alternatives. I spent hours and hours alternatives. I spent hours and hours researching this, but the this is the researching this, but the this is the researching this, but the this is the tool to get if you are just starting tool to get if you are just starting tool to get if you are just starting out. Take my word for it. Then I have a out. Take my word for it. Then I have a out. Take my word for it. Then I have a full video on my channel that you can full video on my channel that you can full video on my channel that you can find if you search for rancher desktop find if you search for rancher desktop find if you search for rancher desktop on my channel. So when you install on my channel. So when you install on my channel. So when you install rancher desktop then it will also rancher desktop then it will also rancher desktop then it will also install cubectl. This is the this is install cubectl. This is the this is install cubectl. This is the this is called cube control. This is the CLI the called cube control. This is the CLI the called cube control. This is the CLI the command line interface for kubernetes.
-
command line interface for kubernetes. command line interface for kubernetes. How you can manage kubernetes clusters How you can manage kubernetes clusters How you can manage kubernetes clusters from the command line which is what from the command line which is what from the command line which is what we're going to be doing in a second. And we're going to be doing in a second. And we're going to be doing in a second. And when you have installed this then you when you have installed this then you when you have installed this then you should be able to run cubectl get nodes. should be able to run cubectl get nodes. should be able to run cubectl get nodes. So I have my Kubernetes cluster over So I have my Kubernetes cluster over So I have my Kubernetes cluster over here. If I write cubectl get nodes then here. If I write cubectl get nodes then here. If I write cubectl get nodes then what we see here is that I have a what we see here is that I have a what we see here is that I have a cluster with one node which is a control cluster with one node which is a control cluster with one node which is a control plane. You might see several nodes. It plane. You might see several nodes. It plane. You might see several nodes. It depends a bit on your configuration and depends a bit on your configuration and depends a bit on your configuration and your system. But this is what um what your system. But this is what um what your system. But this is what um what you will see. And if this gives output you will see. And if this gives output you will see. And if this gives output then you know that you have a Kubernetes then you know that you have a Kubernetes then you know that you have a Kubernetes cluster running. you are talking to a cluster running. you are talking to a cluster running. you are talking to a Kubernetes cluster. Kubernetes cluster. Kubernetes cluster. Nodes are what I mentioned here. A Nodes are what I mentioned here. A Nodes are what I mentioned here. A Kubernetes node is basically a virtual Kubernetes node is basically a virtual Kubernetes node is basically a virtual machine that is part of a Kubernetes machine that is part of a Kubernetes machine that is part of a Kubernetes cluster. A Kubernetes cluster can be one cluster. A Kubernetes cluster can be one cluster. A Kubernetes cluster can be one or more virtual machines or even bare or more virtual machines or even bare or more virtual machines or even bare metal machines. So, one machine is metal machines. So, one machine is metal machines. So, one machine is already a Kubernetes cluster. But already a Kubernetes cluster. But already a Kubernetes cluster. But technically um what Kubernetes is technically um what Kubernetes is technically um what Kubernetes is basically made for is to make all of basically made for is to make all of basically made for is to make all of these machines talk to each other and these machines talk to each other and these machines talk to each other and clustering them and making making it so clustering them and making making it so clustering them and making making it so that you can expand and contract your that you can expand and contract your that you can expand and contract your cluster as the demand arises. So now cluster as the demand arises. So now cluster as the demand arises. So now that we have our Kubernetes cluster that we have our Kubernetes cluster that we have our Kubernetes cluster running, let's get into a couple of core running, let's get into a couple of core running, let's get into a couple of core concepts.
-
The first core concept are pods. A pod The first core concept are pods. A pod is the smallest unit of deployment on is the smallest unit of deployment on is the smallest unit of deployment on Kubernetes. A pod is a collection of Kubernetes. A pod is a collection of Kubernetes. A pod is a collection of containers and a few other things which containers and a few other things which containers and a few other things which in which you can run your application. in which you can run your application. in which you can run your application. So it's important to know that a pod is So it's important to know that a pod is So it's important to know that a pod is the unit but inside of the pod you can the unit but inside of the pod you can the unit but inside of the pod you can have multiple containers. This is have multiple containers. This is have multiple containers. This is important to remember but usually it's important to remember but usually it's important to remember but usually it's just one container especially when you just one container especially when you just one container especially when you are a bit just starting out then it's are a bit just starting out then it's are a bit just starting out then it's just one going to be one container and just one going to be one container and just one going to be one container and pods are also ephemeral just like pods are also ephemeral just like pods are also ephemeral just like containers you don't store any state containers you don't store any state containers you don't store any state inside of your pods they are meant to be inside of your pods they are meant to be inside of your pods they are meant to be spun up and killed and um they are spun up and killed and um they are spun up and killed and um they are ephemeral they can die and be replaced ephemeral they can die and be replaced ephemeral they can die and be replaced now the second unit is a deployment so a now the second unit is a deployment so a now the second unit is a deployment so a deployment is a collection of parts deployment is a collection of parts deployment is a collection of parts So if I go to my Kubernetes cluster and So if I go to my Kubernetes cluster and So if I go to my Kubernetes cluster and if I run K rung engine X image equals if I run K rung engine X image equals if I run K rung engine X image equals engine X then it's going to create one engine X then it's going to create one engine X then it's going to create one pod of engine X k get pods and now I pod of engine X k get pods and now I pod of engine X k get pods and now I have one pod of engineext running. I have one pod of engineext running. I have one pod of engineext running. I have one instance of an enginex web have one instance of an enginex web have one instance of an enginex web server running as a standalone unit.
-
server running as a standalone unit. server running as a standalone unit. This is the smallest unit that you can This is the smallest unit that you can This is the smallest unit that you can get. Now I I use the K run command and get. Now I I use the K run command and get. Now I I use the K run command and you see that I use K for short for you see that I use K for short for you see that I use K for short for cubectl. This you will see this cubectl. This you will see this cubectl. This you will see this everywhere. So if I then want to delete everywhere. So if I then want to delete everywhere. So if I then want to delete this pod I would say K delete pod and this pod I would say K delete pod and this pod I would say K delete pod and then press tab and then engine X is then press tab and then engine X is then press tab and then engine X is shown to me. And now my pod is deleted shown to me. And now my pod is deleted shown to me. And now my pod is deleted again. I can say I declare a desired again. I can say I declare a desired again. I can say I declare a desired state. So for example I want three state. So for example I want three state. So for example I want three replicas of engine X. I want three replicas of engine X. I want three replicas of engine X. I want three instances of my engine X application to instances of my engine X application to instances of my engine X application to run on this cluster. Figure it out and run on this cluster. Figure it out and run on this cluster. Figure it out and then when I create this deployment then then when I create this deployment then then when I create this deployment then Kubernetes is going to figure it out and Kubernetes is going to figure it out and Kubernetes is going to figure it out and deploy that for us. It ensures that the deploy that for us. It ensures that the deploy that for us. It ensures that the current state equals the desired state. current state equals the desired state. current state equals the desired state. So when one of these pods dies, then So when one of these pods dies, then So when one of these pods dies, then it's going to fix that. And I'm going to it's going to fix that. And I'm going to it's going to fix that. And I'm going to show you that in a in a second. So let's show you that in a in a second. So let's show you that in a in a second. So let's just create our first deployment. We're just create our first deployment. We're just create our first deployment. We're going to be creating an again an enginex going to be creating an again an enginex going to be creating an again an enginex deployment. You will often see engine X deployment. You will often see engine X deployment. You will often see engine X used in tutorials like this because it's used in tutorials like this because it's used in tutorials like this because it's a very common application, but also it a very common application, but also it a very common application, but also it has a nice way of verifying that it has a nice way of verifying that it has a nice way of verifying that it works by curling or visiting it in the works by curling or visiting it in the works by curling or visiting it in the browser. So I'm going to create my browser. So I'm going to create my browser. So I'm going to create my deployment. And now my deployment is uh deployment. And now my deployment is uh deployment. And now my deployment is uh running. So if I do k get pods now, now running. So if I do k get pods now, now running. So if I do k get pods now, now I see that I have a deployment again, a I see that I have a deployment again, a I see that I have a deployment again, a pod again, but it's just one instance.
-
pod again, but it's just one instance. pod again, but it's just one instance. And why is that? Well, we didn't specify And why is that? Well, we didn't specify And why is that? Well, we didn't specify how many replicas we wanted, right? So how many replicas we wanted, right? So how many replicas we wanted, right? So that's what we're going to do in the that's what we're going to do in the that's what we're going to do in the next section. So if I if I now do k I next section. So if I if I now do k I next section. So if I if I now do k I have my pods but if I do k get have my pods but if I do k get have my pods but if I do k get deployment deployment deployment now we see that we have one deployment now we see that we have one deployment now we see that we have one deployment and that we have one container of one and that we have one container of one and that we have one container of one the of the desired state it's all the of the desired state it's all the of the desired state it's all looking good now what if I want to have looking good now what if I want to have looking good now what if I want to have multiple instances of this application multiple instances of this application multiple instances of this application right well how would we do that let me right well how would we do that let me right well how would we do that let me just first delete the deployment now my deployment is deleted. K get now my deployment is deleted. K get pods. I don't have any pods anymore. And pods. I don't have any pods anymore. And pods. I don't have any pods anymore. And let's just create the deployment again. let's just create the deployment again. let's just create the deployment again. But now I will pass the flag replicas But now I will pass the flag replicas But now I will pass the flag replicas equals three. So now the deployment is equals three. So now the deployment is equals three. So now the deployment is created again. And if I do k get pods created again. And if I do k get pods created again. And if I do k get pods now, then we see, hey, now we have three now, then we see, hey, now we have three now, then we see, hey, now we have three pods running. Do you see that? So just pods running. Do you see that? So just pods running. Do you see that? So just by adding the replicas flag to this by adding the replicas flag to this by adding the replicas flag to this command, I now have three instances of command, I now have three instances of command, I now have three instances of my deployment up and running. So if I do my deployment up and running. So if I do my deployment up and running. So if I do k get pods and if I now for example k k get pods and if I now for example k k get pods and if I now for example k delete pod and I just delete one of delete pod and I just delete one of delete pod and I just delete one of these and it's delete now and if I these and it's delete now and if I these and it's delete now and if I quickly if I now quickly run the k get quickly if I now quickly run the k get quickly if I now quickly run the k get pods command again we see that the new pods command again we see that the new pods command again we see that the new one is actually 2 seconds old now. So one is actually 2 seconds old now. So one is actually 2 seconds old now. So this is how quick this went right you this is how quick this went right you this is how quick this went right you you could see how quickly this went. So you could see how quickly this went. So you could see how quickly this went. So maybe I can open up a
-
maybe I can open up a maybe I can open up a second window here. If I do watch n0.5 and then cube ctl get pods and then cube ctl get pods like this. So now I'm running this every like this. So now I'm running this every like this. So now I'm running this every 0.2 seconds. And if I now would delete 0.2 seconds. And if I now would delete 0.2 seconds. And if I now would delete another one. K delete pod another one. K delete pod another one. K delete pod my engine x like this. Then look in the my engine x like this. Then look in the my engine x like this. Then look in the bottom screen here you will see one is bottom screen here you will see one is bottom screen here you will see one is deleted very quickly. And now it's up deleted very quickly. And now it's up deleted very quickly. And now it's up and running again. That's how fast it and running again. That's how fast it and running again. That's how fast it goes. So for a split second there, you goes. So for a split second there, you goes. So for a split second there, you could see that the current state was could see that the current state was could see that the current state was different from the desired state. And different from the desired state. And different from the desired state. And then Kubernetes stepped in and created a then Kubernetes stepped in and created a then Kubernetes stepped in and created a new pod to make sure that those three new pod to make sure that those three new pod to make sure that those three replicas that I specified are always replicas that I specified are always replicas that I specified are always online. And this is why Kubernetes is online. And this is why Kubernetes is online. And this is why Kubernetes is the way to run containers at scale. So the way to run containers at scale. So the way to run containers at scale. So now we have our deployment up and now we have our deployment up and now we have our deployment up and running. We have our pods with engine X running. We have our pods with engine X running. We have our pods with engine X up and running. How are we going to up and running. How are we going to up and running. How are we going to connect to this? So, a full rundown of connect to this? So, a full rundown of connect to this? So, a full rundown of Kubernetes networking is out of scope Kubernetes networking is out of scope Kubernetes networking is out of scope for this video. There is one coming up.
-
for this video. There is one coming up. for this video. There is one coming up. So, make sure you subscribe. But I will So, make sure you subscribe. But I will So, make sure you subscribe. But I will give you a very quick introduction to give you a very quick introduction to give you a very quick introduction to it. So, when we have our deployment it. So, when we have our deployment it. So, when we have our deployment here, if I do k get pods o wide, then we here, if I do k get pods o wide, then we here, if I do k get pods o wide, then we see that our pods all get their own IP see that our pods all get their own IP see that our pods all get their own IP address, right? So, Kubernetes has its address, right? So, Kubernetes has its address, right? So, Kubernetes has its own internal network inside of the own internal network inside of the own internal network inside of the cluster. Now what I could do is if I cluster. Now what I could do is if I cluster. Now what I could do is if I want this container to talk to the other want this container to talk to the other want this container to talk to the other container, I could say send a curl container, I could say send a curl container, I could say send a curl command to this IP address and it would command to this IP address and it would command to this IP address and it would work. However, the problem is if I work. However, the problem is if I work. However, the problem is if I delete one of these pods like this. like this. So we deleted H8. So this is the one H8. So we deleted H8. So this is the one H8. So we deleted H8. So this is the one H8. This had IP6. This had IP6. This had IP6. If I do K, get pulse o wide again. Then If I do K, get pulse o wide again. Then If I do K, get pulse o wide again. Then here we see that the H81 is gone and the here we see that the H81 is gone and the here we see that the H81 is gone and the IP this the IP ending in 16 is also IP this the IP ending in 16 is also IP this the IP ending in 16 is also gone. Right? So the new pod received a gone. Right? So the new pod received a gone. Right? So the new pod received a new IP address. So there's no way that I new IP address. So there's no way that I new IP address. So there's no way that I could point my traffic to an IP address could point my traffic to an IP address could point my traffic to an IP address because this is constantly changing because this is constantly changing because this is constantly changing because every time I roll out an update, because every time I roll out an update, because every time I roll out an update, all of my pods have a new IP address. So all of my pods have a new IP address. So all of my pods have a new IP address. So what are we going to do? Well, the the what are we going to do? Well, the the what are we going to do? Well, the the way this is solved in Kubernetes is by way this is solved in Kubernetes is by way this is solved in Kubernetes is by the usage of services. So, I have my the usage of services. So, I have my the usage of services. So, I have my pods here and this doesn't matter how pods here and this doesn't matter how pods here and this doesn't matter how many these are, how big they are, but many these are, how big they are, but many these are, how big they are, but over o over here there is something over o over here there is something over o over here there is something that's called a service. A service is
-
that's called a service. A service is that's called a service. A service is then going to be routing those the then going to be routing those the then going to be routing those the traffic to those pods. And this service traffic to those pods. And this service traffic to those pods. And this service which is called a cluster IP which is called a cluster IP which is called a cluster IP service. That's the the the standard the service. That's the the the standard the service. That's the the the standard the the basic service that you get. There the basic service that you get. There the basic service that you get. There are multiple types but we'll get into are multiple types but we'll get into are multiple types but we'll get into that in a different video. But this that in a different video. But this that in a different video. But this gives me a stable IP to refer to. So I'm gives me a stable IP to refer to. So I'm gives me a stable IP to refer to. So I'm just saying hey if I want to reach my just saying hey if I want to reach my just saying hey if I want to reach my front-end deployment talk to the cluster front-end deployment talk to the cluster front-end deployment talk to the cluster IP service and then the cluster IP IP service and then the cluster IP IP service and then the cluster IP service is going to handle the rest. So service is going to handle the rest. So service is going to handle the rest. So I can freely delete and create new pods I can freely delete and create new pods I can freely delete and create new pods under here. It doesn't matter what I'm under here. It doesn't matter what I'm under here. It doesn't matter what I'm doing. This service is just one stable doing. This service is just one stable doing. This service is just one stable endpoint and it's going to handle the endpoint and it's going to handle the endpoint and it's going to handle the routing of the traffic to the right pods routing of the traffic to the right pods routing of the traffic to the right pods for me. So this is how that works. Now for me. So this is how that works. Now for me. So this is how that works. Now let's deploy our first service then. How let's deploy our first service then. How let's deploy our first service then. How are we going to do that? Well in this uh are we going to do that? Well in this uh are we going to do that? Well in this uh the cube cubectl cube control has a very the cube cubectl cube control has a very the cube cubectl cube control has a very neat command for that which is called neat command for that which is called neat command for that which is called expose. So now we're running cubectl expose. So now we're running cubectl expose. So now we're running cubectl expose deployment my engineext on port expose deployment my engineext on port expose deployment my engineext on port 80 and this has now created a service.
-
80 and this has now created a service. 80 and this has now created a service. So if I want to see my service I can do So if I want to see my service I can do So if I want to see my service I can do k get service k get service k get service and then we see our engine x service and then we see our engine x service and then we see our engine x service over here. You see that it has a type over here. You see that it has a type over here. You see that it has a type cluster IP and this is an IP address cluster IP and this is an IP address cluster IP and this is an IP address that is going to be stable and I can that is going to be stable and I can that is going to be stable and I can just always point it to there. So if I just always point it to there. So if I just always point it to there. So if I want to access this service then then we want to access this service then then we want to access this service then then we use something that's called port use something that's called port use something that's called port forward. So let me run the port forward forward. So let me run the port forward forward. So let me run the port forward command here. cubectl port forward and command here. cubectl port forward and command here. cubectl port forward and then we're pointing it to a service then we're pointing it to a service then we're pointing it to a service called my engineext and I'm I'm I want called my engineext and I'm I'm I want called my engineext and I'm I'm I want this to be available on port 8080 on my this to be available on port 8080 on my this to be available on port 8080 on my local machine and it needs to connect to local machine and it needs to connect to local machine and it needs to connect to port 80 in that deployment. So each pod port 80 in that deployment. So each pod port 80 in that deployment. So each pod is going to expose pod 80 to the service is going to expose pod 80 to the service is going to expose pod 80 to the service and we are routing the traffic through and we are routing the traffic through and we are routing the traffic through there. So if I now go to my browser and there. So if I now go to my browser and there. So if I now go to my browser and I do localhost 8080 then we see that I I do localhost 8080 then we see that I I do localhost 8080 then we see that I am now presented with a web page welcome am now presented with a web page welcome am now presented with a web page welcome to engine X. And if I start deleting to engine X. And if I start deleting to engine X. And if I start deleting pods and and and messing around with pods and and and messing around with pods and and and messing around with things then every time I make a new things then every time I make a new things then every time I make a new request to the service this is now going request to the service this is now going request to the service this is now going to be routed to one of the pods that I to be routed to one of the pods that I to be routed to one of the pods that I have available. And that is in a have available. And that is in a have available. And that is in a nutshell how Kubernetes networking works nutshell how Kubernetes networking works nutshell how Kubernetes networking works and it's very simple, very beautiful and and it's very simple, very beautiful and and it's very simple, very beautiful and it it is it works extremely well. So now it it is it works extremely well. So now it it is it works extremely well. So now we have three pods running. We have an we have three pods running. We have an we have three pods running. We have an engineext deployment that is highly engineext deployment that is highly engineext deployment that is highly available. But what if our traffic available. But what if our traffic available. But what if our traffic increases? What if we want to have a increases? What if we want to have a increases? What if we want to have a whole bunch of people um visiting our
-
whole bunch of people um visiting our whole bunch of people um visiting our website? Well, then we can scale our website? Well, then we can scale our website? Well, then we can scale our deployment with the following command, deployment with the following command, deployment with the following command, the cubectl scale command. I can scale the cubectl scale command. I can scale the cubectl scale command. I can scale my deployment and I give it to the I'm my deployment and I give it to the I'm my deployment and I give it to the I'm I'm targeting the deployment my engine I'm targeting the deployment my engine I'm targeting the deployment my engine X. Now I'm just saying I want my X. Now I'm just saying I want my X. Now I'm just saying I want my replicas to become 10. So now the replicas to become 10. So now the replicas to become 10. So now the deployment apps my engine X is scaled. deployment apps my engine X is scaled. deployment apps my engine X is scaled. If I now do K get pods again, we see If I now do K get pods again, we see If I now do K get pods again, we see that I have 10 pods running. Now they that I have 10 pods running. Now they that I have 10 pods running. Now they are all if I do k get pods and pipe that are all if I do k get pods and pipe that are all if I do k get pods and pipe that to w to w to w then we get 11 lines which is correct then we get 11 lines which is correct then we get 11 lines which is correct because this is including the top line because this is including the top line because this is including the top line and we have 10 pods ready um running and we have 10 pods ready um running and we have 10 pods ready um running already. If I do k get deployment then already. If I do k get deployment then already. If I do k get deployment then we see that we have now a status of 10 we see that we have now a status of 10 we see that we have now a status of 10 of 10 ready and they're all up to date of 10 ready and they're all up to date of 10 ready and they're all up to date and all available. So this is how easy and all available. So this is how easy and all available. So this is how easy it is to scale up and down applications it is to scale up and down applications it is to scale up and down applications on Kubernetes. If I were do if I were to on Kubernetes. If I were do if I were to on Kubernetes. If I were do if I were to do this in the old situation with do this in the old situation with do this in the old situation with Anible, then how are you going to figure Anible, then how are you going to figure Anible, then how are you going to figure out where the pod is? Uh how many there out where the pod is? Uh how many there out where the pod is? Uh how many there are are already where you want to place are are already where you want to place are are already where you want to place the other ones, how to distribute them the other ones, how to distribute them the other ones, how to distribute them evenly. Kubernetes is handling all of evenly. Kubernetes is handling all of evenly. Kubernetes is handling all of this for you. Again, it's container this for you. Again, it's container this for you. Again, it's container orchestration at scale. And this is why orchestration at scale. And this is why orchestration at scale. And this is why this is such a powerful tool and why this is such a powerful tool and why this is such a powerful tool and why it's only gaining in popularity.
-
it's only gaining in popularity. it's only gaining in popularity. In fact, the average salary for In fact, the average salary for In fact, the average salary for Kubernetes jobs is $160,000 Kubernetes jobs is $160,000 Kubernetes jobs is $160,000 a year and the trend is only going a year and the trend is only going a year and the trend is only going upward and there are only more and more upward and there are only more and more upward and there are only more and more jobs coming every single year. jobs coming every single year. jobs coming every single year. So you we've seen how we can scale the So you we've seen how we can scale the So you we've seen how we can scale the the the pod and the deployment and now the the pod and the deployment and now the the pod and the deployment and now the service is also going to be load the service is also going to be load the service is also going to be load balancing the traffic all through that balancing the traffic all through that balancing the traffic all through that deployment. So this was just a very deployment. So this was just a very deployment. So this was just a very quick introduction and I hope you quick introduction and I hope you quick introduction and I hope you followed along with the CLI commands. followed along with the CLI commands. followed along with the CLI commands. It's very important that you get started It's very important that you get started It's very important that you get started handson with this stuff as soon as handson with this stuff as soon as handson with this stuff as soon as possible. So install wrencher desktop possible. So install wrencher desktop possible. So install wrencher desktop and do it quickly. Now the truth is in and do it quickly. Now the truth is in and do it quickly. Now the truth is in in real life you are not sitting there in real life you are not sitting there in real life you are not sitting there and and saying uh give me 10 uh pods now and and saying uh give me 10 uh pods now and and saying uh give me 10 uh pods now and you're not sitting there scaling and you're not sitting there scaling and you're not sitting there scaling your deployments up and down by CLI your deployments up and down by CLI your deployments up and down by CLI commands. This is all handled with KDA commands. This is all handled with KDA commands. This is all handled with KDA Kubernetes event driven autoscaling and Kubernetes event driven autoscaling and Kubernetes event driven autoscaling and you would not be deploying things by you would not be deploying things by you would not be deploying things by running CLI commands. You are doing running CLI commands. You are doing running CLI commands. You are doing githops for that. And finally, let's githops for that. And finally, let's githops for that. And finally, let's just clean everything up what we have just clean everything up what we have just clean everything up what we have deployed. So, so first of all, we have deployed. So, so first of all, we have deployed. So, so first of all, we have our service kvc.
-
our service kvc. our service kvc. We have our engineext service. So, let's We have our engineext service. So, let's We have our engineext service. So, let's just delete that first. So, that is now just delete that first. So, that is now just delete that first. So, that is now deleted. And then we have our deleted. And then we have our deleted. And then we have our deployment. So, it wouldn't work if I deployment. So, it wouldn't work if I deployment. So, it wouldn't work if I start deleting pods now because then uh start deleting pods now because then uh start deleting pods now because then uh then the deployment would just keep then the deployment would just keep then the deployment would just keep recreating them. If I want to get rid of recreating them. If I want to get rid of recreating them. If I want to get rid of the pods, I actually have to delete the the pods, I actually have to delete the the pods, I actually have to delete the deployment. So, k delete deployment deployment and my engine X. And now our deployment and my engine X. And now our deployment and my engine X. And now our deployment is being deleted. And if I now do K get is being deleted. And if I now do K get is being deleted. And if I now do K get pods, everything is cleaned up and I pods, everything is cleaned up and I pods, everything is cleaned up and I have nothing running in my cluster have nothing running in my cluster have nothing running in my cluster anymore. So there you go. If you want to anymore. So there you go. If you want to anymore. So there you go. If you want to get access to this text file and have a get access to this text file and have a get access to this text file and have a list of all the commands, then jump into list of all the commands, then jump into list of all the commands, then jump into my free community. It's all there. And my free community. It's all there. And my free community. It's all there. And this is about as much as I could cram this is about as much as I could cram this is about as much as I could cram into a 20inute video. Kubernetes is a into a 20inute video. Kubernetes is a into a 20inute video. Kubernetes is a huge topic. It deserves a lot more huge topic. It deserves a lot more huge topic. It deserves a lot more attention. But again, I want to impress attention. But again, I want to impress attention. But again, I want to impress upon you that it's so important to get upon you that it's so important to get upon you that it's so important to get hands-on as soon as possible. And I hope hands-on as soon as possible. And I hope hands-on as soon as possible. And I hope this video helped you to do that. Let me this video helped you to do that. Let me this video helped you to do that. Let me know in the comments what you thought, know in the comments what you thought, know in the comments what you thought, and I'll see you in the next one.
Summary
This crash course introduces Kubernetes, highlighting its role in solving the challenges of managing containers at scale across multiple machines. The main takeaway is to learn by doing, as Kubernetes is broad and requires hands-on experience to understand its declarative approach to container orchestration, moving beyond imperative methods like Ansible. By the end, beginners will grasp Kubernetes' purpose and be able to deploy their first application.