Stop Avoiding Kubernetes - Set Up a K3S Cluster at Home
Read full transcript 15 segments
-
So, Kubernetes, something I have been So, Kubernetes, something I have been avoiding like the plague on this channel avoiding like the plague on this channel avoiding like the plague on this channel because it just looks way too damn because it just looks way too damn because it just looks way too damn complicated. Today, I am going to force complicated. Today, I am going to force complicated. Today, I am going to force myself to spin up a Kubernetes myself to spin up a Kubernetes myself to spin up a Kubernetes environment, and I am going to pretend environment, and I am going to pretend environment, and I am going to pretend to like it. I'm just kidding. It's a to like it. I'm just kidding. It's a to like it. I'm just kidding. It's a It's a lot more simple than I thought it It's a lot more simple than I thought it It's a lot more simple than I thought it was going to be. Running Kubernetes in was going to be. Running Kubernetes in was going to be. Running Kubernetes in your home lab will solve a bunch of your home lab will solve a bunch of your home lab will solve a bunch of problems you probably don't have. It's problems you probably don't have. It's problems you probably don't have. It's generally designed for managing multiple generally designed for managing multiple generally designed for managing multiple containers or pods across many machines containers or pods across many machines containers or pods across many machines at a large scale. We're talking at a large scale. We're talking at a large scale. We're talking companies running hundreds, if not companies running hundreds, if not companies running hundreds, if not thousands, of different containers thousands, of different containers thousands, of different containers across dozens of servers all over the across dozens of servers all over the across dozens of servers all over the world. Docker Compose for single server world. Docker Compose for single server world. Docker Compose for single server setups are going to handle just about setups are going to handle just about setups are going to handle just about everything beautifully. If something everything beautifully. If something everything beautifully. If something goes down, you restart the stack. If goes down, you restart the stack. If goes down, you restart the stack. If something breaks, you have a backup. You something breaks, you have a backup. You something breaks, you have a backup. You have a backup, right? I hope you have a have a backup, right? I hope you have a have a backup, right? I hope you have a backup. However, Kubernetes is the backup. However, Kubernetes is the backup. However, Kubernetes is the industry standard. It is important to industry standard. It is important to industry standard. It is important to learn if you are in DevOps, SRE, or any learn if you are in DevOps, SRE, or any learn if you are in DevOps, SRE, or any infrastructure role. And if you're going infrastructure role. And if you're going infrastructure role. And if you're going to run Kates, it's your home lab is to run Kates, it's your home lab is to run Kates, it's your home lab is probably the cheapest and easiest place probably the cheapest and easiest place probably the cheapest and easiest place to start. Tinkering, learning, and to start. Tinkering, learning, and to start. Tinkering, learning, and playing. No cloud bill, no pressure, playing. No cloud bill, no pressure, playing. No cloud bill, no pressure, just either a couple VMs with similar just either a couple VMs with similar just either a couple VMs with similar specs or a couple mini PCs. Which, by specs or a couple mini PCs. Which, by specs or a couple mini PCs. Which, by the way, that's where these guys come the way, that's where these guys come the way, that's where these guys come in. This is the Zimaboard. Well, not in. This is the Zimaboard. Well, not in. This is the Zimaboard. Well, not this specifically. This is a piece of this specifically. This is a piece of this specifically. This is a piece of the packaging. But, I'm going to be the packaging. But, I'm going to be the packaging. But, I'm going to be running three of them. You got dual SATA running three of them. You got dual SATA running three of them. You got dual SATA 3.0 ports, so you could use these as a 3.0 ports, so you could use these as a 3.0 ports, so you could use these as a little NAS if you want to. We have dual little NAS if you want to. We have dual little NAS if you want to. We have dual 2.5 gigabit networking, which is 2.5 gigabit networking, which is 2.5 gigabit networking, which is fantastic. 4K display out, which fantastic. 4K display out, which fantastic. 4K display out, which unfortunately, it's a mini display port, unfortunately, it's a mini display port, unfortunately, it's a mini display port, so you got to get a little adapter. And so you got to get a little adapter. And so you got to get a little adapter. And it's a quad-core Intel CPU. It doesn't
-
it's a quad-core Intel CPU. It doesn't it's a quad-core Intel CPU. It doesn't say on here. I believe it's the N the say on here. I believe it's the N the say on here. I believe it's the N the Intel N150, which is a great little Intel N150, which is a great little Intel N150, which is a great little low-power CPU, especially for something low-power CPU, especially for something low-power CPU, especially for something like Jellyfin. Has really good Intel like Jellyfin. Has really good Intel like Jellyfin. Has really good Intel Quick Sync and all that. I believe the Quick Sync and all that. I believe the Quick Sync and all that. I believe the machines I have are 16 gigs of memory. machines I have are 16 gigs of memory. machines I have are 16 gigs of memory. It looks like if Apple was going to make It looks like if Apple was going to make It looks like if Apple was going to make a little single-board computer, this is a little single-board computer, this is a little single-board computer, this is what it would look like. It's all what it would look like. It's all what it would look like. It's all aluminum shell, absolutely beautiful. aluminum shell, absolutely beautiful. aluminum shell, absolutely beautiful. Ton of different accessories. You can Ton of different accessories. You can Ton of different accessories. You can see this one that I have here has the see this one that I have here has the see this one that I have here has the kind of hard drive tray, has a little kind of hard drive tray, has a little kind of hard drive tray, has a little holder if you want to add a PCIE holder if you want to add a PCIE holder if you want to add a PCIE accessory. Overall, these are great accessory. Overall, these are great accessory. Overall, these are great little devices and especially for little devices and especially for little devices and especially for building a nice little clustered building a nice little clustered building a nice little clustered environment like this. They're all environment like this. They're all environment like this. They're all relatively low power. They all are the relatively low power. They all are the relatively low power. They all are the same spec, so it's perfect. But, real same spec, so it's perfect. But, real same spec, so it's perfect. But, real quick, we're going to need to give a quick, we're going to need to give a quick, we're going to need to give a special shout out to the sponsor of special shout out to the sponsor of special shout out to the sponsor of today's video. And that is Plural. All today's video. And that is Plural. All today's video. And that is Plural. All right, so if you're managing Kubernetes right, so if you're managing Kubernetes right, so if you're managing Kubernetes clusters, you already know the pain. clusters, you already know the pain. clusters, you already know the pain. You've got kubectl open one terminal, You've got kubectl open one terminal, You've got kubectl open one terminal, Argo in another tab, Prometheus and Argo in another tab, Prometheus and Argo in another tab, Prometheus and Grafana dashboards everywhere, maybe Grafana dashboards everywhere, maybe Grafana dashboards everywhere, maybe some janky scripts you wrote at 2:00 some janky scripts you wrote at 2:00 some janky scripts you wrote at 2:00 a.m. holding the whole thing together. a.m. holding the whole thing together. a.m. holding the whole thing together. It works, but it is a lot. And that's It works, but it is a lot. And that's It works, but it is a lot. And that's where Plural comes in. This is a where Plural comes in. This is a where Plural comes in. This is a Kubernetes fleet management platform Kubernetes fleet management platform Kubernetes fleet management platform that brings all of that into one place.
-
that brings all of that into one place. that brings all of that into one place. You get full visibility across your You get full visibility across your You get full visibility across your clusters, GitOps deployments, clusters, GitOps deployments, clusters, GitOps deployments, monitoring, troubleshooting, everything monitoring, troubleshooting, everything monitoring, troubleshooting, everything in a single interface. No more bouncing in a single interface. No more bouncing in a single interface. No more bouncing between five different tools just to between five different tools just to between five different tools just to figure out what pod is crash looping. figure out what pod is crash looping. figure out what pod is crash looping. But, something that was kind of exciting But, something that was kind of exciting But, something that was kind of exciting to me is that they just rolled out their to me is that they just rolled out their to me is that they just rolled out their new AI-powered Co-pilot features that new AI-powered Co-pilot features that new AI-powered Co-pilot features that are genuinely useful. So, say you've got are genuinely useful. So, say you've got are genuinely useful. So, say you've got an alert firing or a deployment that is an alert firing or a deployment that is an alert firing or a deployment that is stuck. Instead of digging through the stuck. Instead of digging through the stuck. Instead of digging through the logs and YAML files for an hour, logs and YAML files for an hour, logs and YAML files for an hour, Plural's AI will surface the issue, Plural's AI will surface the issue, Plural's AI will surface the issue, explain what's going on in plain explain what's going on in plain explain what's going on in plain English, and recommend a fix. For English, and recommend a fix. For English, and recommend a fix. For smaller teams that don't have a smaller teams that don't have a smaller teams that don't have a dedicated platform engineering group, dedicated platform engineering group, dedicated platform engineering group, this is huge. You're basically getting this is huge. You're basically getting this is huge. You're basically getting the capabilities of a much larger ops the capabilities of a much larger ops the capabilities of a much larger ops team without the head count. And team without the head count. And team without the head count. And probably the best part is you can just probably the best part is you can just probably the best part is you can just sign up with a card, start using it sign up with a card, start using it sign up with a card, start using it immediately. No sales calls, no waiting immediately. No sales calls, no waiting immediately. No sales calls, no waiting around for a demo, just sign up and go. around for a demo, just sign up and go. around for a demo, just sign up and go. If you're running Kubernetes and want to If you're running Kubernetes and want to If you're running Kubernetes and want to simplify your stack, check out Plural. simplify your stack, check out Plural. simplify your stack, check out Plural. If this is something that interests you, If this is something that interests you, If this is something that interests you, go ahead to the first link down the go ahead to the first link down the go ahead to the first link down the description, give it a click, and try it description, give it a click, and try it description, give it a click, and try it out today. I promise if you're juggling out today. I promise if you're juggling out today. I promise if you're juggling multiple tools, this will simplify your multiple tools, this will simplify your multiple tools, this will simplify your Kubernetes deployments. Let me give you Kubernetes deployments. Let me give you Kubernetes deployments. Let me give you the shortest possible explanation of the shortest possible explanation of the shortest possible explanation of what Kubernetes is and how we're kind of what Kubernetes is and how we're kind of what Kubernetes is and how we're kind of using it today. Nodes are going to be using it today. Nodes are going to be using it today. Nodes are going to be our machines. In this case, I have three our machines. In this case, I have three our machines. In this case, I have three of these Zimaboard twos that we're going of these Zimaboard twos that we're going of these Zimaboard twos that we're going to be installing this on. One is going to be installing this on. One is going to be installing this on. One is going to be our server node or our control to be our server node or our control to be our server node or our control plane, and two are going to be our plane, and two are going to be our plane, and two are going to be our agents, also called workers. The server agents, also called workers. The server agents, also called workers. The server node is our brain. It decides what to node is our brain. It decides what to node is our brain. It decides what to do, where things run, and our agents are
-
do, where things run, and our agents are do, where things run, and our agents are just our workers. They do what the brain just our workers. They do what the brain just our workers. They do what the brain tells it to do. Pods are the smallest tells it to do. Pods are the smallest tells it to do. Pods are the smallest unit in Kubernetes. Think of a pod as a unit in Kubernetes. Think of a pod as a unit in Kubernetes. Think of a pod as a wrapper around one or more containers. wrapper around one or more containers. wrapper around one or more containers. Most of the time, it's just one Most of the time, it's just one Most of the time, it's just one container per pod. So, for example, container per pod. So, for example, container per pod. So, for example, we're going to be running Nginx, so we we're going to be running Nginx, so we we're going to be running Nginx, so we have one Nginx container within the pod. have one Nginx container within the pod. have one Nginx container within the pod. Deployments are how you tell Kubernetes Deployments are how you tell Kubernetes Deployments are how you tell Kubernetes you want three copies of this thing you want three copies of this thing you want three copies of this thing running. Kubernetes will figure out what running. Kubernetes will figure out what running. Kubernetes will figure out what nodes to put them on, and if one dies, nodes to put them on, and if one dies, nodes to put them on, and if one dies, it will spin up the replacements it will spin up the replacements it will spin up the replacements automatically. And then, services are automatically. And then, services are automatically. And then, services are how the pods are actually going to talk how the pods are actually going to talk how the pods are actually going to talk to each other, and how you access them to each other, and how you access them to each other, and how you access them from outside of the cluster. Since pods from outside of the cluster. Since pods from outside of the cluster. Since pods can move around and get new IP can move around and get new IP can move around and get new IP addresses, a service gives you a stable addresses, a service gives you a stable addresses, a service gives you a stable way to reach them. And that's really the way to reach them. And that's really the way to reach them. And that's really the absolute bare bottom basics of what you absolute bare bottom basics of what you absolute bare bottom basics of what you need to get started. And one thing to need to get started. And one thing to need to get started. And one thing to know is we're not actually going to know is we're not actually going to know is we're not actually going to install full-blown Kubernetes in our install full-blown Kubernetes in our install full-blown Kubernetes in our system here. We're going to be system here. We're going to be system here. We're going to be installing K3s. It's a lightweight uh installing K3s. It's a lightweight uh installing K3s. It's a lightweight uh distribution of Kubernetes made by distribution of Kubernetes made by distribution of Kubernetes made by Rancher, now part of SUSE. SUSE. Don't Rancher, now part of SUSE. SUSE. Don't Rancher, now part of SUSE. SUSE. Don't let the name confuse you. It's certified let the name confuse you. It's certified let the name confuse you. It's certified by CNCF. It's real Kubernetes. It's just by CNCF. It's real Kubernetes. It's just by CNCF. It's real Kubernetes. It's just stripped down, doesn't have a bunch of stripped down, doesn't have a bunch of stripped down, doesn't have a bunch of the cloud stuff and bloat for local the cloud stuff and bloat for local the cloud stuff and bloat for local environments, testing, even smaller environments, testing, even smaller environments, testing, even smaller deployments. It's awesome. It comes with deployments. It's awesome. It comes with deployments. It's awesome. It comes with everything you need. It's a single everything you need. It's a single everything you need. It's a single binary under 100 megabytes. It has a binary under 100 megabytes. It has a binary under 100 megabytes. It has a SQLite by default, built-in load SQLite by default, built-in load SQLite by default, built-in load balancer, installs quick. Alternatively, balancer, installs quick. Alternatively, balancer, installs quick. Alternatively, another one that we could have used is another one that we could have used is another one that we could have used is MicroK8s, but that installs with a snap MicroK8s, but that installs with a snap MicroK8s, but that installs with a snap package. It's directly from Canonical, package. It's directly from Canonical, package. It's directly from Canonical, which would make sense considering I'm which would make sense considering I'm which would make sense considering I'm going to be doing this on Ubuntu, but going to be doing this on Ubuntu, but going to be doing this on Ubuntu, but I'm just going to go with K3s uh single
-
I'm just going to go with K3s uh single I'm just going to go with K3s uh single command, low dependencies, and it's used command, low dependencies, and it's used command, low dependencies, and it's used by a lot of people. So, here we are on by a lot of people. So, here we are on by a lot of people. So, here we are on our system. Now, but yes, I am currently our system. Now, but yes, I am currently our system. Now, but yes, I am currently on Windows just because I'm testing a PC on Windows just because I'm testing a PC on Windows just because I'm testing a PC for another video. for another video. for another video. But, that aside, what have I done so But, that aside, what have I done so But, that aside, what have I done so far? We have Ubuntu running on all those far? We have Ubuntu running on all those far? We have Ubuntu running on all those Zuma boards. We have three of them. Zuma boards. We have three of them. Zuma boards. We have three of them. SSH'd into all of them. I've set static SSH'd into all of them. I've set static SSH'd into all of them. I've set static IPs, so you can see we got 191, 192, and IPs, so you can see we got 191, 192, and IPs, so you can see we got 191, 192, and 193 with the appropriate host names for 193 with the appropriate host names for 193 with the appropriate host names for what they're going to be used for. And what they're going to be used for. And what they're going to be used for. And the system is up to date. So, beyond the system is up to date. So, beyond the system is up to date. So, beyond that, we are good to go. Now, you can that, we are good to go. Now, you can that, we are good to go. Now, you can see right here, this is the K3s quick see right here, this is the K3s quick see right here, this is the K3s quick start guide. We're just going to use start guide. We're just going to use start guide. We're just going to use their installation script. Grab that, their installation script. Grab that, their installation script. Grab that, and we're going to install this on the and we're going to install this on the and we're going to install this on the server node. Now, as you can see, I have server node. Now, as you can see, I have server node. Now, as you can see, I have my K8s server, and these two are going my K8s server, and these two are going my K8s server, and these two are going to run as my agents. So, we're going to to run as my agents. So, we're going to to run as my agents. So, we're going to right click. We're going to install this right click. We're going to install this right click. We're going to install this right here. Type in our sudo password, right here. Type in our sudo password, right here. Type in our sudo password, and it's simple as that. It's now and it's simple as that. It's now and it's simple as that. It's now installed, ready to go. We don't have installed, ready to go. We don't have installed, ready to go. We don't have any dependencies or any weird things any dependencies or any weird things any dependencies or any weird things that we had to do or configure to get that we had to do or configure to get that we had to do or configure to get that up and going. And we can see it that up and going. And we can see it that up and going. And we can see it running with a system CTL status running with a system CTL status running with a system CTL status command. So, it's running right there.
-
command. So, it's running right there. command. So, it's running right there. And then, we can also check the node And then, we can also check the node And then, we can also check the node with a K3s cube CTL get nodes command. with a K3s cube CTL get nodes command. with a K3s cube CTL get nodes command. So, you can see my K8s server is ready. So, you can see my K8s server is ready. So, you can see my K8s server is ready. Which this is acting as my control Which this is acting as my control Which this is acting as my control plane. Now, to add the agent nodes, we plane. Now, to add the agent nodes, we plane. Now, to add the agent nodes, we are going to need to know our IP are going to need to know our IP are going to need to know our IP address, which we already do, and we're address, which we already do, and we're address, which we already do, and we're going to need the node token. To get the going to need the node token. To get the going to need the node token. To get the node token, it is a sudo cat command to node token, it is a sudo cat command to node token, it is a sudo cat command to actually print out a file, and that's actually print out a file, and that's actually print out a file, and that's going to be in var lib rancher k3s going to be in var lib rancher k3s going to be in var lib rancher k3s server node token. If we hit enter, we server node token. If we hit enter, we server node token. If we hit enter, we can see our token right here ready to can see our token right here ready to can see our token right here ready to use. This is essentially the password use. This is essentially the password use. This is essentially the password for joining the cluster, so do make sure for joining the cluster, so do make sure for joining the cluster, so do make sure you treat it like one. Don't share it you treat it like one. Don't share it you treat it like one. Don't share it all willy-nilly. Now, let's go ahead and all willy-nilly. Now, let's go ahead and all willy-nilly. Now, let's go ahead and add our two agent nodes. So, we have our add our two agent nodes. So, we have our add our two agent nodes. So, we have our agent nodes right here. And what we're agent nodes right here. And what we're agent nodes right here. And what we're going to want to do is use this command going to want to do is use this command going to want to do is use this command right here. So, it's going to run a kind right here. So, it's going to run a kind right here. So, it's going to run a kind of the same curl command. It's going to of the same curl command. It's going to of the same curl command. It's going to get the K or K3s for us. We have our get the K or K3s for us. We have our get the K or K3s for us. We have our URL, so we're going to want to switch URL, so we're going to want to switch URL, so we're going to want to switch this out for our actual IP address for this out for our actual IP address for this out for our actual IP address for the server. So, mine's 173 10 191. And the server. So, mine's 173 10 191. And the server. So, mine's 173 10 191. And then for your token here, we're going to then for your token here, we're going to then for your token here, we're going to replace this with this right here. So, replace this with this right here. So, replace this with this right here. So, let's grab our token, give that a copy, let's grab our token, give that a copy, let's grab our token, give that a copy, and drop it on in. And before I run it, and drop it on in. And before I run it, and drop it on in. And before I run it, since I do have another agent, I'm going since I do have another agent, I'm going since I do have another agent, I'm going to copy the entire thing, to copy the entire thing, to copy the entire thing, and that should be good to go. So, let's and that should be good to go. So, let's and that should be good to go. So, let's hit enter, type in our pseudo password, hit enter, type in our pseudo password, hit enter, type in our pseudo password, and just to check real quick, we could and just to check real quick, we could and just to check real quick, we could go back over here and two commands up we go back over here and two commands up we go back over here and two commands up we got the get nodes. So, if I run this,
-
got the get nodes. So, if I run this, got the get nodes. So, if I run this, well, yeah, look at that. We can see well, yeah, look at that. We can see well, yeah, look at that. We can see agent one right there. So, I'm going to agent one right there. So, I'm going to agent one right there. So, I'm going to head over to my agent two machine, drop head over to my agent two machine, drop head over to my agent two machine, drop this command right on there, and there this command right on there, and there this command right on there, and there we go. The command is done, so we head we go. The command is done, so we head we go. The command is done, so we head back over here, run this again, we could back over here, run this again, we could back over here, run this again, we could see we have both of our agents. It's all see we have both of our agents. It's all see we have both of our agents. It's all connected together. So, at this point, connected together. So, at this point, connected together. So, at this point, technically, we do have a full technically, we do have a full technically, we do have a full Kubernetes cluster running in my home Kubernetes cluster running in my home Kubernetes cluster running in my home lab, and it took a couple of minutes. lab, and it took a couple of minutes. lab, and it took a couple of minutes. Just to show you what we're working with Just to show you what we're working with Just to show you what we're working with here, we can run this command, the uh here, we can run this command, the uh here, we can run this command, the uh kubectl top nodes, hit enter. kubectl top nodes, hit enter. kubectl top nodes, hit enter. We will run this with pseudo. So, now We will run this with pseudo. So, now We will run this with pseudo. So, now you can see what we got going on when it you can see what we got going on when it you can see what we got going on when it comes to the actual resource usage with comes to the actual resource usage with comes to the actual resource usage with our server using the most at the moment. our server using the most at the moment. our server using the most at the moment. Do note, when I copy and paste commands Do note, when I copy and paste commands Do note, when I copy and paste commands over, I'm pasting everything from over, I'm pasting everything from over, I'm pasting everything from techcut.tv. We do have a full written techcut.tv. We do have a full written techcut.tv. We do have a full written guide on everything that we're doing. guide on everything that we're doing. guide on everything that we're doing. So, if you want to use that to follow So, if you want to use that to follow So, if you want to use that to follow along with all the commands and along with all the commands and along with all the commands and everything, it is there and ready for everything, it is there and ready for everything, it is there and ready for you. So, now that we have a cluster, you. So, now that we have a cluster, you. So, now that we have a cluster, let's actually go ahead and put this let's actually go ahead and put this let's actually go ahead and put this thing to work. What I'm going to do is thing to work. What I'm going to do is thing to work. What I'm going to do is deploy nginx, which is a web server, deploy nginx, which is a web server, deploy nginx, which is a web server, across all three nodes. But, just to across all three nodes. But, just to across all three nodes. But, just to make it a little more fun, we're going make it a little more fun, we're going make it a little more fun, we're going to have each node kind of serve its own to have each node kind of serve its own to have each node kind of serve its own host name, so we can know what is host name, so we can know what is host name, so we can know what is actually or what node is being served to actually or what node is being served to actually or what node is being served to us. So, that way we can literally see us. So, that way we can literally see us. So, that way we can literally see which pod and which actual physical which pod and which actual physical which pod and which actual physical machine is answering the request. So, in machine is answering the request. So, in machine is answering the request. So, in Kubernetes, basically, everything is Kubernetes, basically, everything is Kubernetes, basically, everything is going to be done in YAML files. What I'm going to be done in YAML files. What I'm going to be done in YAML files. What I'm going to do is going to I'm going to going to do is going to I'm going to going to do is going to I'm going to make a directory. I'm going to call this make a directory. I'm going to call this make a directory. I'm going to call this In GenX uh test like that. And then we In GenX uh test like that. And then we In GenX uh test like that. And then we could CD into that directory. And then could CD into that directory. And then could CD into that directory. And then from here, we are going to do this. Say from here, we are going to do this. Say from here, we are going to do this. Say nano In GenX deployment yaml. So, nano
-
nano In GenX deployment yaml. So, nano nano In GenX deployment yaml. So, nano being our text editor just like this. being our text editor just like this. being our text editor just like this. And again, I'm copying and pasting this And again, I'm copying and pasting this And again, I'm copying and pasting this from techcut.tv. from techcut.tv. from techcut.tv. Copy, drop her on in. And we'll kind of Copy, drop her on in. And we'll kind of Copy, drop her on in. And we'll kind of go over what all this is doing. So, up go over what all this is doing. So, up go over what all this is doing. So, up here V1 kind, this is going to be a here V1 kind, this is going to be a here V1 kind, this is going to be a deployment with the name of our web deployment with the name of our web deployment with the name of our web demo. For replicas, we have it defined demo. For replicas, we have it defined demo. For replicas, we have it defined as six, meaning we'll have six copies as six, meaning we'll have six copies as six, meaning we'll have six copies spread across our three machines, so spread across our three machines, so spread across our three machines, so roughly two per node. Roughly was the roughly two per node. Roughly was the roughly two per node. Roughly was the wrong word. And then down here, we will wrong word. And then down here, we will wrong word. And then down here, we will have an argument to run a echo command have an argument to run a echo command have an argument to run a echo command which will define the pod host name which will define the pod host name which will define the pod host name serve from this cluster. So, we'll be serve from this cluster. So, we'll be serve from this cluster. So, we'll be able to see where this is coming from. able to see where this is coming from. able to see where this is coming from. And then down below here, we have our And then down below here, we have our And then down below here, we have our actual service, which is how we'll actual service, which is how we'll actual service, which is how we'll access the pods from outside of the access the pods from outside of the access the pods from outside of the cluster. We're using the node port cluster. We're using the node port cluster. We're using the node port service on 30080, service on 30080, service on 30080, which means we can hit any of our three which means we can hit any of our three which means we can hit any of our three nodes IPs on that port and Kubernetes nodes IPs on that port and Kubernetes nodes IPs on that port and Kubernetes will route us to one of the pods. So, will route us to one of the pods. So, will route us to one of the pods. So, from there, I could go control O, output from there, I could go control O, output from there, I could go control O, output that, control X, and then we will apply that, control X, and then we will apply that, control X, and then we will apply it with a cube CTL apply -f In GenX it with a cube CTL apply -f In GenX it with a cube CTL apply -f In GenX deployment yaml. Hit enter. Ah, wait, deployment yaml. Hit enter. Ah, wait, deployment yaml. Hit enter. Ah, wait, sudo again. I'll add some notes in the sudo again. I'll add some notes in the sudo again. I'll add some notes in the document here about running this without document here about running this without document here about running this without having to do sudo. But for this video, having to do sudo. But for this video, having to do sudo. But for this video, we'll just do it with sudo. So, you can we'll just do it with sudo. So, you can we'll just do it with sudo. So, you can see the web demo is created, the service see the web demo is created, the service see the web demo is created, the service for web demo is created. It's pulling for web demo is created. It's pulling for web demo is created. It's pulling everything. It should be running in the everything. It should be running in the everything. It should be running in the background. We should be able to test background. We should be able to test background. We should be able to test this or check this with cube CTL get this or check this with cube CTL get this or check this with cube CTL get pods - O wide. Screw it. Let's go ahead pods - O wide. Screw it. Let's go ahead pods - O wide. Screw it. Let's go ahead and fix this now, shall we? So, we're and fix this now, shall we? So, we're and fix this now, shall we? So, we're going to change the permissions for our
-
going to change the permissions for our going to change the permissions for our K3s yaml file, so it's readable. And K3s yaml file, so it's readable. And K3s yaml file, so it's readable. And then we will export that. And then we then we will export that. And then we then we will export that. And then we want this to be persistent across want this to be persistent across want this to be persistent across reboots. So, now theoretically, this reboots. So, now theoretically, this reboots. So, now theoretically, this should work. should work. should work. Hey. Hey. Hey. But look at that. We can see we can see But look at that. We can see we can see But look at that. We can see we can see things running. We can see things things running. We can see things things running. We can see things happening. I'm going to stretch this out happening. I'm going to stretch this out happening. I'm going to stretch this out real quick just so you can see it a real quick just so you can see it a real quick just so you can see it a little bit better. We can see they're little bit better. We can see they're little bit better. We can see they're already they're all running. You can see already they're all running. You can see already they're all running. You can see the IPs for them within this network. the IPs for them within this network. the IPs for them within this network. The node that they're all running on. So The node that they're all running on. So The node that they're all running on. So we have two per machine and it's all we have two per machine and it's all we have two per machine and it's all just up spun up for us ready to go. Very just up spun up for us ready to go. Very just up spun up for us ready to go. Very nice. Let me show you the service we nice. Let me show you the service we nice. Let me show you the service we created and what's running in the created and what's running in the created and what's running in the cluster over all. So you can see we have cluster over all. So you can see we have cluster over all. So you can see we have our web demo node port with the IP and our web demo node port with the IP and our web demo node port with the IP and the ports right here. Or if you want to the ports right here. Or if you want to the ports right here. Or if you want to see everything at once, you can do a get see everything at once, you can do a get see everything at once, you can do a get all command just like that. What this all command just like that. What this all command just like that. What this will give us all of the actual pods, the will give us all of the actual pods, the will give us all of the actual pods, the services, and our deployment right here. services, and our deployment right here. services, and our deployment right here. If you want to get specific information If you want to get specific information If you want to get specific information about a specific pod, you can do that as about a specific pod, you can do that as about a specific pod, you can do that as well. So if I copy like this pod name well. So if I copy like this pod name well. So if I copy like this pod name right here and drop it in, hit enter.
-
right here and drop it in, hit enter. right here and drop it in, hit enter. There we go. So if I scroll up you can There we go. So if I scroll up you can There we go. So if I scroll up you can see a lot more very detailed information see a lot more very detailed information see a lot more very detailed information about the specific pod. And just like about the specific pod. And just like about the specific pod. And just like with Docker, we can also see logs of a with Docker, we can also see logs of a with Docker, we can also see logs of a specific pod. So actually if I just go specific pod. So actually if I just go specific pod. So actually if I just go kubectl kubectl kubectl logs and then that, you can see the logs logs and then that, you can see the logs logs and then that, you can see the logs for that specific pod. So now, if I for that specific pod. So now, if I for that specific pod. So now, if I actually open up a web browser here, we actually open up a web browser here, we actually open up a web browser here, we can kind of see what this looks like. So can kind of see what this looks like. So can kind of see what this looks like. So if I open this up and we'll go to http if I open this up and we'll go to http if I open this up and we'll go to http at one of our at one of our at one of our nodes here, so nodes here, so nodes here, so let's go to nine our main one, our let's go to nine our main one, our let's go to nine our main one, our server, at the port 30080. server, at the port 30080. server, at the port 30080. Hit enter and we can see this is served Hit enter and we can see this is served Hit enter and we can see this is served in the K3 or the K3 cluster and we have in the K3 or the K3 cluster and we have in the K3 or the K3 cluster and we have our pod name here. So if I go on and our pod name here. So if I go on and our pod name here. So if I go on and scroll back up here to where it says scroll back up here to where it says scroll back up here to where it says what pod this is on, we can see this is what pod this is on, we can see this is what pod this is on, we can see this is in ending in RQ. We have RQ right here. in ending in RQ. We have RQ right here. in ending in RQ. We have RQ right here. So this is running on our server. If I So this is running on our server. If I So this is running on our server. If I demo this within our terminal, probably demo this within our terminal, probably demo this within our terminal, probably be a better example with a simple curl be a better example with a simple curl be a better example with a simple curl command. Hit enter. You could see ending command. Hit enter. You could see ending command. Hit enter. You could see ending in GL. So, every time I hit this, you in GL. So, every time I hit this, you in GL. So, every time I hit this, you could see it's serving up a different could see it's serving up a different could see it's serving up a different pod. I can hit any node IP and it works pod. I can hit any node IP and it works pod. I can hit any node IP and it works because it's just routing traffic to any because it's just routing traffic to any because it's just routing traffic to any of the healthy pods regardless of what of the healthy pods regardless of what of the healthy pods regardless of what actual node that I'm talking to. And actual node that I'm talking to. And actual node that I'm talking to. And let's say theoretically I wanted to let's say theoretically I wanted to let's say theoretically I wanted to scale this. I want more pods. I'm going scale this. I want more pods. I'm going scale this. I want more pods. I'm going to go ahead and drop this in here. This to go ahead and drop this in here. This to go ahead and drop this in here. This will scale it to 10 pods and then we can will scale it to 10 pods and then we can will scale it to 10 pods and then we can watch them kind of spread out here. So,
-
watch them kind of spread out here. So, watch them kind of spread out here. So, if I hit enter, we could see it going. if I hit enter, we could see it going. if I hit enter, we could see it going. It's running. Run this command again and It's running. Run this command again and It's running. Run this command again and then we could see we have 1 2 3 4 5 6 7 then we could see we have 1 2 3 4 5 6 7 then we could see we have 1 2 3 4 5 6 7 8 9 10 pods distributed very well over 8 9 10 pods distributed very well over 8 9 10 pods distributed very well over all of our different nodes. I could all of our different nodes. I could all of our different nodes. I could easily scale back down just by running easily scale back down just by running easily scale back down just by running the same command with a six. Give that a the same command with a six. Give that a the same command with a six. Give that a second to do what it needs to do. Run second to do what it needs to do. Run second to do what it needs to do. Run this again. We could see it that these this again. We could see it that these this again. We could see it that these ones are terminating and then in a ones are terminating and then in a ones are terminating and then in a matter of no time, okay, some time, matter of no time, okay, some time, matter of no time, okay, some time, granted. They're terminating. It's going granted. They're terminating. It's going granted. They're terminating. It's going to shut down. There we go. Now we only to shut down. There we go. Now we only to shut down. There we go. Now we only got these six running. Now, another got these six running. Now, another got these six running. Now, another thing that's really cool is the thing that's really cool is the thing that's really cool is the self-healing. So, what happens if a pod self-healing. So, what happens if a pod self-healing. So, what happens if a pod just dies? What if it crashes or just dies? What if it crashes or just dies? What if it crashes or something goes wrong? I will delete one something goes wrong? I will delete one something goes wrong? I will delete one and we'll see what happens. So, we are and we'll see what happens. So, we are and we'll see what happens. So, we are going to delete a specific pod. Let's going to delete a specific pod. Let's going to delete a specific pod. Let's say this first one here. So, we'll copy say this first one here. So, we'll copy say this first one here. So, we'll copy that. We'll paste it in and then we can that. We'll paste it in and then we can that. We'll paste it in and then we can watch Kubernetes go ahead and recreate watch Kubernetes go ahead and recreate watch Kubernetes go ahead and recreate it. So, I'll hit that. You could see it it. So, I'll hit that. You could see it it. So, I'll hit that. You could see it deleted from name space, but you can see deleted from name space, but you can see deleted from name space, but you can see this one is a new one. We don't see it this one is a new one. We don't see it this one is a new one. We don't see it over here. It recreated it to keep the over here. It recreated it to keep the over here. It recreated it to keep the environment balanced as we defined with environment balanced as we defined with environment balanced as we defined with the six pod variable. Now, here's kind the six pod variable. Now, here's kind the six pod variable. Now, here's kind of the fun part. I am going to unplug of the fun part. I am going to unplug of the fun part. I am going to unplug one of these machines. Let's say it one of these machines. Let's say it one of these machines. Let's say it crashes. It needs to reboot for an crashes. It needs to reboot for an crashes. It needs to reboot for an update. Something happens. So, right now update. Something happens. So, right now update. Something happens. So, right now it's not perfectly distributed. I have a it's not perfectly distributed. I have a it's not perfectly distributed. I have a couple extra on agent two there. So, couple extra on agent two there. So, couple extra on agent two there. So, that's the machine that I'm going to go that's the machine that I'm going to go that's the machine that I'm going to go ahead and unplug. Now, it might take in ahead and unplug. Now, it might take in ahead and unplug. Now, it might take in a minute cuz Kubernetes doesn't panic a minute cuz Kubernetes doesn't panic a minute cuz Kubernetes doesn't panic immediately. By default, it usually immediately. By default, it usually immediately. By default, it usually takes about 5 minutes for Kubernetes to
-
takes about 5 minutes for Kubernetes to takes about 5 minutes for Kubernetes to decide that a node is truly gone. decide that a node is truly gone. decide that a node is truly gone. Um it doesn't do it immediately just in Um it doesn't do it immediately just in Um it doesn't do it immediately just in case if it's just a little like network case if it's just a little like network case if it's just a little like network blip or something like that. Oh, whoa, blip or something like that. Oh, whoa, blip or something like that. Oh, whoa, there it goes. Woohoo! We got some that there it goes. Woohoo! We got some that there it goes. Woohoo! We got some that terminated. We got some pending. We got terminated. We got some pending. We got terminated. We got some pending. We got some containers that were created. Let's some containers that were created. Let's some containers that were created. Let's go ahead and get out of here and see how go ahead and get out of here and see how go ahead and get out of here and see how it distributed these. it distributed these. it distributed these. Oh, it's going to it's going to take it Oh, it's going to it's going to take it Oh, it's going to it's going to take it a minute. Well, we'll be patient. We'll a minute. Well, we'll be patient. We'll a minute. Well, we'll be patient. We'll be patient. Well, I mean, we can still be patient. Well, I mean, we can still be patient. Well, I mean, we can still kind of see here. We got these two kind of see here. We got these two kind of see here. We got these two running. One is on server and agent one, running. One is on server and agent one, running. One is on server and agent one, server agent one, server agent one. So, server agent one, server agent one. So, server agent one, server agent one. So, it perfectly distributed the total of it perfectly distributed the total of it perfectly distributed the total of six containers to the two nodes that are six containers to the two nodes that are six containers to the two nodes that are still alive and online. And if I go plug still alive and online. And if I go plug still alive and online. And if I go plug it in, it should do the same thing the it in, it should do the same thing the it in, it should do the same thing the other way. So, I got that plugged back other way. So, I got that plugged back other way. So, I got that plugged back in. And I do kind of like how it takes in. And I do kind of like how it takes in. And I do kind of like how it takes about 5 minutes for it to decide to do about 5 minutes for it to decide to do about 5 minutes for it to decide to do that cuz that's about the time, well, that cuz that's about the time, well, that cuz that's about the time, well, less than the time that it takes for less than the time that it takes for less than the time that it takes for like a reboot or something like that, like a reboot or something like that, like a reboot or something like that, which is nice. If I control C out of which is nice. If I control C out of which is nice. If I control C out of there, you could see that my agent two there, you could see that my agent two there, you could see that my agent two node is back online. And if I look at node is back online. And if I look at node is back online. And if I look at our pods, we still have the distribution our pods, we still have the distribution our pods, we still have the distribution between our server and our agent. But, between our server and our agent. But, between our server and our agent. But, uh let's go ahead and watch this again.
-
uh let's go ahead and watch this again. uh let's go ahead and watch this again. So, we'll do the watch variable here and So, we'll do the watch variable here and So, we'll do the watch variable here and just give this some time. Now, these just give this some time. Now, these just give this some time. Now, these pods are not going to automatically pods are not going to automatically pods are not going to automatically redistribute. So, if I drop this on in, redistribute. So, if I drop this on in, redistribute. So, if I drop this on in, we're going to do the rollout restart we're going to do the rollout restart we're going to do the rollout restart deployment of web demo, and then we can deployment of web demo, and then we can deployment of web demo, and then we can watch these redistribute. So, if I hit watch these redistribute. So, if I hit watch these redistribute. So, if I hit enter, you could see it is going to enter, you could see it is going to enter, you could see it is going to terminate and then start up the terminate and then start up the terminate and then start up the everything that we need. Now, if I check everything that we need. Now, if I check everything that we need. Now, if I check this out to via a get pods command or uh this out to via a get pods command or uh this out to via a get pods command or uh sorry, get pods output wide, we can see sorry, get pods output wide, we can see sorry, get pods output wide, we can see a pretty good distribution of all of our a pretty good distribution of all of our a pretty good distribution of all of our pods. Super nice. Now, actually pods. Super nice. Now, actually pods. Super nice. Now, actually physically unplugging a machine is kind physically unplugging a machine is kind physically unplugging a machine is kind of dramatic. Probably shouldn't do that. of dramatic. Probably shouldn't do that. of dramatic. Probably shouldn't do that. There are better ways to do this, and There are better ways to do this, and There are better ways to do this, and that is with the drain command. So, if I that is with the drain command. So, if I that is with the drain command. So, if I grab this, this will gracefully remove grab this, this will gracefully remove grab this, this will gracefully remove all the pods off of a machine. So, you all the pods off of a machine. So, you all the pods off of a machine. So, you can see agent two. So, if I hit enter can see agent two. So, if I hit enter can see agent two. So, if I hit enter from there, you can see we are evicting from there, you can see we are evicting from there, you can see we are evicting two of the pods. So, there we go. We can two of the pods. So, there we go. We can two of the pods. So, there we go. We can see agent two is now drained. Agent two see agent two is now drained. Agent two see agent two is now drained. Agent two no longer has any no longer has any no longer has any pods running on it. If I get my nodes, pods running on it. If I get my nodes, pods running on it. If I get my nodes, we can see agent two is still there.
-
we can see agent two is still there. we can see agent two is still there. It's still ready, but we do have It's still ready, but we do have It's still ready, but we do have scheduling it disabled. If we want to scheduling it disabled. If we want to scheduling it disabled. If we want to allow this pod or this node, sorry, to allow this pod or this node, sorry, to allow this pod or this node, sorry, to start accepting pods again, start accepting pods again, start accepting pods again, we just need to run this command right we just need to run this command right we just need to run this command right here. Hit enter. And now, if I get the here. Hit enter. And now, if I get the here. Hit enter. And now, if I get the nodes, you can see everything is ready. nodes, you can see everything is ready. nodes, you can see everything is ready. And then soon it will redistribute those And then soon it will redistribute those And then soon it will redistribute those pods. And with all that, I do hope you pods. And with all that, I do hope you pods. And with all that, I do hope you found this useful. Again, I'll have a found this useful. Again, I'll have a found this useful. Again, I'll have a more refined article on tech at TV, so more refined article on tech at TV, so more refined article on tech at TV, so you can follow along. you can follow along. you can follow along. I'll throw in some additional tips and I'll throw in some additional tips and I'll throw in some additional tips and tricks and some extra commands to help tricks and some extra commands to help tricks and some extra commands to help you out. Maybe even a couple extra you out. Maybe even a couple extra you out. Maybe even a couple extra optional services with the whole YAML optional services with the whole YAML optional services with the whole YAML template and everything, so you can template and everything, so you can template and everything, so you can practice just spinning some things up. practice just spinning some things up. practice just spinning some things up. Maybe like uptime Kuma I might throw in Maybe like uptime Kuma I might throw in Maybe like uptime Kuma I might throw in there. Maybe a couple others. We will there. Maybe a couple others. We will there. Maybe a couple others. We will see. Link is down below. And again, big see. Link is down below. And again, big see. Link is down below. And again, big shout out to Plural. If you have shout out to Plural. If you have shout out to Plural. If you have Kubernetes environments that need Kubernetes environments that need Kubernetes environments that need monitored at scale with a bunch of monitored at scale with a bunch of monitored at scale with a bunch of different cool tools to help you fix different cool tools to help you fix different cool tools to help you fix deployments, troubleshoot issues, it is deployments, troubleshoot issues, it is deployments, troubleshoot issues, it is great. And that will be the first link great. And that will be the first link great. And that will be the first link down below. And with all that, I do hope down below. And with all that, I do hope down below. And with all that, I do hope you have an absolutely beautiful day.
-
you have an absolutely beautiful day. you have an absolutely beautiful day. And goodbye.
Summary
The main theme concerns the perceived complexity and practical application of Kubernetes, contrasting it with simpler solutions like Docker Compose. Key references include Kubernetes itself, Docker Compose, and the Zimaboard mini-PC for home lab setups. The practical takeaway is that Kubernetes, though initially daunting, is the industry standard and a crucial skill to learn, with home labs offering a cost-effective and pressure-free environment for practice.