Helm Chart Demo - How to create your first Helm Chart? - Part 6

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome to j hook and in today's session we are going to create our first helm chart inside our kubernetes cluster if you are starting with the helm chart and this is your first session then i would highly recommend to go back and check my previous session where i have shown and explained what is the helm chart what is chart.yml what is template and what values.yml is for help chart so that session is a really good starting point for you if you are getting started with the help chart and in this session we are going to start from the scratch and we are going to create our first demo chart application and that we are going to deploy or install inside our kubernetes cluster okay let us move ahead on the right hand side you can see a guide which i will put into the description section so you can follow the same guide which i am going to follow during this session so as a first step we need to install the helm chart and that's what we are going to do but since i have already installed the helm chart on my local development machine so you we can skip this step number one but if you haven't done then you need to choose for an option there are so many uh apt or not app but package manager available which you can use or either you can go for the binary or if you still interested in the script section then you can check this scripts also so you need to run this script and you can get your helm installation done on your local development machine before we move to the second step i am assuming you have installed the helm chart and you have your local kubernetes cluster up and running so the first thing which we are going to do is we are going to verify whether our kubernetes cluster is running or not so for that we can run the command coupe ctl get all i'll copy this command and i'll paste it over here so as you can see our kubernetes cluster is running and i have previously deployed some of the applications so you can see over here so i have deployed one in springboot application so that is up and running so that means my kubernetes cluster is properly running and now we can proceed with the next step one more thing ah during this our lab session i am going to use the spring boot application i have already compiled a docker image for my spring boot application and i have already uploaded it to the docker hub so you can use your any of your application just creates the docker image and upload it to docker hub and if you don't know how to do that then i'll put the description of that tutorial or the link of this guide where i have shown how to upload it to the docker hub and that you can use for your reference okay now we have verified our kubernetes cluster is up and running the next thing we need to do is we need to create our chart our first helm chart and the chart name we are going to give is springboard so you need to copy this command go to terminal i'll clear the screen here and i'll paste it so as you can see creating spring wood that means our spring boot chart has been created you can verify with the command ls so here you can see the spring boot so our spring boot helm chart has been created okay let us move ahead and check how our helm chart structure look like so you can use the command tree and specify the chart name that is spring boot and hit enter if you don't have if you don't have the tree command then you need to install this tree command but yeah after the installation of the tree command you can just simply run the tree followed by the chart name and you can see over here so these are the basic file or basic ymls which is provided by a helm chart and it is created once you create the helm chart so once we have run this command we got all this file by default so one of the advantage of the helm chart is is helm chart creates all the boilerplate code for us so we don't need to create everything manually so we can pretty much use all this template and replace the values inside those template and that we can leverage to reuse again and again okay let's go through some of the file and the first file which we are going through is the chart.yml so head over to your terminal uh go to spring boot which is our helm chart ls over here and as you can see there is a chart.yml so you can just view this chart.yml so on the right hand side you can see in the guide i have uh shorten my chart.yml because once you run the create helm chart it will give you lots of details regarding your chart.yml so i have just removed all of these comments and i have just kept the necessary configuration which is needed for us and in the guide you will see a comment that is mandatory so these are the fields which is mandatory and which we need to supply it while creating the elm chart so api version name and the version so these are the three mandatory fields which we need for creating any help chart and one more thing here we need to look for is the version you cannot specify any version in any syntax you need to follow the ah sm version 2 because that's the semantic version 2.2 that we call it as a sem bar 2. and in this case you need to follow this pattern 0.1.0 and you can change the number based on your need but it has to be in this format so that's the one point which you need to keep in mind while working with the helm chart okay so that's our helm chart and since we don't need to edit anything into the helmchart.chat.yml so we can just quit this mode okay the next file which we are going to see is the values.yml helm chart already created this values.wireml for us but we need to update some of the values so here just open this vi values.yml and here you can see there are lots of values which is already pre-filled and i'll keep those as it is the only thing which we need to change is the repository here and on the right hand side you can see in the guide i have mentioned the command update the url or updated url so we need to change this repository url because we are going to fetch our application or the docker image from the docker hub so we need to provide that url so that help chart can access the docker image and deploy it inside the kubernetes cluster so i would say copy this url and this is the part where you can upload your own image or own docker image which you have created for your own application so i'll copy this url here i'll go head over to terminal i'll go into the edit mode and i'll remove this nginx repository which is default by default provided by a helm chart okay so i have pasted my url i'll save and quit and rest of the thing you can keep it as it is inside the values.ml because since this is our very first tutorial or the session with the helm chart so we can keep other thing as it is there is a one more thing which i forget to tell you we need to update the port because uh in the docker on the docker image i have configured to run it on the port number 8080 so that we need to modify it again so i'll head back again to the values.yml go into the edit mode and i'll look for that particular port number here so this is the port so by default it's running on 80 so i need 8080 port so i'll update it and i'll quit it okay so now i have updated my values.yml i have seen the chart.yml the next file which we are going to see is the deployment.yml in the deployment.yml we need to update the two values not the two values but at least one value that is the container port that should be 8080 and we need to update the image repository name here also i'll show you how it it needs to be done so first of all open it a vi mode and go to deployment.yml and here first of all we'll update the port and change it to 8080 and then here you can see the by default the image name is quite long over here so if you look into the docker hub so my repository contains only this image name so i don't need the version number which is added by helm chart so i will pretty much delete this value because i don't need it otherwise it will cause me an invalid image name error so what i need to do is i need to go into the edit mode and delete all these values because i don't need it yeah so our repository url should be something like i showed you here something like this so helm chart will not add any version number after the image name so that we wanted to avoid otherwise it will cause invalid image name issue for us okay so now we have updated the deployment.yml let us move further i'll escape and save the file sorry there is one more thing which we need to comment out over here is this liveliness probe and readiness prop inside our deployment.yml so that i forget to mention so we will comment out this this is something other topic which tests the liveliness of any application which you deploy but for the time being we are going to comment out this section uh so again go to deployment.yml and here we need to comment this lines so go into the edit mode press hash and we need don't need this right now yeah let's just save it moving further there is one more yml that is service.yml but in that we don't need to update anything so you can keep that service dot yml as it is and just to give you a little bit more information that will be a service ah which we are going to create after the deployment so how it works is kubernetes deployment and then we create a service to expose that deployment as a service so for that purpose we use this service dot yml all right moving to the step number four uh helm provides us a very good commands uh there is a one command that is called template and that template command can be used to view our actual wireless how would how it would look like so uh if i go back so here you can see a lot of placeholder so after looking at the yml you don't know what would be their actual values so helm provides a very good command that is template and i do really like it so that you can just see what will be the actual value when we are going to run this helm install command so what you need to do is you need to run the command helm ah just one more thing you need to be outside of this directory if you run the helm template springboard so just go one side up or one directory up and then you need to run helm template spring boot sorry there is a spelling mistake which i did ah here you can see so this will generate you all the yml with their actual value so this is the service account dot yml with their all values which is filled and here you can see the deployment.yml which we have modified previously but here you can see all the details so here for your reference this is our docker image url this is our container port and this is our test connection also over here yeah so the helm template command is a very good command if you are not sure what would be the actual values once you run the helm install command so you can use this command whenever you feel like i need to check their actual values so this command comes very handy okay so here is the code for templates which i have seen over here so i pasted over here for your reference so you can just follow along okay so moving forward uh there is a one more command lint helm lint so it's like if there is any problem with your uh helm chart then it will highlight you so what you need to do is again uh you need to be uh one directory up or outside of the helm chart directory and you need to run the command helm lint and then the spring boot the chart name and as you can see one chart yeah we have created one chart one chart entered that it shows and g zero chart failed so that means ah there is no failure or there is no issue with our chart so we can pretty much run this chart very easily so if there is any issue some tactical mistake or if you have provided any incorrect value then it gonna show you over here so that comes it's kind of a compilation ah if you assume it in the programming world so you are just trying to compile your health chart with the lint command moving ahead there is one more command debug driven which comes pretty handy to verify your helm chart before running the helm install command and in this command which you can pretty much verify all the errors and if is there any configuration mistakes which you have done so this command can be used for that purpose and to run this command what you need to do is help install and after that you need to specify a release name because everything we do in the helm chart we need to do as a release and that the name we need to provide so always remember this is not a helm chart name this is a release name then followed by debug and then that is followed by dry run and after that you need to specify the chart name so that is our spring boot helm chart okay let's copy this command and head over to terminal and paste it over here so as you can see there is no error and there is a notes which is provided by a helm chart ah this is basically a commands which you can use but anyway i'll go through the uh console output uh this is the yml the final yml just like we have run the template command so it will generate the all the yml with their actual values and if there is any error then it will highlight you otherwise it will simply uh generate the deployment.yml it will generate service.yml service account.yml with their actual values and that will show this notes message at the bottom so that means our health chart is correct and we can pretty much run the helm install command moving ahead to the step number six we need to install the helm chart and to command for that is helm install followed by the release name so that is spring boot or my spring boot and then the chart name so the chart name is spring boot so always remember helm install followed by the release name so this is my release name and this is my chart name okay once you return this command hit enter and as you can see the namespace is default so it has been deployed in the default name space the status is deployed revision is one because this is the first release which we are going to do so that's why the revision number is one and these are the nodes so pretty much you can use this command to generate the access url but anyway we are going to look next into the step number seven okay moving to the step number seven we need to verify the helm installation which we did and for that you can run the command helm list a a for all and here you can see i'll create i'll increase the screen and here you can see the name of the release is my spring boot space namespace is default revision is one because this is the first time we are we have deployed this application so the revision is one and the chart name is spring boot status is deployed so yeah we have successfully installed our first helm chart there are a few more command which you can use to verify your deployment and for that you can use the coop petal command also and the command which we are going to use is google get all it will tell whether your spring boot deployment has went successfully or not and i'll increase the size here and here you can see in the deployment section you have deployed my spring boot that's the release name we kept it and it's one slash one that means it's ready and it's available so that means our deployment has been successful and our application is running inside kubernetes cluster okay so now you have seen how to create your first hand chart and how to deploy your application using the home chart the next command which we are going to talk about is the upgrade helm release so if you have already deployed one of your application using helm chart inside kubernetes cluster then if you want to make some modification to it then in the helm world what we do we do the upgrade so that we make changes to the existing deployment and for that the command which we are going to use is upgrade helm release to use this command what we need to do is first we need to update the version number so previously if you remember we have kept the version 0.1.0 so now we first we need to go to chart.yml and update the version so i'll go and edit the chart.yml and here you can see the version number it's 0.1.0 so i need to have this or you can put any version number if you want but you need to follow the semantic versioning here you can see yeah so i have updated my chart.yml now next thing i'm going to modify is values.yml so as a next change what i wanted to have is i want to increase the replica account so i'll go to values.yml and here you can see previously the default replica count was 1 and i am updating it to 2. i'll save the change and it's done so before we use this command just check your existing deployment in the kubernetes environment here you can see the replica count is one so it's only one replica which is running right now okay so now we are ready with our changes and now we need to use our helm upgrade command so how you gonna do this is helm upgrade copy this command and then you need to specify the release name which is this one or you can copy it from here also and the chart name okay so here you can see the message release my spring boot has been upgraded happy helmet so that means our release has been upgraded and that we can check using the group ctl command and here you can see the replica count is 2 so this is what makes us easy for us to do the release and upgrade the release so the hair helps comes pretty handy with you when you are doing this kind of a changes the next question comes in my mind if you are upgrading the release then what about downgrading or is there an any way by which i can go back and go back to previous version so yes uh helm provide there is one more way by which you can just roll back your religious so the command for that is helm roll back and then you need to specify the version number okay so first of all i'll clear the screen here and just list down all the releases which we have done i'll increase the screen size here and here you can see the release name is my spring boot and the revision number is 2. so since we have done the upgrade that's why the revision number 2 is coming over here if we haven't done the upgrade then revision number would have been 1 okay so now we know there has been 2 releases which has happened and now i switch back or i roll back to switch religion number one to roll back what you need to do is help roll back release name my spring boot and the version number that is one that's it and now you can check the roll back has it happened or not so hal list a and as you can see now the revision is 3 that means rollback has happened but in the helm world you will always get a revision number incremented by 1. whether you have roll back or you have upgraded so it is it is counted as a revision so that is why we are seeing the revision number three over here and as you know we have increased the replica count in the second release when we have upgraded it so the replica account initially we have upgraded to but since we have rolled back that revision so it should have a replica count of one so let's check that group ctl get all and here you can see now after the rollback we went back to our initial replica account that is one slash one so now we are having only one replica which is running inside our kubernetes cluster so that's how easy it is to manage the releases uh using helm inside your kubernetes cluster so the next thing which we are going to see after the roll back is how to delete the helm releases since we have done the installation of the release we have done the upgrade we have done the rollback the next thing how to clean up all this thing so first of all i'll clear the screen here sorry i'll clear the screen now and the first thing which you need to do is first of all you need to list down all your releases so this is the command and here you can see i'll increase this screen size and this is the release name which we have right now but in your case it might be multiple releases but since we have created this release i want to delete it so what you need to do is help delete and your release name and you can soon see here release my spring boot uninstall okay so now it has installed the release with the name my spring boot i'll clear the screen let's list down again and here you can see now there is nothing running inside our kubernetes cluster or there is no way you can see any of our release which is running inside the kubernetes cluster i hope you enjoyed today's session on getting started with the helm chart and the lab session if you face any issues or error please put down into the comment section i'll try to reply you back and if you want something similar lab session then also please do let me know into the comment section below and i also put this guide into the description section of this video so you can follow along whenever you feel comfortable so all the commands and all the steps which i have already mentioned in the guide so it will be pretty handy when you are practicing out the helm or helm chart installation thank you and have a nice day bye
Info
Channel: Rahul Wagh
Views: 10,204
Rating: 5 out of 5
Keywords: helm chart, helm chart demo, creating helm chart, helm chart tutorial, getting started with helm chart
Id: 2dqQcou_MCU
Channel Id: undefined
Length: 24min 56sec (1496 seconds)
Published: Wed Jul 22 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.