0% found this document useful (0 votes)
198 views6 pages

Using Helm To Package An Application Running On Kubernetes

Uploaded by

suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
198 views6 pages

Using Helm To Package An Application Running On Kubernetes

Uploaded by

suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Using Helm to Package an Application

Running on Kubernetes
Author: Zayan Ahmed | Estimated Reading time: 6 mins

Helm is a powerful tool for managing Kubernetes applications. It simplifies the deployment,
management, and versioning of applications by providing a standardized way to package
them as "charts." This guide explains how to use Helm to package an application running on
Kubernetes.

Prerequisites
1. Kubernetes Cluster: A running Kubernetes cluster (local or remote).
2. kubectl: Installed and configured to interact with your Kubernetes cluster.
3. Helm: Installed on your local machine.

Step 1: Install Helm


Follow these steps to install Helm:

1. Download the Helm binary for your operating system from the official Helm releases.
2. Install the binary by following the installation instructions for your OS.
3. Verify the installation:

helm version
Step 2: Create a Helm Chart
A Helm chart is a collection of files that describe a related set of Kubernetes resources.

1. Use the helm create command to scaffold a new chart:

helm create my-application

This creates a directory structure like this:

my-application/
├── charts/
├── templates/
├── values.yaml
└── Chart.yaml

2. Key Files:

○ Chart.yaml: Contains metadata about the chart.


○ values.yaml: Defines default configuration values.
○ templates/: Contains Kubernetes manifests written as Helm templates.

Step 3: Modify the Chart for Your Application

Update Chart.yaml

Edit the Chart.yaml file to reflect your application's metadata:

apiVersion: v2
name: my-application
version: 1.0.0
appVersion: "1.0.0"
description: A Helm chart for my application

Configure values.yaml

Set default values for your application, such as container image and replica count:

replicaCount: 2
image:
repository: my-docker-repo/my-app
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 80
ingress:
enabled: false

Edit Kubernetes Manifests in templates/

Replace the sample manifests in the templates/ directory with your application's
manifests. For example:

templates/deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Chart.Name }}
labels:
app: {{ .Chart.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: 80

templates/service.yaml

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

Step 4: Package the Chart


Once you've configured the chart, package it into a .tgz archive:

helm package my-application

This generates a file like my-application-1.0.0.tgz.

Step 5: Deploy the Application Using Helm


To deploy your application, run the following command:

helm install my-app ./my-application-1.0.0.tgz

Helm will:
1. Render the templates using the values provided in values.yaml.
2. Apply the resulting Kubernetes manifests to your cluster.

Verify the deployment:

kubectl get all

Step 6: Manage the Release


Upgrade the Application

To update your application, modify the chart or values.yaml and run:

helm upgrade my-app ./my-application

Roll Back Changes

Helm keeps a history of releases, allowing you to roll back to a previous version:

helm rollback my-app 1

Step 7: Share the Chart


You can share the packaged .tgz file or host it on a Helm repository like ArtifactHub.

To create a local repository:

1. Serve the directory with the .tgz file using a web server.
2. Add it to Helm:

helm repo add my-repo http://my-repo-url

Best Practices
1. Use Variables: Keep configurations flexible by defining values in values.yaml.
2. Lint Charts: Validate your chart:

helm lint ./my-application

3. Version Control: Track chart changes in a version control system.


4. Automation: Automate Helm chart deployment in your CI/CD pipelines.

Conclusion
Helm simplifies Kubernetes application management by enabling you to package, deploy,
and manage applications consistently. Following this guide, you can package your
application into a Helm chart and leverage its full capabilities to enhance deployment and
operational efficiency.

🤔
😊
Want more ?
Follow me on LinkedIn

You might also like