Helm Chart deployment example

Helm greatly simplifies the deployment process by providing a standardized approach and a high level of reusability for Kubernetes applications. It has become a popular tool in the Kubernetes ecosystem and is widely used by developers and DevOps teams to streamline application deployments and management.. Here’s an example of a basic Helm chart for Kubernetes

Create a new directory for your Helm chart:

mkdir mychart
cd mychart

Initialize the Helm chart:

helm create mychart

This will create the basic structure and files for your chart.

Related: Full Guide on How to Create a simple helm chart

Edit the values.yaml file to define your configuration values. This file contains the default configuration values for your chart.

Create your Kubernetes manifest files (e.g., deployment.yaml, service.yaml, etc.) in the templates directory. You can use standard Kubernetes YAML syntax to define your resources.

Here’s an example deployment.yaml file in the templates directory:

apiVersion: apps/v1
kind: Deployment
  name: {{ include "mychart.fullname" . }}
    app: {{ include "mychart.name" . }}
  replicas: {{ .Values.replicaCount }}
      app: {{ include "mychart.name" . }}
        app: {{ include "mychart.name" . }}
        - name: {{ .Chart.Name }}
          image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
            - containerPort: {{ .Values.service.port }}

Customize the manifest files using Helm’s template language. You can use Helm values, functions, and conditionals to make your templates dynamic. For example, in the above deployment.yaml, {{ .Values.replicaCount }} and {{ .Values.image.repository }} are placeholders that will be replaced with the values defined in your values.yaml file.

You can also define a Chart.yaml file in the root of your chart directory to provide metadata about your chart, such as the name, version, and description.

Here’s an example Chart.yaml file:

apiVersion: v2
name: mychart
version: 0.1.0
description: A Helm chart for my application

Once you’ve defined your chart, you can package it into a Helm chart archive (.tgz) using the following command:

helm package .

This will create a .tgz file in your current directory.

You can then install the chart on your Kubernetes cluster using the following command:

helm install myrelease mychart-0.1.0.tgz

Replace myrelease with the name you want to give to the release.

That’s a basic example of a Helm chart in Kubernetes. You can add more resources, such as services, configmaps, and ingress rules, by creating additional manifest files in the templates directory and referencing them in your deployment.yaml or other templates.