springboot-helm

Helm Chart for Spring Boot Application with PostgreSQL

This Helm chart deploys a Spring Boot application that connects to a PostgreSQL database. The chart manages the application and database resources efficiently using Kubernetes objects like Deployments, Services, Secrets, and PersistentVolumes.


Features

  1. Spring Boot Application
    • Runs on port 8080.
    • Deployed as a Deployment with 2 replicas.
    • Image pulled from Docker Hub: naveenalla/spring-app-helm.
  2. PostgreSQL Database
    • Persistent storage enabled using a PersistentVolumeClaim (postgres-pvc).
    • Credentials and configuration are managed using Kubernetes Secrets.
    • Default credentials:
      • Username: postgres
      • Password: postgres
      • Database: springdb
    • Storage size: 1Gi.
  3. Service Configuration
    • PostgreSQL is exposed as a ClusterIP service on port 5432.
    • Application is exposed as a NodePort service on port 8080.

Files and Configuration

Chart Files:

Values.yaml Configuration:

postgres:
  username: postgres
  password: postgres
  database: springdb
  persistence:
    enabled: true
    storageSize: 1Gi

springApp:
  image: naveenalla/spring-app-helm
  replicas: 2

service:
  type: NodePort
  port: 8080

Prerequisites

  1. Kubernetes cluster (1.20+) with kubectl configured.
  2. Helm (3.x) installed on the cluster.
  3. Persistent storage provisioner for the cluster.
  4. minikube (optional) for local testing.

Installation & Deployment steps

  1. Add repository helm-chart files from the artifacthub.io.
    helm repo add naveenalla-springboot https://naveenalla3000.github.io/springboot-helm/
    
  2. Update the repository.
    helm repo update
    
  3. Install the Helm chart with a release name spring-app.
    helm install my-spring-helm naveenalla-springboot/spring-helm
    
  4. Verify the deployment.
    kubectl get all
    

Access the Application

  1. Verify the NodePort service created for the application.
    kubectl get svc
    
  2. Access the application using the NodePort service.
    kubectl port-forward service/my-spring-helm-spring-app-service 8080:8080
    
  3. Open the application in a browser using the URL: http://localhost:8080.

Flow Diagram

Below is the deployment architecture for the Helm chart:

 +------------------+      +-----------------------+      +-------------------+
 |                  |      |                       |      |                   |
 |  postgresql      |      |       cluster-ip      |      |     springboot    |
 |     pod          |----->|       db-service      |----->|     application   |  
 |                  |      |                       |      |                   |
 +--------+---------+      +-----------+-----------+      +---------+---------+
          |                                                         |
          |                                                         |                    
 +--------v---------+                                     +---------v---------+
 |                  |                                     |                   | 
 |     persistent   |                                     |    NodePort       |
 |    volume claim  |                                     |    app-service    |
 |                  |                                     |                   |                        
 +------------------+                                     +-------------------+
           |                                                       |
           |                                                       |
 +---------v---------+                                   +---------v---------+
 |                   |                                   |                   |            
 |    persistent     |                                   |    web browser    |
 |     storage       |                                   |                   |
 |                   |                                   +-------------------+
 +-------------------+
             

Notes


Uninstallation

To delete the Helm release:

helm uninstall my-spring-helm

This will remove all resources associated with the release.