Getting Started with Helm Charts: A Beginner's Guide for Deploying Spring Boot Applications

 

1. Introduction to Helm

When working with Kubernetes, managing all the YAML files (Deployments, Services, ConfigMaps, etc.) can become complex and error-prone, especially as applications grow.

Helm is the package manager for Kubernetes, like Maven for Java. It simplifies deploying, versioning, and rolling back Kubernetes applications by packaging all necessary resources into a Chart.

  • Helm = Package Manager

  • Chart = A packaged application (like a .jar file for Java)

Think of a Helm Chart as a ready-to-install "Kubernetes application".

2. What is a Helm Chart?

A Helm Chart is a collection of files that describe a related set of Kubernetes resources.

Definition:

"A Helm Chart is a pre-configured Kubernetes resource bundle that can be installed, upgraded, or deleted as a single unit."

Use cases:

  • Deploy Spring Boot microservices easily.

  • Manage multiple environments (Dev, QA, Prod) with different configuration values.

  • Enable versioned and repeatable deployments.

3. Helm Chart Hub (Artifact Hub)

You don't always have to build charts from scratch.

  • Artifact Hub (https://artifacthub.io/ ) is a central repository where developers share public Helm Charts.

  • You can search for databases (PostgreSQL, MySQL), monitoring tools (Prometheus, Grafana), or example applications.

  • It's similar to Maven Central for Java libraries.

Example:

helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-mysql bitnami/mysql

4. Helm Chart vs Docker: Understanding the Difference

Many beginners confuse Docker and Helm. Here's a simple analogy:

Aspect Docker Helm
Purpose Packages application code + dependencies into containers Packages Kubernetes resource configurations into deployable units
Output Container Image (e.g., my-app:1.0) Helm Chart (e.g., my-springboot-app-0.1.0.tgz)
Usage Run containers anywhere (Docker, Kubernetes, local VMs) Deploy and manage Kubernetes resources easily
Example docker run my-app helm install my-app ./my-springboot-app

Summary:

  • Docker focuses on packaging and running applications.

  • Helm focuses on packaging and deploying Kubernetes infrastructure (which runs Docker containers internally).

You usually need both for a full Kubernetes application:

  • Build a Docker image of your Spring Boot App.

  • Deploy it to Kubernetes using a Helm Chart.

5. Helm Chart Structure

When you create a Helm chart for your Spring Boot Web Application, the folder structure looks like this:

my-springboot-app/
├── Chart.yaml
├── values.yaml
├── templates/
│   ├── deployment.yaml
│   ├── service.yaml
│   ├── ingress.yaml (Optional)
│   ├── configmap.yaml (Optional)
│   ├── hpa.yaml (Optional)
├── charts/ (Optional - for dependencies)
└── templates/_helpers.tpl (Optional - for helper templates)

Let's understand each file:

a) Chart.yaml

  • Metadata about the chart (name, version, description).

  • Example:

apiVersion: v2
name: my-springboot-app
description: A Helm chart for deploying a Spring Boot Web Application
version: 0.1.0
appVersion: 1.0.0

b) values.yaml

  • The default configuration values.

  • You override these during deployment (helm install -f custom-values.yaml).

  • Example:

replicaCount: 2
image:
  repository: myregistry/my-springboot-app
  tag: latest
service:
  type: ClusterIP
  port: 8080

c) templates/deployment.yaml

  • Defines the Kubernetes Deployment.

  • Uses placeholders like {{ .Values.image.repository }} to fetch values dynamically.

  • Example snippet:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Release.Name }}
          image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
          ports:
            - containerPort: 8080

d) templates/service.yaml

  • Defines the Kubernetes Service (how your application is exposed internally).

  • Example snippet:

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

e) templates/ingress.yaml (Optional)

  • Used if you want to expose your service externally with a domain name.

f) templates/configmap.yaml (Optional)

  • Inject environment-specific configs without rebuilding images.

g) templates/hpa.yaml (Optional)

  • For Horizontal Pod Autoscaling (auto-scaling pods based on CPU/memory).

6. Create Your First Helm Chart for Spring Boot

Steps:

  1. Install Helm CLI:

brew install helm # MacOS
choco install kubernetes-helm # Windows
  1. Scaffold a new Chart:

helm create my-springboot-app
  1. Update templates and values.yaml to match your application.

  2. Package and Deploy:

helm install my-app ./my-springboot-app
  1. To upgrade after changes:

helm upgrade my-app ./my-springboot-app

7. Real-World Example: Deploying a Spring Boot Web App

Suppose you have a Spring Boot app exposing /api/hello on port 8080. Here’s a minimal values.yaml:

image:
  repository: myregistry/my-springboot-app
  tag: 1.0.0
service:
  type: LoadBalancer
  port: 8080
replicaCount: 3

After helm install, your app is available via the LoadBalancer IP.

8. Summary

Component Purpose
Chart.yaml Metadata about the application
values.yaml Default configurations
templates/*.yaml Kubernetes resource definitions

Comments

  1. This site gave me a better understanding of cyber security for mobile phones—clear and simple info.

    ReplyDelete
  2. Helm provides a practical way to manage Kubernetes deployments by packaging related resources into reusable Charts. The comparison with Maven and the distinction between Helm Charts and Docker make the topic especially approachable for beginners, while the examples involving Spring Boot microservices show how Helm can simplify repeatable deployments across different environments.

    The discussion of versioning, configuration, and environment management is particularly useful for developers working with enterprise Java applications. Understanding how deployment resources can be organized and managed alongside application development can complement skills gained through Spring Boot Angular Full Stack Developer Course, especially when applications need to move through development, testing, and production environments.

    ReplyDelete
  3. I also found the Docker-versus-Helm comparison helpful because the two technologies address different parts of the deployment process. Docker focuses on packaging and running applications in containers, while Helm manages Kubernetes resources as deployable units. This distinction is valuable for developers building broader application skills through Java Full Stack Developer Course, where understanding both application development and deployment concepts can be beneficial.

    ReplyDelete

Post a Comment

Popular posts from this blog

Understanding Mutual TLS (mTLS): A Comprehensive Guide for Beginners

Liquibase Tutorial

Streaming Spring boot logs to ELK stack