How to convert Kubernetes yaml to Helm Chart yaml

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 see how we can convert a kubernetes via mls into helm chart yml so basically we are trying to achieve over here is to convert a kubernetes deployment into a helm chart deployment here in this diagram you can see on the left hand side that is a kubernetes simple deployment and on the right hand side you can see the helm chart deployment so in this session we are going to see both the approaches first we will go with the kubernetes approach where we are going to create a kubernetes deployment yml and then we are going to create a kubernetes service yml to expose the deployment so that we can access our services in the second approach we are going to take the same application and we are going to convert this kubernetes deployment yml into a deployment yml that is a helm chart yml actually and there will be a service yml which will be a helm chart again service yml so the same application we are going to convert into the helm chart and we will see how we can deploy it using the helm chart throughout this session i'll be using this guide and i'll put the link of this guide into the description section so if you forget any command then please go back and check this guide i'll put all the commands which i'm going to use in this session all right so let's move ahead the objective one first of all what we need to do and as we have seen this diagram so we need to create a deployment.yml so first we are going to create a kubernetes deployment without using helm chart okay so this is our first objective i have mentioned over here and the yml which we are going to create is the kubernetes uh ka test deployment yml but before moving further on the left hand side you can see this is my kubernetes cluster which i have already set up so these are my nodes which i have already set up before working on this lab session so if you haven't set up your kubernetes cluster then you can go back to my channel and see this video using cube spray where i have shown you how you can set up your kubernetes cluster on your local machine okay so i am assuming that you have already set up your kubernetes cluster and you have your kubernetes cluster up and running on your local development machine or any cloud service moving further first create a k8s deployment.yml so this is the command for creating the yml so i'm creating a blank yml and here you can see i have created this kits deployment yml and here we are gonna insert the configuration for deploying our application inside our kubernetes cluster okay so open in a vi mode ah that is k it does and now i'm into the vi mode since this deployment dot yml is pretty much empty so we need to fill in some values over here so here you can see this is my very simple deployment.yml so this is very simple and here i have not done anything special apart from just using this docker image so this docker image is a very simple microservice which you can use you can exactly copy the name of this docker image if you are trying out this demo session then this is a public image which i have made it available on a docker hub so that that's the only thing which you need while creating this kubernetes deployment dot yml okay so you can copy this complete uh configuration from here and paste it over here and after that you need to save this and that's done so let us verify whether we have saved it correctly or not so here you can see this is my deployment the kind is deployment and the image which we are using is this one you can use this image as it is i don't have any problem with that and yeah so we are done with deployment.yml and we are going to use this yml to deploy our application or we can create a kubernetes deployment actually let's move further and deploy our first kubernetes deployment so the command which we are going to use is cube ctl apply f and the name of my yml so copy this command and paste it over here and it should deploy your application okay so here you can see the messages deployment demo created let's verify our deployment and for that the command is cube cto get sorry it should be get deployment demo and here you can see the demo is ready and it has been deployed 22 second ago so that means our deployment went successful okay so if you move back to the diagram which i have shown you earlier so we are taking this approach on the left hand side and we have created a successful deployment so user like us we have created k8 as deployment yml and after that we have created the deployment and that we have done it the next thing which we are going to do we are going to create a service so that we can expose this deployment as a service so that we can access that microservice okay so let us move ahead in the guide and the next thing which we are going to create we are going to create a k at s service dot yml okay so again the command is pretty much same which we did just like in the deployment so i'll clear the screen and paste it over here and i'll verify whether i have created so yeah i have created the service dot yml and after that i am going to open in the vi mode and since this file is empty we need to copy this configuration so i'll first copy this configuration and then i'll explain how it is i'll escape w and quit okay so now i have saved it i'll view the file again so that we can verify whether we have saved it correctly or not okay so now it has been saved so here if you will see okay i'll move it over here so it is more ah easy to read over here in my guide so this service dot wireless tells you like what kind of a service you are creating so first of all we need to tell like we need to create a service for our deployment that is demo okay so here you can see cube ctl get deployment so our deployment name is demo and we are going to create a service for our deployment that is demo and the name of the service is demo service okay so these are the two things which is necessary second we need to define the kind that is service which we have already did and the port on which port you want to access this service so we are going to use the port 8080 okay you can change it by your whatever convenient support which you feel so you can change it and the third thing which you need to mention is the load balancer either you can use cluster ip if you don't want to expose this service to the outside world or you want to keep it within the cluster then you need to use the cluster ip otherwise you can use the node port or load balancer since i want this service to be accessible to the outside world or the third party so that's why i kept it as a load balancer so that we can access it via browser this micro service okay let's apply this configuration and the command is pretty much same cube city will apply f and then k8 service yml so i'll copy this command i'll clear the screen over here and paste it over here so as you can see our service has been created okay let's verify our service which we have created recently so just copy this command so command is pretty simple cube ctl get service demo service because we have created the service with the name demo service okay so i copied and passed it over here so here you can see uh the name of the service is demo service type is load balancer the ip is this external ip is pending because we have just created the service so it might take around 40 or 50 seconds to get the external ip so we'll wait and we'll see what external ip which we get okay so here you can see we have got the external ip and i did nothing i just waited for some time and i rerun the command again so here this is my external ip which i got and it's running on the port 8080 so now we can access our microservice which we have deployed inside our kubernetes cluster so for that copy the ip address that is external ip address and column and the port that is 8080 and after that the microservice name so microservice is hello and as you can see this is the response which i have got from my application that is hello so this is how i deployed my simple micro service application inside my kubernetes cluster okay so if you move back to guide so this is the screenshot which i have shown over here how to access your microservice but remember this ip address will change for you because this is a dynamic ip address which i get ah whenever i deploy this service so this ip address might change but the port will be the same if you will use the same configuration just like which i did okay so this is our part one where i have deployed ah so here back to the diagram so this is the left part which i have shown shown to you so i have created a deployment and i have exposed the service okay and this service we can access it ah via browser okay the same thing which we are going to achieve via helm chart so that is the second part of this session okay but before moving further so first of all let's delete everything so group ctl delete service demo service okay so now i have deleted the service which i have created it might take some time and it should be deleted i'll be back when it's done and the service has been deleted and now i can see that my service is not accessible via browser and one more thing we need to delete the deployment also cube ctl delete deployment demo and our deployment has also been deleted so now we can see cube ctl cat deployment and it should not be it should be empty because we have not we we are not running any deployment right now all right so now what we have done we have achieved our objective one as well as objective number two and the third thing is now we need to create our uh towards our objective three is we need to create the helm chart and we have deleted all the previous deployments our cluster is pretty much clean over here and the thing which we need to do is we need to create our helm chart and for the helm chart if you you are a beginner and if you want to install the helm chart then please follow this kind i'll put the link of this guide also into the description section or you can follow this part 2 on my youtube channel so where i have shown how you can install your helm chart and run your hello world application with your hum chart ok so moving back to the diagram so here first of all we need to create our helm chart application okay and the command for that is ah remember i have already installed the help chart so i am not going to show the installation of a helm chart so i am assuming that you have already installed your helm chart and then you are proceeding further okay so the thing which we need to do if you see in this diagram so we need to create our helm chart so once you run this command helm create spring boot i have mentioned it over here is a springboard but you can keep any name of your choice so the command here you will see okay so let's create one helm create demo chart okay so this is the command which we are gonna use you need to just hit enter and it says creating hello hello uh sorry creating demo chart and here you can see this is the folder which is which it has created that is demo chart okay so after creating the demo chart helm chart now we need to compare the service dot yml as well as deployment.yml and if you are working with the han chart then you need you don't need to create a deployment.yml so if you will see this red arrow over here so this deployment.yml is already created once you run this command hello create spring boot okay so here you can see i'll just use the command tree and the demo chart so it will show you all the file in a tree fashion so once you hit enter so you will see this is our parent directory that is our demo chart and inside that you will find service dot yml this is the service dot yml and the deployment.yml so basically this is very simple application that's why we only need deployment.yml and service.yml okay so these are the two ymls which we need and that is already been created by helm chart but it will not work we need to update some of the values inside the deployment.yml as well as service yml okay so let's move further in the guide that is our third objective so this is the table i have created so like once you are going with the kubernetes deployment then you you need to create this sorry k8sdeployment.yml and ktservice.yml so this replacement for that in the helm chart is service.yml and deployment.yml and apart from these two files you need to update the values.yml also so if you see over here so this is the values.yml which is like created by our helm chart in the guide you can see we have already run this command and we have already seen this tree structure of our help chart and that this is the similar structure you will get once you run this command and the next thing which we need to do we need to update some of the values so first of all we are going to update the chart.yml so clear the screen go to your demo chart and then vi and then go with the chart.yml okay so here this is not a mandatory step but it will be good to update some of the values so i am going to update over here the description convert k at us to hell and after that you can just save and quit okay so that's our first chart.yml which i have updated the second yml which i am about to update is the deployment.yml so what you need to do is uh you need to first of all see over here there should be a templates folder so first of all you need to go inside the templates folder and then you will see the deployment.yml okay so now we need to update this deployment.yml uh you need to be little careful over here we need to update certain values over here okay so first of all we are going to update the container port to 8080 okay so just go down over here and i will be into the insert mode and we need to update the port to 8080 okay and after that you need to delete this liveliness prob also because we don't need right now because we are not deploying it in production but it is just for our demo purpose so we don't need it right now so i am going to delete these lines also and this readiness prob also if you can see over here so we need to delete this also okay done after that there is one more thing which you need to update and that is this image so what we need to do is this is the image name which we need to keep so i need to delete the values from here actually what it will do is we are going to use our docker image i'll show that docker image name if i don't remove this path this postfix then it is going to append a version number behind it and that will force us to uh download some in unavailable image actually so that is incorrect okay all right so now i have updated i'll explain that part just after some few moment and after that i will quit and save it okay so the part i was trying to convey you is this one so this is my docker image rahul var kubernetes j hook springboard so in case if i don't delete that part which i just deleted in the deployment.yml what will happen is it will just go and at the time of deployment it is going to update something this version yeah but my image name only exists with this name not with any version so it will try to look for this version name also and that it will not find on a docker hub and it will fail okay so that is the theory behind it ok i will clear the screen over here ok so coming back to our guide so this is the deployment.yml so we have updated the port we have updated the image name so either if you feel difficult then just copy this whole line and paste it over here so that your image name is correct over there okay the third thing which we need to do is we need to [Music] we need to check the service dot yml also but remember we don't need to update anything service dot yml you can keep as it is you don't need to change anything just check where it is so here is the service dot yml and if you do the cat command then it should be like this yeah so you don't need to update anything over here just keep the way it is moving further there is a values.yml so this values.yml you will find one directory up so go one directory up do ls okay and here is your values.yml and now we need to update this so what you need to do is vi values.yml okay so here we need to update two thing first of all port as well as uh the repository okay and yeah so first let us go inside this i am going to edit mode and here first of all change the port here to 8080 and one more thing we need to change from cluster ip to load balancer because we are going to access it via browser the way we did it previously so i'm gonna use load balancer over here you can use node port also that's absolutely okay and then we need to update the image name so you can find this image name over here so here i am going to highlight this so this repository here i need to delete the nginx and you can copy this value over here from here and just paste it over here okay so we have updated three values actually so one is the image name ah then the service type that is load balancer and the port that is 8080 okay so after updating this value what you need to do is you need to save and quit all right so next command is we need to verify whether our chart is correct or not so there are certain commands i'll clear this so the command is helm template first of all i think i need to get outside of this directory yep so i'm outside my demo chart directory okay so that remember and the next command i'm going to run is helm template and the name of my chart so that is demo chart okay and here you will see it will generate the complete yml so just like we have seen in the kubernetes deployment it has created the service service account a service account is new because it is created by hand chat but we have seen the service and the deployment okay so the thing which you need to verify over here is the port and the image name so here you can see the image name is this there is no prefix with the version number so that is okay your port is 8080 and yeah we are good to go so our this uh command will let you visualize how your yml's looks like after the helm has processed those volumes there is one more command that is lent that will tell any error if there is any by mistakes and tactical error which you have done so what you can do is you can run this command over here and here you can see one chart linted zero chart failed that means our chart went successfully our home chart has been created or processed successfully actually all right now it's time to run our application or run our hand chart so the command for that is i'm gonna update this command because you cannot use upper case over here so i'll update this guide once i publish this video okay so the command which i am going to run over here is hello sorry helm uh install and after that you need to specify some name so i am using kts to help remember it has to be in lower case okay and then the actual chart name which i have created that is ah demo chart ok so now our helm chart installation command has been done and now we need to verify our deployment service as well as the helm status so one command for that is to verify everything is scoop ctl get all and here you will see ah our this external ip is still pending so we have just deployed that is 31 second ago so it's still generating our external ip but meanwhile we need to verify our deployment so this is our deployment section so our deployment went successfully and this is our replica side that is also working fine and this is our services sorry i just decreased this screen size ok and here you can see the services that is demo chart so that is also working fine although the ip address is pending and this is our part that is also healthy and running okay so i'll rerun the command coop city will get all again so that we can see if i got the ip yeah i have got the external ip it is getting clumsy i'll clear the screen and i'll rerun the command again okay so here i have got the ip address okay so that means our deployment is went ok our service has been created and now i got the external ip also so the next thing what you need to do you need to copy this external ip go to your browser so this was our previous endpoint says just delete everything paste the ip and the port should be 8080 and followed by hello and here you can see we have deployed the same application using the helm chart okay so after you have deployed this you can delete everything and but before deleting there are certain command which i need to tell you helm list a it will show you all the deployment i'll reduce the found maybe a little bit more okay i think it's better now so there is a command helm list a and here you can see this is the helm chart installation which we did okay so now you have verified everything and you want to delete everything and you need to clear your cluster then the command is helm delete and the release name okay so that you can do and it has uninstalled so that means uh everything which we did ah has been removed from our kubernetes cluster okay so that comes to the end of this lab session and i hope you liked today's session on how to convert our kubernetes deployment uh into a helm chart installation and this is the approach which you can take and which i would suggest you to take if you are trying to convert any of your kubernetes deployment into a helm chart so this is the simplest way ah which you can do and one more thing which you need remember this is a very basic application which we have seen today so that only requires change in the deployment as well as in the service but in case if you are having some more complex application then you might need to update increase service account with role based access so all these kind of things when you need to update inside this in grace or service account yml also so i hope you liked today's session so if you like then please go and subscribe and put like i that i really appreciate and for similar content please follow my channel where i keep on uploading similar content on devops and the kubernetes and docker and helm chart and also you can find me on the web that is jhoop.com where you will find all these guides available so you can come back and check so you don't need to remember anything so see you into the next session and till then goodbye and have a nice day
Info
Channel: Rahul Wagh
Views: 5,605
Rating: 5 out of 5
Keywords: helm chart, convert kubernetes to helm chart, kubernetes, convert kubernetes yaml to helm chart yaml
Id: ZZVXXEyEzAs
Channel Id: undefined
Length: 25min 12sec (1512 seconds)
Published: Wed Jan 13 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.