Kubernetes Deployment Using Helm — A Complete Beginner-Friendly Guide

 

Kubernetes Deployment Using Helm — A Complete Beginner-Friendly Guide

Deploying applications directly with raw Kubernetes YAML files quickly becomes repetitive and error-prone.
This is exactly where Helm helps — a package manager for Kubernetes that simplifies deployments, promotes reusability, and standardizes configurations.

In this blog, we’ll understand:

  • What is Helm?

  • Helm chart folder structure

  • How templates work

  • How values.yaml makes your deployment configurable

  • Deployment + Service example for a backend API

  • Helm commands to deploy your application


🧭 1. What Is Helm?

Helm is Kubernetes’s package manager, similar to:

  • apt (Ubuntu)

  • yum (CentOS)

  • Homebrew (macOS)

A Helm chart packages all Kubernetes YAML files into a reusable structure.

Instead of maintaining multiple YAMLs per environment (dev, QA, prod), Helm allows:

✔ Configuration overrides
✔ Templates
✔ Versioning
✔ Easy upgrades (helm upgrade)
✔ One-line deployment


🗂️ 2. Helm Chart Structure Explained

When you create a Helm chart using:

helm create myservice

Helm generates the following structure:

myservice/ │ ├── Chart.yaml # Chart metadata (name, version, description) ├── values.yaml # Default configuration values (overridable) │ ├── templates/ # Kubernetes YAML templates │ ├── deployment.yaml │ ├── service.yaml │ ├── ingress.yaml │ ├── hpa.yaml │ ├── _helpers.tpl # Helper functions │ └── NOTES.txt # Instructions after deployment │ └── charts/ # Dependency charts (optional)

🧩 3. Key Components Inside the Chart

✔ Chart.yaml

Metadata about the chart:

apiVersion: v2 name: myservice description: A backend API service version: 0.1.0 appVersion: "1.0"

✔ values.yaml

All environment-specific configuration goes here.

Example:

replicaCount: 2 image: repository: myregistry/myservice tag: "1.0.0" pullPolicy: IfNotPresent service: type: ClusterIP port: 8080 resources: limits: cpu: "500m" memory: "512Mi" env: APP_ENV: "prod" LOG_LEVEL: "info"

You will override these per environment (dev/prod).


🛠️ 4. Templates — How Helm Injects Values

Inside templates/deployment.yaml, Helm uses Go template syntax:

apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "myservice.fullname" . }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: app: {{ include "myservice.name" . }} template: metadata: labels: app: {{ include "myservice.name" . }} spec: containers: - name: myservice image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" ports: - containerPort: {{ .Values.service.port }} env: - name: APP_ENV value: "{{ .Values.env.APP_ENV }}" - name: LOG_LEVEL value: "{{ .Values.env.LOG_LEVEL }}"

Helm replaces {{ ... }} during deployment.


🌐 5. Service (Expose Your Endpoint)

If your backend API runs on http://service:8080/api/v1/hello,
you need a Kubernetes Service.

Example service.yaml:

apiVersion: v1 kind: Service metadata: name: {{ include "myservice.fullname" . }} spec: type: {{ .Values.service.type }} ports: - port: {{ .Values.service.port }} targetPort: {{ .Values.service.port }} protocol: TCP selector: app: {{ include "myservice.name" . }}

This exposes your API internally inside the cluster.


🌍 6. Optional: Ingress (Expose to Internet)

If you want the service available via a domain like:

https://api.mycompany.com/myservice

You need an ingress:

apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: {{ include "myservice.fullname" . }} spec: rules: - host: api.mycompany.com http: paths: - path: / pathType: Prefix backend: service: name: {{ include "myservice.fullname" . }} port: number: {{ .Values.service.port }}

📝 7. How to Deploy the Service Using Helm

1. Create your chart

helm create myservice

2. Update values.yaml

Your image, port, replicas, env variables.

3. Deploy to Kubernetes

helm install myservice ./myservice

4. Upgrade after modifying values

helm upgrade myservice ./myservice

5. Uninstall

helm uninstall myservice

📦 8. Passing Environment-Specific Values

dev-values.yaml

replicaCount: 1 image: tag: "1.0-dev"

prod-values.yaml

replicaCount: 4 image: tag: "1.0-prod"

Deploy using:

helm install myservice -f prod-values.yaml .

🧱 9. How the Application Endpoint Is Exposed

Let’s say your application exposes:

GET /api/v1/status PORT = 8080

Then:

  • Container exposes → 8080

  • Deployment uses → containerPort: 8080

  • Service exposes → port: 8080

  • Ingress exposes → domain route

Flow:

Client → Ingress → Service → Pod → Application Endpoint

🧭 10. Text Diagram — Deployment Flow

┌───────────────────────┐ │ Ingress (Optional)│ └────────────┬──────────┘ │ ┌────────────▼──────────┐ │ Service (ClusterIP)│ └────────────┬──────────┘ │ ┌──────────────▼──────────────┐ │ Deployment │ └──────────────┬──────────────┘ │ ┌──────────────▼──────────────┐ │ Pods │ │ (Running your API) │ └──────────────────────────────┘

🎯 Summary

ConceptDescription
HelmPackage manager for Kubernetes
ChartFolder containing Kubernetes templates
values.yamlEnvironment-specific variables
deployment.yamlDeploy your app container
service.yamlExposes your app to the cluster
ingress.yaml(Optional) Public access endpoint

👍 Final Thoughts

Helm makes Kubernetes deployments:

✔ Consistent
✔ Repeatable
✔ Versioned
✔ Easy to override for multiple environments

You only maintain one chart, and override the configuration for dev/staging/prod.

No comments:

Post a Comment

Java Design Patterns With What • Why • When • Full Java Programs • Client Usage

  Java Design Patterns  With What • Why • When • Full Java Programs • Client Usage Introduction Design Patterns are proven solutions to...

Featured Posts