Helm Chart Builtin Objects


Helm Chart Builtin Objects

In this tutorial, we are going to discuss about helm chart builtin objects. Let us introduce the templating concept.

In the earlier tutorial we saw how to create the config map, YAML file and deploy the config map as a part of Kubernetes cluster.

So following is the what the config map yaml file that we had created.

[email protected]:~/mychart/templates$ cat configmap.yaml 
apiVersion: v1
kind: ConfigMap
metadata:
  name: mychart-configmap
data:
  myvalue: "Sample Config Map"

I’m going to use the same config map yaml file and introduce the templating concept. Let me get into this particular file.

Here as a part of the name, I’m going to introduce the template. For the template derivative to include within the code, we will be using the double open flower bracket and double closing flower bracket I’m going to change the name.

Here I’m going to introduce the derivative so that it can get the values either from the values file or from the built in objects.

Get the values for the template

Now let me introduce the 2 ways where we can get the values for the template. One is from the values file and another one is, there are some builtin objects which can provide the value.

To get started, we are going to understand about the built in objects. Builtin objects are nothing but every chart It will be having a list of values which can be retrieved using the builtin objects Variable name.

Say, for example {{ .Release.Name }} will provide the name of the release that we are creating using that specific chart.

So let me go ahead and use this so that I don’t need to create the values file, in the next tutorial, we will see how to use the values file.

[email protected]:~/mychart/templates$ cat configmap.yaml 
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-configmap
data:
  myvalue: "Sample Config Map"

So within the flower bracket derivative, I will insert this particular value.

There are n number of builtin objects like NameSpace, IsUpgrade, IsInstall etc. So we can go ahead and use slowly in the future tutorials we will start using one after the other.

Now let me go ahead and save this particular config file and install this specific template. So let me install the template helm install and name of the release and then the folder where I do have the resources required for this particular chart.

[email protected]:~$ helm install releasename-configmap ./mychart
NAME: releasename
LAST DEPLOYED: Sun May 16 17:42:20 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
List helm

Now the chart got deployed. Let me go ahead and get the details about the deployment using the following command.

[email protected]:~$ helm ls
NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
releasename     default         1               2021-05-17 20:04:41.584376161 +0530 IST deployed        mychart-0.1.0   1.16.0        

So I do have a deployment the name releasename. I can get more details about this particular deployment using the command get manifest.

[email protected]:~$ helm get manifest releasename-configmap
---
#Source: mychart/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: releasename-configmap
data:
  myvalue: "Sample Config Map"

So it’s going to provide the manifest file, that is the YAML file that we had used. If you look at the derivative that we had used that got replaced with the release name that we had provided.

Describe ConfigMaps

So I should have a config file with this specific name, I can check whether that particular config file, existing or not.

[email protected]:~$ kubectl describe configmaps mychart-configmap
Name:         releasename-configmap
Namespace:    default
Labels:       app.kubernetes.io/managed-by=Helm
Annotations:  meta.helm.sh/release-name: releasename-configmap
              meta.helm.sh/release-namespace: default
Data
myvalue:
Sample Config Map
Events:  <none>

Now we have successfully used the template derivative for the first time and within the YAML file, we have used the builtin object to replace within the template derivative.

So in the next lecture, we’re going to use the values file and replace this particular template derivative.

Summary

So in a quick summary we have seen how to use the template derivative and what is the syntax of it and how to use the builtin objects.

Helm Chart Builtin Objects


Scroll to top