[ Kube 106.1 ] Kubernetes Ingress setup and the ingressClassName field

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello viewers welcome to this video so this video is just an update to cube 59.2 so i did this video about a year ago using kubernetes ingress with metal lb i was just trying to follow that video i wanted to try something so i basically followed the steps in this video and found it wasn't actually working as expected what i'm planning to do is in this video i'm gonna follow the same steps i did in this video and i'm gonna show you where it's not working as expected and what you need to do to fix it so any of you who have previously watched this video and wondering why it's not working it's just a simple change it's the ingress class name that you need to add so previously in this video i haven't added the ingress class name so the ingress class name has to be nginx previously i don't know whether it's the kubernetes version that i used back during this video which was 1.22 i guess but recently i updated my vagrant provisioning script so now i'm using kubernetes version 1.24 i don't know if it's something to do with the kubernetes version 1.24 or the version of the kubernetes ingress controller that's requiring this change now but anyways let's let's go through this and see um what we need to do to fix it okay so i'm going to go back to my terminal i've already got my kubernetes cluster up and running i do cube ctl get note it's a three note cluster one control plane all running version 1.24 cube light so this is a cluster with kubernetes version 1.24 okay so the first thing is to deploy metal lb for nginx inverse controller we need a load balancing solution so i'm not using a cloud provider so i'm not running this kubernetes cluster in a public cloud um if it's the case then i could have actually used the load balancer uh from the cloud so i basically go with metal lb i've done a lot of videos on metal lb so i'm just going to do the same now let's go to the documentation for metal lb metal lb universe.tf let's go to the installation link on the left so there are a few ways you can install metal lb installation by manifest which is the simple which is what i'm going to use now so there is this cube cdl apply command the first one that creates just the namespace and the second one actually creates all the resources like cluster role binding role binding deployment daemon set and etc so that's why simply by deploying the manifest or you can use customize if you want or the more easier way would be to do with helm if you're already using helm to deploy all your kubernetes resources and then you can go with helmets just adding the helm repository and then installing the chart okay let's copy this one and run it here okay so cube cd i'll get namespace we have the metal lb system namespace created and now the actual resources okay you can say port security policy service account cluster role role binding cluster role binding demon set and deployments all created fine so there's a warning here saying policy v1 beta 1 api version is deprecated since 1.21 plus and it will be unavailable from 1.25 onwards nothing to worry about it it's up to them to update this yaml file manifests but anyway so we've deployed the resources now we need to add a config map so there's this configuration here again for metal lb there are a few configurations i'm going to go with the simple layer 2 configuration so that's the config map i'm going to copy that and open up a temporary file call it metal lb config map dot ammo and paste it here so the only change i'm going to make in this file is the ip address range so let me first show you what my ip address range is because i'm using my vagrant environment i'm using the network 172.16.16.0 24. so if i do cube ctl get notes dash oh white so you can see k master has got 172 16 1600 k worker 1 is 101 and 102. so basically it's a slash 24 network and so i'm gonna assign the last few ip addresses to metal lb so that it can hand over those ip addresses that i assigned to metal lb to the load balancer services okay so let me bring up the the configuration file again so here i'm going to give it a range of 172.16.16.240 to 172.16.16.250. it actually goes from 172.16.16.0 but i'm gonna assign the last few ip addresses to metal lb and i'm going to leave like last five addresses if in case i need to use it for something else okay so that's the config map cubesatio create minus f metal lb config map dot ml config map created get name space so if i look in metal lb system name space now metallic system get all so you can see so that is there are two components to metal lb one is the controller the other one is the speaker so speaker is deployed as the daemon set depending on the number of worker nodes you have you will have the speaker component deployed in each of your worker nodes and then there is this controller which is a deployment with one replica and all the parts are running fine all right cool so metal lb has been deployed so now let's go to ingress ingress control so now we got to deploy the ingress controller for that again i'm going to refer to the official documentation cuber that is ingress okay so installation guide nginx ingress controller i'll put a link in the video description to the to this installation guide okay so we have a few methods one is using the helm the other one is with cube cpl apply using the default manifests um okay so the easiest way here is just to use helm i already got helm installed help version i'm running version 3.7.0 if i do helm repo list i've just got the helms table repository okay so there's this command here which they claim it is item potent because you're running helm upgrade minus minus install so if it's not installed previously this will install the ingress controller but if it's installed already it will upgrade the existing installation if there's any update available okay so that's the um helm repository for ingress nginx and we are deploying this in the ingress nginx namespace and this option create namespaces to create the nginx namespace sorry the ingress nginx namespace if it doesn't exist before okay and here is the the ingress name sorry the the helm release name and that's the chart and the the chart name which is the ingress engine x so let's deploy that okay so that's deployed if i do helm list dash a for all the name spaces you can see the helm release ingress nginx was deployed in the ingress nginx namespace status is deployed it's all fine the chart version app version okay if i do cube cdl minus any ingress in genex get all just to see what has been deployed so there's one part there's the service ingress and genex controller and a deployment so the nginx ingress controller service now has got the load balancer ip address from the metal lb so if you remember for the metal lb configuration we we've given the ip address range from 1 7 to 16 16 240 to 250 so that's the first ip address in the range we've given to metal lb so metal lb has handed over the load balancer ip this external ip to this service because this service is a load balancer type service it has to get the load balancer ip if you haven't deployed metal lb before deploying the ingress engine x you will see the service the external ip will be in pending state because you need to have a load balancing solution so unless you have metal lb you won't you can't get the ingress controller to work you can uh with the note port and stuff but it's going to be a bit complex so for nginx ingress controller please install some form of load balancing solution metal lb is not the only load balancing solution but i feel comfortable using metal lb because i got used to it so that's all cool and i'm in my kubernetes repository if i do get remote so i've get cloned github.com just being open source cubenet is and in here i navigate to the yaml's directory and again from here i go into the ingress demo and these are the ingress demo files that i originally used for this video cube 59.2 which is what i'm going to do so even in that video i deployed metal lb first and then i deployed the nginx increase controller and then i used these yaml files these manifest deploy and nginx deployment create a service and then create the ingress resource and see how it actually works all right now i'm going to deploy this nginx deploy main which is just an nginx deployment i can actually show that nginx deploy main.normal it's just a simple deployment uh with the image nginx nothing special about it cube cdl create f nginx deploy main.cml so that's created if i do cube ctl get all so nginx pod is getting created so i'm also going to expose this deployment so cube ctl xposed deployment nginx deploy main on port 80 right so if i do cube ctl get all now so you have this nginx pod running so that's from the nginx deploy main deployment and we've also exposed this deployment as a service of type cluster ip so that's that service nginx deploy main all right so that has got the the cluster ip so you can't access this from outside your host outside the kubernetes cluster because this is a cluster iep service it's not a node port it's not a load balancer but we are going to access this service using the nginx ingress controller so we need to create an ingress resource to access the service okay so in this image demo directory i have this ingress resource one dot yaml let me show you what's in there okay it's a quick and simple ingress resource so when you deploy this ingress resource the ingress controller configuration will be updated so that any traffic coming to nginx.example.com will be redirected to the nginx deploy main service on port 80. so we already have the service we've deployed the nginx deployment we've also created a service which is exactly the service on port 80 okay cube cpl creates minus f ingress resource 1.0 so we've created the ingress we have the ingress controllers running so it should all work so this is all i did in my q 59.2 video and it worked fine if you want you can just go back and go through the steps that i did in that video but this is what exactly i did so hoping i should be able to access this service nginx deploy main by accessing the nginx.example.com domain but there is one additional step i need to do which is if i look at the ingress nginx namespace if you look at the ingress controller service the load balancer service so that's the external ip so that's the single iep for all your ingress resources so depending on how you configure your ingress depending on what a host name you give to your ingress but all those ingress resources will be pointing to this one ipad so that's the idea of using the ingress controller so imagine if you're not using ingress controller any form of nginx ingress controller traffic ingress controller or any form of fingers controller you will be exposing each and every service with load balance so then you have to let's say you've got like 10 services and you want to expose them outside of your kubernetes cluster then you have to have 10 load balancers right so you if you're in the cloud you'll have to pay for 10 load balances and load balances are expensive in the cloud so by using increased controller you are just using one load balancer and you're creating multiple ingress resources you're configuring the nginx controller which is just a reverse proxy so the nginx does the magic for you so you define all the services and the engine exchange controller is exposed in one ip address and depending on the the hostname that you give in your ingress resources you can doubt your traffic to multiple resources without having to deploy a lot of load balances if that makes sense okay so we have all these and so now i need to the ingress resource that we deployed cube ctl get ingress ingress resource one if i describe that cube cdl describe ingress ingress resource one so you can see the host is nginx.example.com we need to map engineex.example.com to 172.16.16.240. i'm going to do that in my local edc hosts file and when traffic hits engine extra example.com when you hit engine extra example.com it's going to forward the traffic to the nginx deploy main on port 80 and you can see already this the the ip address the endpoints if i do cube ctl get service nginx deploy main and if i describe that service you will see that's the end point 192.168.77131 colon 80 and that should be the ip address of the pod cube ctl get ports so white and that's exactly the ip address of the part okay that's how it all glues together okay so that's the host name and that's the service the traffic will be forwarded to all right so i'm going to add an entry to my edc host file so 172.16.16.240 which is the load balancer ip address assigned to the ingress controller service and i'm going to map that to nginx.example.com so from my machine from now on whenever i go to nginx.example.com it will take me to 172.16.16 okay if i do tail minus one it's been added to my atc host file so if i do call nginx.example.com now i should see the welcome to nginx page but i'm not seeing that i'm getting 404 not found again if i do the same thing from my web browser nginx.example.com i get a 404 so i did exactly the same thing in this video q59.2 and it worked but now it's not working so what has changed i've moved to ubuntu 22 hopefully that shouldn't have affected this i moved from kubernetes 1.22 in this video to cuba that is 1.24 now the metal lb version or the ingress controller version there's a lot of things but the one thing that we need to do is to add the ingress class name so that's what i found that uh we need to do okay so if i come in here this ingress resource 1.0 i'm going to destroy i'm going to delete the ingress that we deployed cube ctl get ingress so i'm going to edit this one and under spec i'm going to add ingress class name and set that to nginx so that's all we need that's it and now if i deploy inversus source cube ctl describe ingress ingress resource one you can see the ingress class is nginx and now we have the ingress resource deployed so now i should be able to do curl enginex.example.com and you can see welcome to nginx and again here if i just refresh the page i can see welcome to engine x that's that's all to it so essentially it's the same set of steps nothing has changed q59 point to the video that i did a year ago the only change that is required is adding the ingress class name okay so i haven't committed this change to my repository yet but soon i'm going to find all the ingress resources that i've used possibly in this yamas directory i don't know where else i've used this ingress resources but i'm going to find out where all i've used the ingress resources i'm going to add the ingress class name option to the to the manifest by the time you watch this video i would have already committed my changes so it should all be good for you guys okay i think that's it for this video i will see you all in my next video until then keep learning and keep on learning bye
Info
Channel: Just me and Opensource
Views: 9,723
Rating: undefined out of 5
Keywords: just me and opensource, kubernetes ingress, just me kubernetes ingress, how to use kubernetes ingress, kubernetes ingress controller for beginners, kubernetes nginx ingress deployment, kubernetes ingress load balancing, kubernetes ingress metallb, metallb bare metal kubernetes, kubernetes ingress resource, kubernetes ingress for beginners, kubernetes tutorial for beginners, just me metallb ingress, k8s ingress controller install, set up nginx ingress, ingress nginx
Id: VHJ6qM9EVbs
Channel Id: undefined
Length: 18min 24sec (1104 seconds)
Published: Mon Jul 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.