Kubernetes Deployments with Flux v2: Helm Basics

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone and welcome to this next installment in the series about supercharging your kubernetes deployments with flux v2 and github and in this part part 5 already we'll look at helm deployments now how exactly did we end up here well in the first installment we looked at installing the cli and bootstrapping cluster then we took a small detour and looked at how customize works because flux v2 is using customize quite heavily in the third video we looked at creating git sources and deploying our yaml manifests with customizations but we kind of skipped the helm charts deployments and then in the fourth part we looked at monitoring and alerting now of course we cannot go without looking at the helm chart deployments as well and that's what we'll do in this video what do we have or what are we going to create well we're going to bootstrap our cluster from a new repository i'm just going to call it the helm infra repo i'm gonna work against a kind cluster so a local kubernetes cluster on my machine as you know from previous videos when you do a bootstrap you select a folder to contain all the components that you'd like to use that folder will contain the flux system folder and of course to the folder that you choose in our case that's an app cluster folder you can add custom resources now in this installment we're going to take a look at creating sources but instead of get sources we're going to create helm sources and we also look at creating helm releases to deploy helm charts to our cluster now the sources we're going to use are the following ones we're going to point to the bitnami helm repository because we want to install redis using a helm chart next we're going to point to one of my own repositories yeah it's called hepa rash from here back registry right and it contains the real time chart for the app that i want to deploy my own app so to speak be aware that the sources you're going to create with flux do only point at the repositories they don't include information about the chart but i noted the chart there in the diagram so that you know why we point at those repositories how we refer to the chart you'll see when we create the helm releases of course we still have the app we are deploying and that is the sample real-time app written in go with a github action that builds and pushes container images when the real-time app sources change now let's check first how we can deploy these helm charts without flux v2 to install the redis chart on my cluster i of course need to have a helm installed on my local machine and cube cuddle has to point to the cluster i want to work with and in this case that's kind it's running already on my machine here i first have to add the helm repository that contains a radish chart and bitnami is a well well known one so i'm just gonna add this one here great the helm repo has been added now we will install the redis chart we do that with the following command we can use helm install redis and i'm going to set a couple of parameters i'm overriding some of the values in the chart for example i don't want to have a full redis cluster and i also don't want to use a password in this case this is just for my example app which doesn't need anything more than that let's do so and let's install the help chart and it's done already although it is not waiting to see if it's done i didn't use dash dash weight there so normally what you would also be able to do is to add dash dash weight here and it will also check if indeed the installation is done properly as well you will wait for the installation to finish didn't do that here let's take a look at what went on here so k get thoughts what do we see we see a redis master zero and we see that one running and if we get the services we see a redis master service and another radius headless service but the radius master service is the one that my app will need to use to connect to radis as its back end with the redis back end deployed i can now deploy my helm chart for the real-time app of course you have to have a helm chart for that at first you have to create that one i'm in a folder now the projects helm realtime app folder that contains the chart that i need to use of course i created this chart myself in this video we're not going to look at the details of how you create a helm chart maybe i'll make another video about that just for fun but in this case just know that this chart will deploy my real-time app production image let's take a look maybe in values.yaml because that one of course contains a couple of my let's say the default settings i want to use so as you can see there the value cml contains replica count of three for production uh i have a variable as well or a parameter called redis host which contains the redis master service name and then the port for redis to use and as you can see here i'm going to deploy to the default namespace so i don't add a namespace behind reddish master so there's no namespace here right just for this example then the image i'm going to use is the heybackerfluxrt image which my git of action is always creating and i'm going to choose here to deploy the image with tag 1.0.2 so if i just deploy this help chart like this with the current values as they are i would just do that with the helm install and then uh real-time app because that's the name i want to give this helm release i'm going to use weight in this case just to wait until everything is deployed and what what is the help chart i want to actually install the one in the current folder right so the dot for the current folder let's see if this works and let's do the installation we have to give it some time because in this case of course he's also waiting for the resources to be created the helm command finished let's clear this and let's do a k get pots and as you can see there we have three instances of the real time app running and we also have our radius master running over there when you run helm ls now on your local machine you will see that the two helm chart have been deployed you can also clearly see the version of the chart so the chart version is over here in this case you can see redis chart version is 12. the chart version of real-time app is 1.0.2 now in this case that corresponds with the app version that's the the version of my application the tag i'm using for my for my image here doesn't of course have to be the case and so the the version of the chart can of course diverge from the version of the app now i don't want to have these installed locally of course or manually i want to install them with flux v2 so we're going to just uninstall uh these these charts and we'll do that by using the release name so i'm going to uninstall a real time app and i'm also going to uninstall the redis deployment or the redis helm chart so if we do helm ls again they should be gone if we do k get pots they are gone as well great now you're ready to bootstrap our cluster and as i said i'm going to use a repository called helm infra for that that doesn't exist yet so it will be created on github for that okay so the cluster is bootstrapped and i already get cloned the helm infra repository to my local machine as you can see in my where i am right now the path i'm in right now and i also see deed into the app cluster folder and now we can create the source for the helm repository but instead of using flux create source git in this case we're using flux create source helm we give it a name we call it bitnami we give it the url to the chart repository which is this one here for bitnami the interval of one minute and we export this to a yaml file when we cut out the helm repo with namiyamo you see something like this so it's a resource of kind helm repository and of course the settings reflect what i use on the flux command line i synced up the changes to the repository over at github and gave it some time to come into effect and when you run flux get sources helm you will see that indeed flux was able to pull that that source source is called bitnami and fetched the following revision with the source created we can now create the helm release so we use flux create helm release we call the release redis because we are going to deploy redis and of course we need to reference the source where can we find this help chart well that's of course in the bitnami helm repository that we just defined the chart in that repository is called redis and the release that i want to deploy so the name i want to give it on my cluster i want to use the name redis as well and of course the helm chart uh it will be deployed or you need to deploy the component somewhere in this case in this example in the video i'm just going to deploy it to the default namespace let's take a look what's inside the yaml file and that's in the a resort of kind helm release now i do want to modify this helm release a bit because as you have seen previously we want to deploy redis and not use a cluster and we also want to disable the use of a password we can do this with values you see the values here to override the values in the chart basically and here is where we set the parameters i pushed the changes i made to the helm release up to the dit repo on github and when you give it some time and you run flux get helm releases you see that flux now has a helm release in this case luckily in a ready state so ready is true and the release reconciliation succeeded that also means that flux was able to find the chart as well in the repo and was able to deploy this chart on your cluster let's take a look if that really worked so let's do k get bots and there we see indeed we have redis master now running be aware that if you now run something like helm uh ls on your local system you're not gonna find anything because everything is done of course by flux within your cluster okay now it gets kind of more interesting because we have to package up our real time app chart and push this to our own registry in order to do so we first set the following environment variable helm experimental oci equals 1. that is required because now we're going to use helm chart commands to save our help chart locally under different names for example you can do helm chart save and of course a dot for the current chart and then save it as a real-time app a colon and then a semver for instance semantic versioning tag be aware that this saves the chart locally okay that's done but of course i would like to push my chart to a remote registry just like with docker images you would then also tag or save the image with a proper name in this case i'm going to save my chart as hebarec.azurecr dot io slash realtime app and then colon the semantic versioning tag so very similar to how you would save a docker image locally on your system so i'm doing that now and that saves the chart now it's time to log in to the remote registry so i can use the following command for that which is helm registry login and then the name of the remote registry now i'm not going to do that because i am logged in already what i am going to do is i am going to push the chart to the remote repository i'm going to use the following command to achieve this let's try that and see if that works great that worked he said he pushed it to remote one layer yeah what you'll actually pushing there is going to be an archive i have an archive here in this folder will be it will be similarly named in my remote repository let's check out that repository here we are in the azure container registry which i can also use to store helm charts the helm chart appears in the list of repositories next to other repositories which i'm using for example for containers if i click on real-time app you'll indeed see the tag that we just pushed 1.0.2 and you can also see that in the config the media type refers to helm over here and the layer actually contains an archive as i discussed earlier now we just have to tell flux v2 how to get to it our azure container registry is protected by user names and passwords it's not something which is publicly available so we'll need to tell flux later how to authenticate to it one way of doing that is just creating a secret on your kubernetes cluster in the plug system namespace i create a secret here which is called acr and then using the from literal option i'm setting username equals to the name of my registry the short name just and then the password is the one that your azure container registry is listing now where do we get that password the password can be found on your container registry if you go to settings access keys and you turn on the admin user now note this is one way of giving access to azure container registry there are other preferred ways as well but in this case this quickly is something that works everywhere so you enable the admin user the username as we've seen in our secret will be the short name of our registry and then you can use either of these two passwords now that we have the secret with our username and password to the repository we can create a second helm source in this case this helm source refers to my azure container registry but do note that you have to add slash helm slash v1 repo over there the interval set to one minute and of course you can see that we refer to the secret that we called acr that contains the username and password to authenticate to our azure container registry let's just create this now that the source is created i'm going to create the helm release for real time app very similar to the earlier helm release but of course now we refer to the other registry the one we created over here the real time app one the chart is called real time app you've seen that with the helm chart push command the release name is real time app the target namespace is the same as where we deployed redis which is default in this case i'm just gonna run this command and this saves the file to my local git repo i also opened the file i just created with nano and i added a couple of overwrites for the values of the yml chart for example here i just set redis host as the name of the redis service dot namespace and then the redisport that's just an example i don't want three but i want two bots to be deployed and just to be sure i set the service to type cluster ip i pushed all the changes to the github repo and after a while i can see that indeed there's a new helm release for real-time app and luckily again the state is ready ready equals true and the release reconciliation succeeded that must mean that our application the real-time app was deployed let's check this out let's clear this and let's do a get bots and what we see is that we have two replicas because i override the values yaml basically and set the replicas to two the default was three if you remember from the beginning and they're both running so that must mean that they're connected correctly to the redis master zero we can still make an improvement to the real-time app helm release because real-time app depends on redis to be available for it to start correctly we can add a depends on line to the yaml file and in this case you see that we depend on another helm release which is called redis this concludes our look at flux v2 and helm we created two helm sources that point to helm repositories an open one bitnami and our own one which is based on azure container registry and then from both helm repositories we installed a chart using the concept of helm releases in flux v2 so we deployed the redis chart and now we deployed our real time app and remember we actually created our own chart for that and we packaged up the chart and saved it into azure container registry before we created the helm release i hope you enjoyed this and see you in another video soon take care
Info
Channel: Geert Baeke
Views: 2,838
Rating: 5 out of 5
Keywords:
Id: UhV8kYcb9Mc
Channel Id: undefined
Length: 20min 38sec (1238 seconds)
Published: Sun Nov 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.