Helm Chart Builtin Objects


Helm Chart Builtin Objects

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

Helm Chart Builtin Objects

In the earlier tutorial, we saw how to create the config map, YAML file and deploy the config map as a part of the Kubernetes cluster. So following is the what the config map YAML file that we had created.

ashok@waytoeasylearn:~/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 to 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 two ways where we can get the values for the template. One is from the values file, and another one is some built-in objects that can provide the value.

To get started, we are going to understand the built-in objects. Builtin objects are nothing but every chart; it will be having a list of values that can be retrieved using the built-in 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 following tutorial, we will see how to use the values file.

ashok@waytoeasylearn:~/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 is n number of built-in objects like NameSpaceIsUpgradeIsInstall etc. So we can 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.

ashok@waytoeasylearn:~$ helm install releasename-configmap ./mychart
NAME: releasename-configmap
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.

ashok@waytoeasylearn:~$ helm ls
NAME                      NAMESPACE       REVISION        UPDATED                                 STATUS          CHART           APP VERSION
releasename-configmap     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-configmap. I can get more details about this particular deployment using the command get manifest.

ashok@waytoeasylearn:~$ 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, which 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 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.

ashok@waytoeasylearn:~$ 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>

We have successfully used the template derivative for the first time, and within the YAML file, we have used the built-in object to replace within the template derivative.

So in the following tutorial, 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 its syntax and how to use the built-in objects.

Helm Chart Builtin Objects
Scroll to top