Deploying Apps with Helm: A Simple Approach and Cheatsheet for Easy Reference!

Learn how to deploy applications effortlessly with Helm in Kubernetes

Deploying Apps with Helm: A Simple Approach and Cheatsheet for Easy Reference!

Helm is a package manager for Kubernetes. Helm is a tool that helps you manage applications in Kubernetes. Think of it like an app store for Kubernetes. It makes it easier to install, update, and manage apps in your Kubernetes environment.

How it works:

  • Charts: These are like packages or blueprints for apps. A chart contains all the files and settings needed to run an app on Kubernetes.

  • Releases: When you install a chart, it creates a release, which is basically the app running in your Kubernetes.

  • Repositories: These are like shelves that hold charts, where you can find different apps to install.

Why it's useful:

  • Easier Deployment: You don’t have to write complex YAML files by hand; Helm does it for you.

  • Manage Versions: Helm keeps track of different versions of your apps, so you can update them or roll back if something goes wrong.

  • Customization: You can tweak settings to fit your needs without changing the whole setup.

Example:

  • To install an app, you run a simple command like helm install <app-name>.

It’s a great tool to save time and keep things organized when managing many apps in Kubernetes.


Note: It is recommended to read this blog for EC2 instance creation before continuing with this one or create any ec2 instance with t2.medium.

How to Install HELM?

Refer to this Repo for installation instructions or follow the steps below:

Prerequisites

  • Kubernetes cluster running (local, cloud, or KIND).

  • kubectl installed and configured.

  • Helm 3 installed. Install Helm with:

  1. Download and install a script get_helm.sh :
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3

Run ls to see that get-helm-3 is available in the directory.

It is a shell script to install HELM.

Now, give the script permission and run it.

chmod 700 get_helm.sh

./get_helm.sh
  1. Install the HELM Chart of Apache:
mkdir helm-practice

cd helm-practice
helm create apache

cd apache

cd templates # here you can see all the deployment, services, ingress files already created

cd ..

#Now opn values.yaml, it have replicas record

vim values.yaml

Lets edit this values.yml:

#Just change below thiungs in values.yaml file

# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/
replicaCount: 2

# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/
image:
  repository: httpd
  # This sets the pull policy for images.
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: 2.4

Now run below command to install Helm:

cd ..

helm install apache ./apache --namespace apache-namespace --create-namespace

You can see details in below screenshot

Explanation of the command:

  • helm install: Command to install an app with Helm.

  • apache: Name for the installation.

  • ./apache: Location of the chart (app files).

  • --namespace apache-namespace: Sets the namespace for the app.

  • --create-namespace: Creates the namespace if it doesn’t exist.

  1. Now check the pods with the namespace apache-namespace

This is how pods gets created with the help of HELM.


Deploy node-app with Zero Code:

  1. Create node-app with helm:
helm create node-app

cd node-app/
  1. Update below details in values.yaml
#vim values.yaml

image:
  repository: chetan0103/node-app
  # This sets the pull policy for images.
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: latest

-----------------------

# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/
service:
  # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
  type: ClusterIP
  # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports
  port: 8000
  targetPort: 8000
  1. After add above details go to templates/service.yaml & update targetPort details:
apiVersion: v1
kind: Service
metadata:
  name: {{ include "node-app.fullname" . }}
  labels:
    {{- include "node-app.labels" . | nindent 4 }}
spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.service.port }}
      targetPort: {{ .Values.service.targetPort }}
      protocol: TCP
      name: http
  selector:
    {{- include "node-app.selectorLabels" . | nindent 4 }}
  1. Now you can apply the changes:
helm install node-app2 ./node-app --namespace node-app --create-namespace

  1. Now try run our application:
kubectl port-forward service/node-app2 -n node-app 8000:8000 --address=0.0.0.0

Get your public IP from AWS and enter it in the browser with port 8000:

This is a no-code deployment of the application we set up.



Deploy Grafana and Prometheus Application:

Repo: https://github.com/Chetan-Mohod/Wanderlust-Mega-Project

  • Add Helm Stable Charts for Your Local Client
helm repo add stable https://charts.helm.sh/stable
  • Add Prometheus Helm Repository
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
  • Create Prometheus Namespace
kubectl create namespace prometheus
kubectl get ns
  • Install Prometheus using Helm
helm install stable prometheus-community/kube-prometheus-stack -n prometheus

You can see Prometheus has been deployed.

Now we can see the deployed pods for Prometheus with the help of HELM:

We can check the services as well:

kubectl get svc -n prometheus

Run the application for Grafana:

sudo -E kubectl port-forward service/stable-grafana -n prometheus 80:80 --address=0.0.0.0

You can see our Grafana is working:

Delete the namespace :

kubectl delete ns prometheus


Here is the Cheat Sheet for HELM.


Happy Learning :)

Chetan Mohod ✨

For more DevOps updates, you can follow me on LinkedIn.