Show List

Chart templates and values file

Helm Chart templates are files that define the configuration and resource requirements for a specific application. They are written using the Go templating language and define the desired state of the Kubernetes resources, such as deployment, service, and ingress.

The Values file, also known as the values.yaml file, contains the default values for the variables used in the templates. These values can be overridden when installing or upgrading the chart.

Here's an example of how the two files work together:

Suppose you have a simple template for a deployment:

yaml
Copy code
apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Release.Name }}-deployment labels: app: {{ .Values.app.name }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: app: {{ .Values.app.name }} template: metadata: labels: app: {{ .Values.app.name }} spec: containers: - name: {{ .Values.app.name }} image: {{ .Values.image.repository }}:{{ .Values.image.tag }} ports: - name: http containerPort: 80

And a values.yaml file with the following default values:

yaml
Copy code
replicaCount: 1 image: repository: myapp tag: latest app: name: myapp

When you run the helm install command, the values in the values.yaml file will be passed to the template, and the resulting YAML file will be used to create the deployment in your Kubernetes cluster. For example, the resulting YAML file for the deployment might look like this:

yaml
Copy code
apiVersion: apps/v1 kind: Deployment metadata: name: myrelease-deployment labels: app: myapp spec: replicas: 1 selector: matchLabels: app: myapp template: metadata: labels: app: myapp spec: containers: - name: myapp image: myapp:latest ports: - name: http containerPort: 80

In this example, the values in the values.yaml file were used to fill in the template variables in the deployment template. The resulting YAML file was then used to create the deployment in the Kubernetes cluster.

In summary, the Chart templates and values file provide a convenient way to define the desired state of your application and configure it for deployment on a Kubernetes cluster. The templates define the desired state of the resources, while the values file provides default values that can be overridden when installing or upgrading the chart.


    Leave a Comment


  • captcha text