Helm is a quick and easy way to deploy a webapp application instance on a kubernetes cluster with Helm chart. Follow the steps below.
Table of Contents
Deploy Webapp on Kubernetes Using with Helm Chart
This guide covers how you can install helm on kubernates cluster and get started using Helm chart for deploying a webapp application on kubernates cluster.
Prerequisites
You must have Kubernetes installed. For the latest release of Helm, we recommend the latest stable release of Kubernetes.
Also Read: What is Kubernetes? | Kubernetes explained
Step 1: Installing Helm From Script on Kubernetes
Helm has an installer script that will automatically grab the latest version of Helm and install it on kubernates locally.
You can fetch that script, and then execute it on kubernates locally.
$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 $ chmod 700 get_helm.sh $ ./get_helm.sh
Step 2: Create the helmchart
$ helm create webapp
Step 3: Delete everything in templates folder
$ rm -r *
Step 4: Create the yaml files in templates folder
1. Create configmap.yaml with the following data
$ vim configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: {{ .Values.configmap.name }} namespace: {{ .Values.namespace }} data: BG_COLOR: '#12181b' FONT_COLOR: '#FFFFFF' CUSTOM_HEADER: {{ .Values.configmap.data.CUSTOM_HEADER }}
2. Create deployment.yaml with the following data
$ vim deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Values.appName }} namespace: {{ .Values.namespace }} labels: app: {{ .Values.appName }} spec: replicas: 1 selector: matchLabels: app: {{ .Values.appName }} tier: frontend template: metadata: labels: app: {{ .Values.appName }} tier: frontend spec: # Pod spec containers: - name: mycontainer image: "{{ .Values.image.name }}:{{ .Values.image.tag }}" ports: - containerPort: 80 envFrom: - configMapRef: name: {{ .Values.configmap.name }} resources: requests: memory: "16Mi" cpu: "50m" # 50 milli cores (1/20 CPU) limits: memory: "128Mi" # 128 mebibytes cpu: "100m"
3. Create service.yaml with the following data
$ vim service.yaml apiVersion: v1 kind: Service metadata: name: {{ .Values.appName }} namespace: {{ .Values.namespace }} labels: app: {{ .Values.appName }} spec: ports: - port: 80 protocol: TCP name: flask selector: app: {{ .Values.appName }} tier: frontend type: LoadBalancer
Step 5: Delete values.yaml file
$ rm values.yaml
Step 6: Create values.yaml file with the following data
$ vim values.yaml appName: myhelmapp namespace: default configmap: name: myhelmapp-configmap-v1 data: CUSTOM_HEADER: 'This app was deployed with helm!' image: name: devopsjourney1/mywebapp tag: latest
Step 7: Pull image
$ sudo docker pull devopsjourney1/mywebapp:latest
Step 8: Install the first one
$ helm install webapp-release webapp/ --values webapp/values.yaml
Step 9: The helm list (or helm ls) function will show you a list of all deployed releases
$ helm list
Step 10: Upgrade after templating
$ helm upgrade webapp-release webapp/ --values webapp/values.yaml
Step 11: Uninstall webapp application
To uninstall a release, use the helm uninstall command:
$ helm uninstall webapp-release
Also Read: How To Install and Use Docker on Ubuntu 22.04
Be the first to comment