Helm is often referred to as the package manager for Kubernetes. It enables you to define, install, and manage even the most complex Kubernetes applications. Helm uses a packaging format called charts, which include all the resources needed to run an application, service, or a complete cloud-native stack inside Kubernetes.
curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
sudo apt-get install apt-transport-https --yes
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm
Run the following command to scaffold a new Helm chart:
helm create node-app-chart
This will create a folder named node-app-chart
with the initial chart structure.
Open Chart.yaml and modify it for your application:
apiVersion: v2
name: node-app-chart
description: A Helm chart for a Node.js application
version: 0.1.0
Edit values.yaml to include:
replicaCount: 1
image:
repository: ayihandocker/2-tier-flask-app:flask-app
tag: flask-app
pullPolicy: IfNotPresent
service:
type: NodePort
port: 30007
targetPort: 8000
Modify deployment.yaml under templates/ to look like this:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-deployment
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 8000
Open service.yaml under templates/ and modify it:
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-service
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort }}
nodePort: {{ .Values.service.port }}
selector:
app: {{ .Release.Name }}
Use these commands to package and deploy the chart:
helm package node-app-chart
helm install my-node-app ./node-app-chart
helm list
helm status <chart name>
helm create [CHART]
: Scaffold a new Helm chart.helm package [CHART]
: Package the chart into a chart archive.helm install [NAME] [CHART]
: Install a Helm chart.helm upgrade [NAME] [CHART]
: Upgrade an installed Helm chart.helm uninstall [NAME]
: Uninstall an installed Helm chart.helm list
: List all installed Helm charts.helm rollback [NAME] [REVISION]
: Roll back a release to a specific revision.