K3S (by Rancher) | Setup a lightweight Kubernetes Cluster in Minutes | Hands-on Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to another video boy cloud versity my name is stefan and i want to talk about k3s today so k3s is a lightweight kubernetes distribution which you can use for different purposes speaking for myself i use kaperia's as a demo or playground environment at home but we also use k3s at work and i just want to share some knowledge about k3s because it's just a great product developed by rancher in this video i will show how you can deploy a kubernetes cluster based on kps by yourself all you need is a linux machine or maybe two linux machines so you can follow along because we will deploy on one linux machine masternode and on the other one worker node if this sounds interesting to you make sure that you hit the like and subscribe button down below and that you follow me on social media and i will roll the intro and after the intro we will dive right into the topic so see you in a second welcome back before we get our hands dirty on uh executing some cube control commands and spinning up clusters and stuff like this we should take a look at the theory first just for a couple of minutes so this is the website from k3s it's just k3s.io and they promise that you can spin up a cluster within 30 seconds if you execute this command if you click on docs in the top right corner here you will be brought to another or to the documentation page of k3s and it tells you that the binary is less than 100 max which is really small and it's great for devices like edge devices and iot devices and for development purposes so you can even run k3s on your raspberry pi or pi's if you have multiples multiple of them and as i already said in the intro we are using kfrs for development environments and work so this works as well and what else is written down here what is interesting yeah the name the name is actually interesting so probably you already know that kubernetes the shortcut for kubernetes is k8s so it's just k and s and between are eight letters so it's k8s so why k3s now because k3s is half the size of the kubernetes binary so it's like only five letters long and then k and s now just five letters in between three letters in between now so it's k3s actually a pretty funny idea of naming products and we can have a look at the architecture as well so you can spin up a single server setup with the embedded database which then will be sqlite or you can have a high availability setup with multiple master nodes multiple worker nodes which are called agent nodes and what else do we have yeah and we have additional deployment possibilities but on the main page is also the a nice picture or nice image of how it actually works in detail so it spawns a process and as you can see on the left side it spawns a process with the sqlitedb then there's the api server the scheduler the controller manager and the proxy so it's pretty similar to what k8s or kubernetes has per default and then we have the worker node and on the worker node there's the cubelet addition there's a cubelet and here which is really great is that we have container d installed if we install the binary so that's actually great because you don't need to have docker pre-installed or something so the the binary will include cube control and it will include container d and then you can just spin up parts so that's that's pretty much it and i would say let's get our hands dirty and we will do now the practical stuff after we took a look at the theory first for a couple of minutes what i did in advance of this video i went to lenode and i created two little nodes so the nanos it's just because they are really small it's just one gig a one gig of memory and one cpu um both of them have a public ip address and yeah we can connect to them so we save some minutes setting those up and by the way i'm not sponsored by the node so it's just a really simple cloud provider everyone can use it's cheap it's easy great we don't need more for those tutorials um yeah okay so i will bring this to the left side o k so i'm connected here to the master node and the second tab is the worker node and what we need to execute to get everything running is actually in one of my repositories i wrote it down i will post a link in the description down below uh you can just check this repo out or i mean it's not a real repositories just read me in the manifest so uh take a look if you want to replicate what i'm showing here in this video so to install the master we will throw this into the command line so it's a little bit longer command than what we actually saw here at the beginning and this one because you can extend your command with properties or with additional commands and you can find them in the on the ranger documentation page under installation installation options and then the server configurations or the agent configuration page then you will have all those informations here so you can set for example where you want to write your cube config to which permissions the cubeconfig should have you can provide the node name etc etc and you can even use docker if you want to but as i said it will run on container d by default and because docker is dropped by kubernetes since version 1.20 or 1.21 not sure i think 1.20 it's good that we run on container d so typically here's a no deploy traffic typically k3s comes with an ingress controller which is traffic but we will actually use nginx in a minute so let's hit enter and hack the time so let's see i guess it's like 15 seconds now and we are done so our kubernetes is probably running we can check this with cube control get nodes let's see and there we are it's not ready yet so the master's just starting just starting up but we have it here and cube control was not installed before so i can show you if i go to the second node and run cube control the command is not there so cube control is within the binary we just installed okay so for the next step we need to have a valid token which we need to give our worker node so he can attach to the to our cluster so if you want to be added to the cluster he needs to provide a token and we will find this token here under var lib or enter k free as server note token we just cat this token here to the console so this is our token we need to have this ready and then what we need to do as we go to our second node our worker node and then we have this command here as you can see before i will make this here a little bit bigger before i passed the additional commands like this so with the dash dash right cubeconfig for example but you can also do it like this you can pass k3 as node name as an environment variable so it's on you and it's also listed in the documentation of the k3s page so whatever you prefer you can use what you prefer okay so what do we need to insert here is the ip address and per default it is then connecting on port 6443 so make sure that the port is open only know there's it's open by default but if you deploy it somewhere else you need to make sure that this port is open uh so we need our master ip address which is this one i will paste it in here and we need token oh we have it here grab the token copy paste and then we hit enter and if we are lucky this will add a worker node to our kubernetes cluster this was quite fast this only took like five seconds now um now we need to wait a little bit and get notes let's see if there's a note joining and there you there we are so it's not ready yet but our worker node is already there so what we need to do next is because we want to export or not export we want to make our web application public we need something as a which is called an ingress controller and as i said before we will use ingress nginx for this so there's a project i will link this also down in the video description um it's like there's it's an open source project here and you can just look at the documentation of this one and how it works stuff like this and of course we can um deploy this so because i resize the page i can't find the deployment option anymore so it's here at the top and you have different deployment options you can go with docker for docker desktop for mini cube for aws for azure doesn't matter for everything it's listed here and typically i would install it through helm but because this is just a simple tutorial i will just when i go with a plain cube apply command this is also listed here so cube control apply and here's the yaml file you can take a look at the eml file if you want in advance before you execute it i will paste it in here on the master node hit enter and this will create all the necessary resources so some some services some role bindings cluster some cluster roles config map and of course the deployment itself this will take maybe a second or a minute to propagate and yeah while this is running i i want to show you something or how you could actually change the settings of your kubernetes cluster right now so with with the command in where we installed k3s you can run kprs and then you have some options you can uninstall the cluster you can you can make snapshots stuff like this but because it's actually a service which is running on your host or on your linux machine you can go to this path um you can go to this path and you will see that the command of starting your service with which options the service actually started is listed here so you can extend it afterwards you just or you just install it over the installation which you have done before so there are multiple options and if you change the configuration here you need to restart the service which is system control restart k3s so it's pretty easy to maintain here okay so let's check if oops ingress nginx is running so our namespace it's there so let's check if everything in the namespace is running yes it is so the ingress controller is running and it probably has a service and the service has two external ip addresses which is one is the master node and one is the worker node typically you will have a load balancer from some cloud provider here for example if you spawn a eks cluster in aws and you create a load balancer service then this will create a elastic load balancer in aws within public ip address but in the node it works a little bit different if you just use the nodes so not the kubernetes servers from the node so okay this is just the public ip it's the same ip we have here for our node so we can actually go ahead and now apply the many manifests um i can i can show it here what is actually inside so we will deploy uh one of the basic cloud version official images so this is on docker hub you can use it on your if you like you can use it um this will listen on port 3000 we need obviously a service in kubernetes which will route traffic to this deployment so the service is listening on port 80 and will forward traffic to port 3000 and then we need an ingress i have actually two ingress resources here one listens just on the path on the root path so if we paste in the ip address we should we should be brought to our our deployment but we can also use paths in our ingress resources but to use paths we actually need to have a dns entry we don't have a dns right now we just have a single plain ip address and to to make a dns entry out of it we can just add nipio or exipio or traffic io so there are multiple providers they are just redirecting the traffic or resolving the traffic back to the ip address but from the perspective of the ingress controller it's a dns entry so we will deploy both so i can show you that routing for root and routing for slash cloud versity will work so let's let's create the yaml file first just copy paste uh manifest yaml paste it in here bigger and then we just apply it this will create our container see it's already running okay so we should be able to go to this ip address and there we go so this worked we have uh our app deployed and it's publicly reachable this is just https but which is what is great is that we have because we used ingress nginx controller there's a default certificate for https traffic so for secure connection uh pre-installed but of course this certificate is not trusted because it's self-signed and the domain for which it was created is probably not this ip address so we will get a warning that's absolutely uh normal and we still have https connection but we can't use any we can't use any paths here because as i said it's just an ip address and we deployed the second ingress resource but we can do nip io behind it we should see nothing actually so not found because this one this guy is watching or listening for the path cloud versity let's check cloud versity also non-existent okay that's that's weird okay it's uh it's with dash okay cloud minus verse t and uh here we go so we can use paths as well there's probably some misconfiguration that's why we don't see the image but you get the point i guess if the content of this video was interesting for you then please consider to click on subscribe and like and all the buttons down there and you will be provided with a lot more tutorials in the upcoming future if there are any additional questions or some tutorials you want to have in the future just let me know post it in the comments down below and everything i mentioned in this video will also be in the video description with a link also to the git repository with all the commands see you soon
Info
Channel: CloudVersity
Views: 4,627
Rating: undefined out of 5
Keywords: devops, docker, kubernetes, k8s, ci, cd, cicd, dockerize, container, application, gitlab, deployment, production, microservice, monolith, kubectl, docker-swarm, openshift mesos, cri-o, crio, master, nodes, rancher, k3s, k3d, containerd
Id: 1hwGdey7iUU
Channel Id: undefined
Length: 21min 10sec (1270 seconds)
Published: Sun Jun 20 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.