Skip to content

Iam-mithran/LWM-Helm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 

Repository files navigation

πŸš€ Helm Charts Made Easy | Learn With Mithran

Welcome to the Helm Charts Made Easy tutorial β€” a complete hands-on guide where you’ll learn how to simplify Kubernetes deployments using Helm 3 on Amazon EKS.

πŸŽ₯ Watch the full Video here: Learn Helm for Beginners & Create your own Helm Chart

This session is perfect for DevOps Engineers, Cloud Practitioners, and Kubernetes Enthusiasts who want to understand how Helm simplifies application deployment, versioning, and management in Kubernetes.

🎯 What You’ll Learn

By the end of this video, you’ll master:

πŸ”Ή Setting up EKS Cluster and installing Helm 3
πŸ”Ή Understanding What is Helm 3 and how it differs from Helm 2
πŸ”Ή Key Helm Commands and workflow
πŸ”Ή Creating Your First Helm Chart from scratch
πŸ”Ή Using Helm Hooks to automate pre/post install actions
πŸ”Ή Working with Dependency Charts
πŸ”Ή Understanding and customizing the _helpers.tpl file
πŸ”Ή Using Include Files, Loops, and If-Else Conditions in Helm templates


🧠 Setup EKS & Helm Environment

☁️ Configure awscli

aws configure
aws s3 ls

🧩 Install and Configure kubectl

curl -o kubectl https://s3.us-west-2.amazonaws.com/amazon-eks/1.29.0/2024-01-04/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin
kubectl version --client

βš™οΈ Install Helm 3

curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm version

☁️ Connect to Your EKS Cluster

aws eks update-kubeconfig --name my-eks-cluster --region ap-south-1
kubectl get nodes

πŸš€ Helm Commands

πŸ“¦ Helm Repository and Chart Commands

helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
helm repo list
helm search repo
helm search repo bitnami/nginx

πŸš€ Deploy and Manage Helm Charts

helm install my-nginx bitnami/nginx
helm list
helm status my-nginx
kubectl get pods
kubectl get svc
helm get manifest my-nginx

πŸ” Upgrade, Rollback, and Uninstall

helm upgrade my-nginx bitnami/nginx --set service.type=LoadBalancer
helm upgrade my-nginx bitnami/nginx \
  --set replicaCount=3 \
  --set service.type=LoadBalancer \
  --set persistence.enabled=true

helm upgrade myapp ./mychart --set replicaCount=4
helm history myapp
helm rollback myapp 1
helm uninstall my-nginx

πŸ“š Popular Helm Repositories

Repo Name URL Notes
stable https://charts.helm.sh/stable Previously the official stable repo; mostly deprecated now.
bitnami https://charts.bitnami.com/bitnami Maintained by Bitnami; includes many popular apps (MySQL, Redis, WordPress, etc.)
hashicorp https://helm.releases.hashicorp.com HashiCorp apps like Vault, Consul, Nomad
elastic https://helm.elastic.co Elasticsearch, Kibana, Logstash, Beats charts
ingress-nginx https://kubernetes.github.io/ingress-nginx Nginx Ingress Controller charts
grafana https://grafana.github.io/helm-charts Grafana, Loki, Prometheus Operator charts
jetstack https://charts.jetstack.io Cert-Manager charts
prometheus-community https://prometheus-community.github.io/helm-charts Prometheus, Alertmanager, Node Exporter charts

🧱 Create Your Own Helm Chart (Step-by-Step)

In this section, you’ll learn how to create, customize, and deploy your own Helm chart from scratch β€” a must-know skill for mastering Kubernetes packaging.

🧰 Step 1: Pull and Explore an Existing Chart

helm pull bitnami/nginx --untar
cd nginx
tree
cd
helm template my-nginx ./nginx

🧰 Step 2a: Create a New Chart using Helm Command

helm create mychart
cd mychart
tree

🧰 Step 2b: Create a New Chart using Linux Commands

mkdir mychart
cd mychart
touch Chart.yaml
touch values.yaml
mkdir templates
touch templates/deployment.yaml

Expected Folder Structure Output:

mychart/
β”œβ”€β”€ Chart.yaml
β”œβ”€β”€ values.yaml
└── templates/
    └── deployment.yaml

🧩 Step 3: Edit the Files

πŸ—‚οΈ Chart.yaml

apiVersion: v2
name: mychart
description: A simple Helm chart for Kubernetes by LearnWithMithran
version: 0.1.0
appVersion: "1.0"

βš™οΈ values.yaml

replicaCount: 2
image:
  repository: nginx
  tag: latest
service:
  type: LoadBalancer
  port: 80

πŸ“„ templates/deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ .Chart.Name }}
  template:
    metadata:
      labels:
        app: {{ .Chart.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          ports:
            - containerPort: {{ .Values.service.port }}

πŸ“„ templates/service.yaml

apiVersion: v1
kind: Service
metadata:
  name: {{ .Release.Name }}
  labels:
    app: {{ .Chart.Name }}
spec:
  type: {{ .Values.service.type }}
  selector:
    app: {{ .Chart.Name }}
  ports:
    - port: {{ .Values.service.port }}
      targetPort: {{ .Values.service.port }}
      protocol: TCP

πŸ§ͺ Step 4: Validate and Deploy

helm install myapp ./mychart
helm upgrade myapp ./mychart -f values-prod.yaml -f values-dev.yaml
helm upgrade myapp ./mychart --set replicaCount=3,image.tag=1.23
kubectl get pods
helm lint ./mychart
helm template myapp ./mychart
helm uninstall myapp

βœ… Congratulations! You’ve just created and deployed your own Helm chart successfully.


⚑ Advanced Helm Concepts β€” Hooks, Dependencies, Templates & Functions

In this section, we dive deeper into advanced Helm features used in real-world Kubernetes deployments β€” including Helm Hooks, Dependency Charts, Subcharts, and advanced templating with Go functions.


🎯 Helm Hooks

Helm hooks let you run specific resources before or after certain release lifecycle events.
They’re useful for running setup, cleanup, or validation tasks (e.g., running a Job before installing a release).

Example β€” Pre-install Hook

# templates/hooks-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
  name: "{{ .Release.Name }}-precheck"
  annotations:
    "helm.sh/hook": pre-install
spec:
  template:
    spec:
      containers:
      - name: precheck
        image: busybox
        command: ['sh', '-c', 'echo Pre-install check completed!']
      restartPolicy: Never

🧾 Helm Hook Types

Hook Name Trigger Event Description
pre-install Before any resources are installed
post-install After all resources are installed
pre-delete Before any resources are deleted
post-delete After all resources are deleted
pre-upgrade Before upgrading resources
post-upgrade After upgrade is complete
pre-rollback Before rollback begins
post-rollback After rollback completes
test Runs with helm test command

🧩 Dependency Charts

Helm supports adding dependencies inside your chart using the Chart.yaml file. For example, you can add Redis as a dependency:

# Chart.yaml
dependencies:
  - name: redis
    version: "17.1.0"
    repository: "https://charts.bitnami.com/bitnami"

Then run:

cd mychart
helm dependency update
helm install myapp ./mychart

Helm will automatically pull and package the Redis subchart under charts/ inside your chart.


🧱 Subcharts

Subcharts are charts placed inside the charts/ directory of your main chart. They help you modularize and reuse charts.

mychart/
β”œβ”€β”€ charts/
β”‚   β”œβ”€β”€ redis/
β”‚   └── backend/
β”œβ”€β”€ templates/
└── values.yaml

Subcharts inherit values via namespaces. You can override them in your main chart’s values.yaml using:

redis:
  replica:
    replicaCount: 2

🧰 Using _helpers.tpl and include

_helpers.tpl allows you to define reusable template snippets and functions.

Example:

# _helpers.tpl
{{- define "mychart.fullname" -}}
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

Then include it in another file:

metadata:
  name: {{ include "mychart.fullname" . }}

You can also define labels:

# _helpers.tpl
{{- define "mychart.labels" -}}
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/version: {{ .Chart.Version }}
{{- end -}}

Use with indentation:

metadata:
  labels:
    {{- include "mychart.labels" . | nindent 4 }}

πŸ“ Using .Files.Get to Insert Files

Helm can embed external files such as JSON or scripts into manifests.

apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-config
data:
  app-config.json: |-
    {{ .Files.Get "files/app-config.json" | nindent 4 }}

Or for shell scripts:

command: ["sh", "-c", "{{ .Files.Get "files/init-script.sh" | quote }}"]

🧩 Conditional Logic and Loops in Helm

If-Else Example

{{- if eq .Values.service.type "LoadBalancer" }}
  externalTrafficPolicy: Cluster
{{- else }}
  clusterIP: None
{{- end }}

Range Example

{{- range $key, $value := .Values.appSettings }}
  {{ $key }}: "{{ $value }}"
{{- end }}

Nested Example

{{- if .Values.enabled }}
{{- range $env := .Values.environments }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ printf "%s-%s" $.Release.Name $env.name }}
data:
  REGION: {{ $env.region }}
{{- end }}
{{- end }}

βš™οΈ Common Helm Functions

Function Description Example Output
upper Convert to uppercase {{ upper "hello" }} HELLO
lower Convert to lowercase {{ lower "HELLO" }} hello
default Default value if undefined {{ .Values.name | default "guest" }} "guest"
quote Add quotes around text {{ quote "text" }} "text"
len Count elements {{ len .Values.env }} 2
replace Replace text {{ replace "app" "a" "A" }} App
add Math addition {{ add 2 3 }} 5
b64enc / b64dec Base64 encode/decode {{ "mypassword" | b64enc }} Base64 string

For a full list of available functions, refer to the official Go template Sprig library: πŸ”— https://masterminds.github.io/sprig/


πŸ§ͺ Real-World Example Combining All Concepts

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "mychart.fullname" . }}
  labels:
    {{- include "mychart.labels" . | nindent 4 }}
spec:
  replicas: {{ .Values.app.replicas }}
  template:
    spec:
      containers:
        - name: {{ .Values.app.name | default "demo" }}
          image: nginx:latest
          env:
            {{- range .Values.env }}
            - name: {{ .name | upper }}
              value: {{ .value | quote }}
            {{- end }}

βœ… With these features β€” Hooks, Dependencies, Helpers, Includes, and Functions β€” you now understand how Helm templates can dynamically generate powerful and reusable Kubernetes manifests.

πŸ“š Further Reading


πŸ“Ί Watch the Complete Helm Video

πŸ‘‰ Learn Helm for Beginners & Create your own Helm Chart

πŸ“ž Contact Us

Phone: +91 91500 87745

πŸ’¬ Ask Your Doubts

Join our Discord Community
πŸ‘‰ Click here to connect

πŸ“Ί Explore More Learning

Subscribe to my YouTube Channel – Learn With Mithran
🎯 Watch Now


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published