Setting up a Raspberry Pi Kubernetes Cluster with Ubuntu 20.04

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello again everyone recently I did a video that showed you guys how to create your very own kubernetes cluster using Raspberry Pi that was a really fun video for me I really enjoyed that one in that video I decided to go with raspbian as the Linux distribution of choice which is now known as Raspberry Pi OS and when I put that video out a lot of you guys reached out to me and asked me to do a video on the same thing but with Ubuntu at that time boom to 2004 was not out yet so I wanted to wait and do some testing and now a boon to 2004 is out the raspberry pi is officially supported and I've had a chance to actually do some testing off-camera and in this video what I'm going to show you guys how to do is again create your very own kubernetes cluster but we're going to use Ubuntu instead of raspberry pi OS now the first question is you know why would I want to do this what's in it for me why would I need to run my own kubernetes stack and what can I do with it now a lot of you guys might be going for certification or something like that and having a low-powered lab might actually be very beneficial for that purpose but maybe you're like me and you run basically a home lab which is essentially running servers out of your house also known as self hosting and if that's you the Raspberry Pi platform uses orders of magnitude lower power than standard x86 servers so that might be something that you can consider and running containers is very great because you know they're smaller you can get more out of your hardware and you learn a really cool platform kubernetes has a lot of fun it might be overwhelming at first but trust me it really isn't just keep learning it and this video can serve as a beginning starting point for getting into kubernetes now as far as what you need to get started you will need at least two Raspberry Pi units to powerchords to go along with them and then an SD card for each now I'm going to go with four raspberry PI's in this video you don't need four so basically you just repeat the worker node process for however many raspberry PI's you have beyond the first the first is going to be the master then every subsequent raspberry pi is going to be a worker node and again I'm going to go through three worker nodes and one master and that's one of the other benefits of this as well because if you max out your raspberry PI's you simply add another raspberry pi join it to the cluster and you can run even more containers allowing you to scale it basically endlessly which is really awesome and it's actually one of the benefits of kubernetes as far as what you can use it for basically you can use this to run docker containers in kubernetes basically presents container orchestration it controls all of your containers and basically allows you to manage them through one console in one suite of command line utilities and you can run all kinds of apps there's all kinds of containers available out there so just go ahead and have a look I'll have some links below in the description where you could go to get a list of some very common and useful containers that you can run you could run web apps you can run all kinds of things in containers it's actually quite fun now as far as what I have right here this right here is probably something that you've seen in the background of most of my videos recently the glowing LED fans is essentially two raspberry pi racks and this is one of them right here and I just wanted to show you guys this case because it's pretty cool now essentially what this case allows you to do is hold four raspberry PI's and it has a glowing fan like I mentioned that keeps them cool and it's just really cool to have I like this case a lot and I even use a power over ethernet hat on each of the PI's so all I need to do is plug in the ethernet cable and they come alive and they're ready to go now I'll give you guys a quick warning I'm not really completely telling you to go grab this case right now it's the best thing ever it does have one downside at least to me getting to the SD cards it's just not really easy I haven't found a way to do it without disassembling it so if you are the type of person that's going to be removing and reinserted SD cards constantly is probably not a very convenient case to get but aside from that one pain point it's actually pretty cool you don't need a case like this to get started I just thought I would mention it just in case you guys were interested but essentially all you need is at least two raspberry PI's one master one node and you can have other nodes as you see fit again I'll show you the process of setting up three nodes and one master [Music] so in this section I'm going to show you guys the process of setting up your SD card with Ubuntu and I'll show you the process on a single SD card and then you could go ahead and repeat for however many pies and SD cards you plan to use now if you've seen me go through this process in other videos I'm going to do pretty much the same thing here I'm going to use etcher to flash the ubuntu image onto the SD card it's a pretty simple procedure and I use edger because it is a cross-platform tool so whether you are running Linux Mac Windows it doesn't matter you'll be able to use this same tool but if you already know how to go through this process you can go ahead and skip to the next section now first of all what you do is you go ahead and scroll down and then this download button should automatically detect your operating system so you simply click on it and it's going to go ahead and download it and you're going to also need the boon to image itself so I will open up a new tab and I will just search for Ubuntu Pi and I'll have a link in the description below so don't worry about that and the first link here is a download page from Ubuntu and then what you do is scroll down and it's going to show a few different Raspberry Pi models so what you do is go ahead and download the one that's appropriate for you if you are on the PI 4 or the PI 3 I recommend the 64 bit version if you are using a PI 2 I'm not really sure if this is going to work out very well because I haven't tested it on the PI 2 at all and I haven't even tested it on the PI 3 either I've only tested it on the PI 4 which is what I'm going to use here and that's what I recommend but what I recommend you do is go ahead and download the 64 bit version like I mentioned and we can see it's downloading right here it's a fairly large file so I'll just let it run I'll be right back now that both tools are downloaded I can go ahead and close out of my browser open up my file manager then in my downloads directory I have a few files here now I've already extracted the etcher utility for a previous video so I should be able to just simply double click on it and there it is so what I will do is choose the file to use as the source and I'll go to my downloads directory and I will choose the Mbutu image that we've downloaded previously and click open and now I need to insert the SD card so if you don't have an SD card slot you could simply use a USB flash card reader or something like that it automatically detected my SD card then I'll simply click the flash button put in my password and then I'll just go ahead and let it run and there we go the SD card is ready to go so at this point I recommend you insert the SD card into one of the raspberry PI's and power it on and just wait to do the others because in the next section I'm going to show you guys how to change the hostname so what you'll do is you'll SSH in you'll change the hostname so that way it gets less confusing each PI will have its own distinct name and we'll bring them online one at a time so that way we don't get confused as to which one is which so in the next section I'm going to show you how to do exactly that I'll SSH into the first unit get it set up with the hostname and then I'll show you how to also set up kubernetes as well so at this point you should have all of the SD cards written and ready to go that you intend to use with your traz berry pies you should also have the first of the series plugged into power and plugged in with an Ethernet cable and ready to go now I haven't gone over the process of setting up Wi-Fi because I feel like with kubernetes you're definitely going to want something stronger than Wi-Fi which is why I recommend a good old fashioned Ethernet cable to get your unit online we're going to start with just the first one so we'll make sure that that's the only one connected and what you'll need is the IP address for your Raspberry Pi for the first one that you plugged in and you can usually get that from your router this is something that I can't show because everyone is using a different router or DHCP server so you should be able to go ahead and find out the IP address for that unit by just logging into the web console of your router and looking at the DHCP assignment list and you should see it right there on the list it should be the most recently assigned IP now once you get the IP address of your PI you will need some sort of terminal to use SSH to connect now in Windows you can use something like putty or the X they do have a boon to four windows now so it really doesn't matter what you go with you need to be able to use SSH and on Mac OS and Linux we have SSH built in and we also have a built in terminal so what I can do is run SSH and then we will type the username ubuntu that's the default user at and then whatever the IP address is that your PI was assigned in my case it was assigned this one right here and it should be that simple I'll press ENTER and it's going to ask me for the password it might ask you something like are you sure you want to connect you could say yes to that the default password is simply Ubuntu and then I'll press ENTER and it's going to basically force you to change your password so you type in the current password again who boon to and then the new one whatever you want it to be and you can see right here that it immediately disconnected me don't worry that was fine it set the new password and now we actually have to login with that password so it dropped the connection I'll press the uparrow Enter I'll type in the new password now notice here in my case it's telling me that we have some updates we should probably take care of that and we will actually take care of that in the next step but right now what we need to do is go ahead and get this unit named so that we don't get confused as to which PI is which so what we'll do is sudo nano you can use vim vim is my preferred text editor I don't really care what text editor you use we need to use some sort of text editor and if you don't have a preference Nano is easy enough we need to edit / Etsy host name just like that I'll press Enter the default hostname is going to be a boon - and this is why we're changing it because if they all come online at the same time with the same host name then we're not going to know from the prompt which one is which I'm going to call mine k8s master just like that and then in Nano you can do ctrl o and then enter to save it and then ctrl X to exit out now next we have another file that we will need to edit so I will do sudo nano slash Etsy again and then slash hosts and I will have all of the commands in a wiki article that you will find the link for in the description below this video so you can either pause the video and enter the commands as I go through them or you could just go ahead and pull up the wiki article and go through it there as well so press ENTER and we can see that it's showing localhost right here so what I'm going to do is just add a new line I'll go to the end and I'll type 127.0.0.1 you can stop right here but if you do have a domain you could go ahead and type it in and I do have one and then we'll just also type the host name without the domain just like that again if you don't have a domain you simply need k8s - master or whatever you decided to call it to make sure that local host is resolvable at the actual host name of the unit so I'll do ctrl o and then enter control X and then I should be able to do sudo reboot to reboot the PI and it could take 30 seconds or so before it becomes available and then we can simply just press the up arrow to recall the ssh command and press Enter see if it's ready and it doesn't look like it's ready quite yet so I just canceled that with control C I'll press the up arrow again and basically I just keep trying you could tell I'm a bit impatient here and there we go and you do have to type the password incorrectly and there we are so now we have the first one done so next what you'll do is go ahead and just plug in the next PI in the sequence repeat the same thing change the host name reboot it so in my case I will open a new tab trying to make the font size reasonably large here so you guys can see it and then I will ssh into the second one and do the exact same thing i'm going to do it off camera though so i will be right back as soon as i have all of the other named and I will actually use the name k8s worker zero one for example for the first worker and then zero two and then zero three and so on so I'll be right back welcome back to the video shortly but I wanted to take a moment to mention my sponsor Linode Linode has been my infrastructure provider for well over a year now and has just recently announced their own managed kubernetes service now you can combine Linn oats ease of use and simple pricing with the infrastructure efficiency of kubernetes with the Linode kubernetes engine you can get your infrastructure and workloads up and running in minutes instead of days and scale resources in real time to meet your infrastructure needs with Leonard's managed kubernetes engine pricing is simple only pay for what you use and with Lyn ODEs 99.9% uptime SLA and bundle transfer you can significantly cut cost when compared to AWS GCP and Azure designed with the open source ecosystem of kubernetes the Linode kubernetes engine supports integration with tools like helm operators and more to help you get started with kubernetes Linode gives you access to in-depth documentation video tutorials and webinars go ahead and sign up at Leno comm slash learn Linux TV to get a sixty dollar 60 day credit to test out lke or any other of Lin oates products I really appreciate Lyn oats continued support of learn Linux TV so go ahead and check them out you won't regret it now let's get back to the video all right so we should be ready to go so I've gone ahead and gone through that process on each one so here I have the master that the first worker the second and the third so let's go ahead and get started so I'll go ahead and paste in the first command here we need to edit a file so I'll just paste it in and again the commands are in the wiki article that I have linked below and I'm going to do the same thing on each you'll notice a pattern here I'm going to keep doing that and we now have the same file open in each of the tabs and what this file does is it just sets some important configurations for building the pie you want to be careful while you edit this file because if you make a mistake it might not operate correctly kubernetes might not work at all it might not but it also definitely be careful now specifically what you are going to do is go to the end of the line press space and then you're going to paste in these values and not all of these are required but I'm going to go ahead and just go up to the beginning of it here it's a little rap so we have C group options so the first one for CPU set for memory we're going to also enable the memory C group option here and add this swap account now now again not all of these are required it's just an attempt to get rid of some annoying messages in the logs and some of them are required but you go ahead and paste these in and they're in the wiki article and make sure you do it at the end of the line and you want to make sure that you have a space between the last option and the first are the ones that we are going to be adding so ctrl o and then enter to save the file ctrl X to exit and what I'm going to do here is just paste again here I'm going to repeat for each of these and again for the last one and we should be good to go on each of those now next what I recommend that we do is install all of the updates to make sure that we have everything well up-to-date we want to basically start from the best possible foundation so let's go ahead and install updates so I'll paste in the command here and essentially what this is going to do is sudo apt update is going to refresh the package index from the repository and then the ampersand ampersand is going to run this second command if the first one is successful sudo apt dist upgrade we'll just install everything that has seen an update since this image was mastered so I'll press ENTER paste enter paste enter and then it basically shows us what all packages it wants to update so I'll just press ENTER to accept the default of YY is in caps there so that means it's the default so enter enter and we'll just wait for all of these updates to install all right so that one's done so is that one awesome they're all done so what we should do right now is reboot each PI to make sure that we take advantage of the new updates so just sudo space reboot easy enough and then we simply give it a minute for all of those to come back online and then we'll go ahead and proceed alright let's go ahead and see if enough time has passed so I'll just press the up arrow [Music] and now we are logged in to each pie and we are ready to go to move on to the next step at this point what I recommend you do and this is optional is go ahead and create a user for yourself so what you'll run is sudo add user and then the name of the user that you want to create I'll use J in my case so what it's going to do is ask you for your password or whatever you want the password of your new user to be so I'll type mine in and then I'll just simply press enter through the breast here so again we ran sudo add user and then our desired user name but we're going to want to make sure that our user is a member of the pseudo group so that way it will be able to run administrative commands so to facilitate that basically all we do is run sudo user mod - lowercase a uppercase G and then the group we want to add the user to which in this case is sudo and then the name of the user that we just created and then I'm simply going to repeat the process for all the other units that I'm setting up you so now we should have our user account on each one of the pies that we can then use to go ahead and finish up the kubernetes installation so to use the new user we will log out of our current session we can either type exit or we could just hold ctrl and press D to disconnect and then we could press the up arrow change the user name to the one we just created and reconnect to each pie as that user to be on the safe side we're going to want to test the sudo command to make sure that it actually works in a very safe and easy way to do that is just use sudo with a tame command like LS and we received no output but we didn't receive any ears which means that it is actually working so I'm going to leave it up to you to create that user on each of your pies add that user to the pseudo group log out log in as that user and then test pseudo with that user with a tame command like LS or similar to ensure that everything is working all right so I've gone ahead and created my user and logged in as my user on each of these next what we're going to do is go ahead and install docker which is required for kubernetes and this is the command to do so right here so I'll press bender on this one and then I'll do the same here as well and then here and you may get prompted for your sudo password or something like that but we'll go ahead and let this run and then it looks like everything was successful here on that one and we're just waiting for the others to finish and it looks like all of them are except for this one so maybe this one has a slower SD card or something it also recommends that you run this command right here to basically add your user to the docker group which is going to make it that much easier so I do recommend that so I'll just simply paste the command in on each of these that was fairly easy we should have docker installed on each of the PI's so next we have a text file that we need to edit and it's this one right here I'll paste the command in here and in the Etsy docker directory we need to edit this file daemon JSON which is not actually going to exist yet so I'll press ENTER here and we're going to do this on each of these PI units and then as far as the contents are concerned I'll go ahead and paste it in here you can fetch this from the wiki article and there it is so again ctrl o and then enter to save and then ctrl X to exit out that's the last time I'll mention that you probably know how to use Nano by now and then next yet another file to edit it's this one right here and see sis CTL dot conf so I'll put sudo nano in front of that so I will have permission to edit the file we will open it in each one as you probably guessed again it's /xe slash cysts CTL conf and what you're looking for is a line that has to do with forwarding ipv4 so if I scroll down here it's this one right here uncomment the next line to enable packet forwarding for ipv4 so I'm basically just going to uncomment that and of course save and exit the file this will allow routing basically and that's going to be required because well we do need a route stuff here so definitely want to make sure that this is set up all right so now that should be good to go so now what we'll do is reboot again to make sure that the changes to these files are in effect so just sue to reboot on each of the PI's then we'll give them a moment to come back up and reconnect okay let's see if enough time has passed all right should be good to go all right so now we are back connected to each of the PI's and ready to continue with setting up kubernetes now first what we want to do on each of the PI's is just make sure that docker is actually working first because that is a prerequisite so it should be able to do system CTL status docker and then enter it is running and then cue to exit and notice that it says some journal files were not open due to insufficient permissions so what we could do is basically put sudo in front of it that we could get some logging information here and because of my font size we're not really going to see much of anything here are we but we want to make sure that it does work so we just checked the status on each just to make sure that we don't have any errors anywhere so far so good and now we can actually go a step further and test docker itself to make sure that it's actually truly working by running a test container and to do that we will run this command right here docker run which is the command that you can use with docker to run a container we want to run a container by the name of HelloWorld so I'll press Enter here of course it's going to download it if the container is in local and according to this message it shows that it's working properly so then we can go ahead and run it on each of our PI's and we'll make sure that each of them are working as they should this one's good that one that one and that one we already tested this one so I know we're good to go on this guy so now we know that docker is actually working it's installed it's ready to go we can go ahead and move on to the next step and the next step is to actually install docker itself so what we'll do first is we will edit this file right here which doesn't exist yet this is going to add the repository that we're going to install kubernetes from so I will open this in each tab here and then inside the file we're going to paste this line right here and notice it says xenial right here which is not the release name for Ubuntu 2004 they haven't released a symlink or a specific version for 2004 just yet when that happens I will update the documentation the wiki article so definitely check that if that has changed but as of the time I'm recording this video this is correct so we'll just go ahead and add this to each and now we have that repository file on each of our nodes but we can't actually use it yet without the GPG key so I will paste that command in here next it's basically going to download the GPG key which is this file right here and then it's going to pipe it into sudo apt key ad which is going to add that key to our system which is going to allow us to make sure that the packages we're downloading are actually signed properly it's a pretty quick command here so it should be pretty easy there we go and then on each of these nodes are going to update our package repository so sudo apt update all right so that appears to have gone correctly on each so far and sure enough we're good there now we're going to go ahead and install the kubernetes packages on each of our nodes and I'll paste the command in right here and I have noticed in the past that if I have too many nodes pulling these down at the same time sometimes it will air out leading me to believe that they may have some sort of rate limiting on the server that I'm downloading this from or the server that these packages are from I'm not sure if that's going to happen here but I'm gonna go ahead and just paste this command in each of them here but if you do get an error just go ahead and try again and I'm actually going to go through this pretty quickly here because I kind of do want it to air out so I could show you guys what I'm talking about let's just see what happens okay so well that one worked that one worked as well that one is fine so they all work this is one of those rare times where actually wanted it to fail so I could show you guys what I was talking about but the installation of those packages that was fine everything worked so we should be good to go on that for now but again if you get any errors during the apt portion of this then just go ahead and run that command again so if you run apt update and it airs out and just press the up-arrow run that again and then maybe you won't get an error the second time same with this command you press the uparrow rerun it if you have any issues and it should be relatively straightforward now this command is unlike the others where we are going to run this on the master only we are not going to run this command on anything but the master and what this is going to do the cube ADM init command is it's going to go ahead and initialize kubernetes specifically the master so we can get this going so I'll press ENTER here and we'll just go ahead and let this finish and right here we can see that the cluster was initialized and we have this command right here this join command which we will be using shortly I'm going to copy this I'm not going to run it yet this is going to be different for each of you so I can't give this to you in the wiki article you will need to use yours because it's going to have a hash that is specific to your cluster and because of that you don't want this command or especially the hash to be publicly available so what I'm going to do is just go ahead and open up a text editor and I'm going to paste it here now again I'm going to be very careful and not upload this anywhere but I just wanted a place to put it for now so I can go ahead and grab it later also we have three commands here that we will need to run so we have this one up here which is going to allow us to create the dot cube directory that we will need then we will copy the admin conf file to our local directory that we just created and then we will also make sure that our user account the one we're logged in with right now is the owner of that file and you simply just copy these commands from your output and then we should be good to go next on the master only we need to run the following command which is this one right here to basically set up a network driver there are multiple network drivers that you can use with kubernetes but it's beyond the scope of this video to cover them all so I'm including this one as an easy way to get started so I'm going to press ENTER on that which is going to basically apply that yamo file and we can see that it's already done and notice I didn't have sudo in front of that that was intentional you shouldn't need that if you have actually added you user to the appropriate group we could check to see whether or not flannel is ready by running cube CTL get pods you want to check all namespaces so if I press ENTER we can see that some of them are already running and we have these two up here that are in the process of being created so basically we just give it a moment if they're not all ready to go and then we just go ahead and check again up arrow and then enter and now they are all ready so they're all running if you get any errors here make sure that you've followed all of the steps properly because you should see what I see here and everything should be running and ready to go now the next part is probably one of my favorites of this entire process and that's adding all of the nodes to the cluster check the status of what nodes are on the cluster we could run cube CTL get nodes just like that which of course is going to show absolutely nothing other than the master because well we haven't even joined anything to the cluster yet and if you remember I stashed this command right here in a text editor and that's exactly why because I knew I was going to need it then on each of the workers we're going to paste that command but we will need sudo for that I'll go ahead and paste it in here and it's setting up the node right now and we should be able to run this right here we see that the new node has been added it's not ready yet it's in the process of being set up and even though it shows that it's finished here there's no output scrolling or anything then we can still see that it's not ready so we'll just give that some time and then in the other tabs here again we're going to run the same join command on each and then on the master we can do watch the magic happen right now we only have the first worker and I'm a bit impatient so I'm going to keep on doing this up there you go we have the second worker already ready to go or at least it's in the process of being set up and now we have the third one as well so basically what we're waiting for is for the status to change to ready like this one is right here and we'll just give it a moment and then we'll go ahead and check back in a few minutes and now we can see that the first one is ready to go so as you can see here all three of the nodes are now ready to go but we can go ahead and move on to the next section so we now have our very own kubernetes cluster running on Raspberry Pi powered by Ubuntu how awesome is that but now that we have a cluster what that do we use it for so what I'm gonna do in this section is show you guys a really awesome website that's going to have a listing of some awesome containers that you can run that'll basically give you guys some good examples and then I'll walk you through running an actual container on our clusters so let's dive back in so back here on my laptop I have an SSH session open to the master and I'm going to walk you through an example but before we do that I want to go ahead and show you guys an awesome website and here it is Linux server IO if we go over here to the images section here we have a listing of some really cool images that we can run on our cluster now it has two support arm in order to work and all the ones that I've tried so far support arm just fine but if you do get any errors that might be why but basically this listing of containers here will give you some exam of things that you can run so if anything there basically catches your attention then you know go ahead and give it a shot but that's basically all I wanted to do there now here on our actual cluster I'm going to walk you guys through running nginx as a proof of concept now I have a couple of files here that I've created off camera and what I'm going to do is make sure the contents of these files are included in the wiki article and the first one is going to be the pod file so I'll just bring it up in a text editor here and this is a yamo file now I want to basically let you guys know I'm not going to give you a complete walkthrough of gamal and I'm not going to give you an in-depth walkthrough of basically how kubernetes works under the hood in this video I do plan on doing some more advanced videos later on but I'm going to give you a high-level overview of what exactly is going on here so first of all we have some generic information we have the API version of version 1 we're not going to change that a kind' basically is telling kubernetes well what the heck it is in this case it's a pod right here it says pod so that's pretty simple and we have some metadata so I just decided to name it nginx example and I'm giving it a label of nginx so you can basically alter your cluster or make changes based on labels and things like that beyond the scope of this video but I wanted to make sure I included that in case you decide to go and look at other examples and for our containers we're going to run a container called nginx and I'm actually going to get this one from Linux server there are other nginx containers out there but I wanted to get one from Linux server uh-oh so that you guys can see basically how to pull a container from a specific site now for the port's we're going to set the container port to 80 which is pretty much standard for a web server like nginx and I'm going to give the port a name I'm just going to call it nginx HTTP it's pretty simple so I'll close this file and we have another file here so it's actually the service and we're going to use node port now I'm not going to get too deep into this concept but there is some general information that I want to make sure that you guys have and that is there are different ways that you can interface with your containers now by default you will not be able to access the containers that are running within your cluster because those are private they are not externally routable if you do want to access the containers that are running within your cluster and I assume nearly all of you will want to do that you're going to need to set up something in front of your cluster or basically create some sort of way of routing traffic from the outside to the inside now the most effective way of doing that is to set up a load balancer and that doesn't work in our case in most cases because we don't actually have an API we can hook into so if you are using Google cloud AWS Leno digitalocean any of those providers or others you'll be able to hook into whatever their load balancer is and create a load balancer that will basically allow your container to be externally available so what I've done here is I've created a node port that's going to go ahead and facilitate accessing this from the outside so what I have here is something called a node port node port isn't always the best way to do it but I think it's the simplest way for me to show you guys this in a tutorial because a full walkthrough of load balancers and the other methods that you can facilitate external to internal traffic is beyond the scope of this particular video but essentially I have some of the same things here API version is again version 1 the kind this time is a service and we have some metadata so again I'm calling it nginx example now for the type it's a node port as you can see right here and then we have some port information so it's HTTP its port 80 and I'm mapping this to port 3-0 zero eight zero it's very common that note ports are 30,000 or so when it comes to the port number starts at 30,000 and my convention is I just make the last digits here just equal to whatever the port is it works for me the target port is nginx HTTP which is what I gave it a name of in the pod file and we have a selector of nginx if we want to select this in particular but we're going to go ahead and close this and then apply our two Yama files to get this container running and make it accessible so first of all what I'm going to do is cube CTL which is the command that we will use to interact with our cluster and we're going to get nodes again just to show one more time that we do have nodes to run containers on and now what I'm going to do is get pods and it's going to show us unless you are working ahead of me that we don't really have any right now but what we want to do is go ahead and get the pod running let's run the nginx pod right now and basically containers run inside pods if you want to know the distinction but we'll do cube CTL apply dash F and then we're going to feed it the file name right here pod yml so in your case you could copy the code from the wiki article save it with whatever name and then apply it with dash F and then whatever name you chose to call it so I'll press Enter and it's just that simple so we can run cube CTL get pods again which previously showed us that we had none and we could see that the nginx example is already running now depending on your speed it's going to have to download the container from the internet and everything and do all the things that it needs to do behind the scenes so it might take some time to become available now like I mentioned we can see that it is running but on which node is it running on now this is the command that we did use to basically get the output from before we can add - Oh and then wide and then press ENTER and we can see that this pod that we are running our nginx container in is actually running on the first worker right here it gives us the name of the actual node that it's running on and it also gives us the internal IP for this pod that's internal to the kubernetes network again this IP is not routable from the outside so what I can't do in let's just say another terminal I open up a new one right here if I go ahead and grab this IP address and then try to ping it from my laptop for example it's not going to work again the IP address is internal to the cluster are not routable from my land I can't access this container or the pod directly but what I can do is put a service in front of it now again I showed that file already and here it is and similar to the previous example what I'm going to run is cube CTL apply - f and then this file and then enter and it tells me that the service nginx example has been created so I could do cube CTL get service and I'm actually able to see that the service for my nginx example is actually running we have a port map right here so if all is working as it should we should be able to enter the IP address of the master but with this port right here and we should actually see the nginx container there so let's just do IP a just did IP space a to get the IP address of my master right here and here it is so I'll copy that then I'll go down here to my browser and I'll paste the IP address in here and then : three zero zero eight zero and enter and it says welcome to our server so we actually know that nginx the container that we decided to run for this example is running and it is accessible from my laptop which is outside of the cluster so we were able to get this accessible from outside the cluster as you can see right here now I typed the IP address of the master so if I go back up here and let's just choose worker 2 it's running on worker 1 you saw that in the output before I'll do IP space a grab the IP address of this particular node just dot 62 and let's just go ahead and change the IP address to that of the second worker node and see what happens same thing so what you can see here is we can basically enter the IP address of the master or any of the actual nodes it doesn't matter but the port right here is specific to this nginx container this pod and that allows us to access it from the outside that's awesome and there you go we were able to run a container in our kubernetes cluster and we were able to access it so from here what you should be able to do is take your knowledge even further go ahead and run some other containers let me know in the comments down below what you decided to run on yours and have some fun so there you go that was my video on how to create your very own kubernetes cluster based on Ubuntu I hope that was fun because I had a lot of fun creating this video I love this stuff let me know what you think of the overall process in the description below and again there is a wiki down in the description as well if you need any of the commands that I've gone over in this video and then I'm going to try to do more kubernetes videos in the future so stay tuned make sure you subscribe so you'll be the first to see any additional content that I'm about to come out with have some awesome videos planned so I will see you soon in the next video [Music]
Info
Channel: LearnLinuxTV
Views: 57,244
Rating: undefined out of 5
Keywords: LearnLinux, Linux, Tutorial, Review, Howto, Guide, Distro, Learn Linux, operating system, os, open-source, open source, k8s, kubernetes, pi, raspberry, raspberry pi, cluster, container, containers, install kubernetes on ubuntu, kubernetes tutorial, kubernetes tutorial for beginners, install kubernetes, setup kubernetes cluster, ubuntu 20.04, kubernetes cluster setup, raspberry pi 4, install kubernetes on ubuntu 20.04, raspberry pi 4 setup, raspberry pi cluster, kubernetes cluster tutorial
Id: qv3_gLvjITk
Channel Id: undefined
Length: 53min 31sec (3211 seconds)
Published: Thu Jun 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.