Hi, Let us understand how to create our own values and use it within the template. Within our sample chart
Let me get in to the values YAML file.
I do have values.yaml file
This one was created while using the chart create command
I'm going to delete all the values and add my one value over here.
So these are all the values which were added when the template was getting created.
Let me delete all the values.
I'm going to add a simple line with a key and value.
So I do have a key cost code and value corresponding to that key is this.
So we're going to read this specific key within the template and substitute that and make use of that
within the templates. Let me go ahead and edit the template.
I'm going to edit the config map.yaml
Now I'm going to add another key value pair as a part of the data.
So I'm going to add a key called cost code.
And that's going to have a value read from the values file using the cost code. The Syntax is .values.costcode
That was the key used within the values.yaml file.
And that will be enclosed within double flower bracket.
Now when I'm deploying this particular chart as a release, it's going to substitute the values and
generate the right YAML file and deploy them, in case if I don't want to do the installation, say I
don't want to make a release
I just want to see how the values are getting substituted.
I can use a dry run option.
This is one of the commonly used command so that I can test it out before doing the release.
So I do have the mychart template.
Now I'm going to do a dry run. The command is helm install --debug --dry-run and then the name of the release
And then the folder where we do have the chart resources.
So it's going to substitute the values and generate the manifest file.
And this is how the manifest file would get generated.
If you see over here, we have a template derivative over here for the cost code and that's read
from the values file and it got substituted.
So this was the value that was computed.
The reason why we have the computed values within values.YAML file
We can have some computations to read.
Data from other file or using some functions and calculate the value.
Simple example date.
So those computed values it's going to generate and that value will get substituted.
In this case, we hardcoded the value.
And the same value is substituted within the YAML file
But there will not be any deployment for this particular operation.
I can check using the helm ls. There is no releases.
And in case, if I wanted to do the release, I can do it using helm install. Helm install name of the release
And then the folder where we have the chart resources.
So the values will be computed and that will be replaced within the template and template would get deployed.
And I should have those config file within the kubernetes.
So this was the name of the release.
Let me check the release.
helm ls, yes it got deployed
In case if I wanted to check the values, what got deployed
I can use manifest command.
So I want to get the values that was used within the YAML file after doing the computation.
The name of the config map should be this.
I can get the details about this particular config map within the kubernetes. Yes, I do have.
And here I do have the key costcode and the value corresponding to that
Is this so successfully we are able to read a key value pair from the values file and substitute that within
the templates and make use of that as a part of the installation.
Along with that, we learned about how to do the dry run so that we can verify the computed value
and how the YAML file will be generated for the test purpose, now to keep the system clean
Let me go ahead and remove this particular installation, helm uninstall and name of the release.
It is uninstalled. So there should not be any release now. After every demo
I'm going to do the uninstallation so that the next demo will be clean and clear.