Hi, Let's understand about sub charts. Charts is a separate entity where
It will be having collection of templates and values
It can be packaged together, shared it within a repository as well as send it as a package to the
external world and within charts. I can have n number of sub charts.
Again, the subcharts will be having a collection of templates and values and the same hierarchy
How we have within the charts.
Let's understand through a demo.
Let me get into the sample chart that we have, within that we do have charts folder.
I'm going to get into the charts folder, within charts folder
I'm going to create a subchart.
The name of the subchart I'll give it is mysubchart and I will use helm create command, helm create
mysubchart. So within charts it's going to create a folder.
mysubchart and like this I can have
n number of charts within it and within the folder
By default it is going to create a project
And within that it's going to create the collection of required folders
And it's going to create the sample templates
And that will be available within the templates.
So within templates, I'm going to have all the sample manifest file for that particular sample chart.
Now I'm going to remove all this so that I can create right from the beginning.
Everything is a removed.
Within mychart I am having mysubchart as another subchart. Within mysubchart
I'm going to add some values.
I delete all the values within the values file as well.
I'm going to add a sample key value pair.
I'm adding a key value pair named dbhostname as key and mysql node known as value.
Now let me go ahead and create a template.
I don't have any files.
I'm going to create a file called config map.yaml, let me add some sample content within it.
So this is going to create a config map where the name
It will have the release name and as a part of the dbhost key its going to have the value
from the values file so it will read the value with the key dbhost name.
Now I can try only this specific subchart.
Let me get into the parent directory mychart here I do have the project mychart
I'm going to do a dry run on my subchart.
If you observe over here, here I have given the entire path within the chart that my subchart directory I have provided.
So it's going to do a dry run and process the values file and generate the manifest file and it replaced
the dbhost with the value that we provided as a part of the values file.
So this is going to work as a separate entity
And like this, I can have n number of subcharts
And in case, if I wanted to override this particular value from the parent directory I can very well
do that. Let me give a try within mychart
I am going to update the values file. So within values file
I'm going to add or inject values to the subchart
So I'm having a collection, mysubchart the key dbhostname.
And I'm providing the value as prod mysql node as the value.
Now, let me go ahead and build the mychart and see how the value is getting generated.
This time I'm going to do a dry run against mychart and mychart is providing the value to the subchart as well.
So if I look into the computed values mysubchart
It's having prodmysqlnode
And this is the value that it calculated within the sub chart because that is coming from the parent
So the computed value, it's being provided from the parent chart
And that will be fed into the mysubchart
And mysubchart got the prodmysqlnode
And that is from the parent chart.
So this is how I can override the value that needs to be provided to the subchart as well
And there is another concept called global values that we will be discussing it in the next lecture.
So in a quick summary we have seen how to create subchart and override
The value of the subchart from the parent chart.