- Download and install Docker Desktop from Docker's official website.
- Open Docker Desktop and navigate to Settings > Kubernetes.
- Check the box for Enable Kubernetes and click on Apply & Restart.
-
Install SDKMAN by running the following command:
curl -s "https://get.sdkman.io" | bash
-
Open a new terminal window and install Java 21:
sdk install java 21.0.0
-
Navigate to your Spring Boot project directory.
-
Run the following command to build the project using Gradle:
./gradlew build
This will generate a JAR file in the build/libs/
directory.
-
Make sure you have a
docker-compose.yaml
file at the root of your project. -
Run the following command to bring up the services:
docker-compose up --build
-
Open a browser and navigate to
http://localhost:8080/hello
to ensure that the application is running as expected.
Run the following command to build a Docker image for your Spring Boot application:
docker build -t helloworld-spring-boot-app:latest .
Your Helm chart directory should look like this:
my-helm-chart/
├── templates/
│ ├── deployment.yaml
│ ├── postgres-service.yaml
│ └── springboot-loadbalancer-service.yaml
├── values.yaml
└── Chart.yaml
- templates/: Your Kubernetes YAML definitions.
- values.yaml: Configuration variables for your templates.
- Chart.yaml: Metadata about the Helm chart.
-
Chart.yaml: This file should contain meta-information about the Helm chart.
apiVersion: v2 name: my-helm-chart version: 0.1.0
-
values.yaml: This file should hold configurable parameters that will be fed into your templates. See example values for Spring Boot and PostgreSQL configurations.
-
deployment.yaml: This file should contain the Deployment configuration for your Spring Boot application, including any environment variables it might need.
-
postgres-service.yaml: This file should define a Kubernetes Service for your PostgreSQL database, as well as a Deployment to manage the database Pods.
Once your Helm chart is ready, you can deploy it to your Kubernetes cluster:
-
Lint the chart to catch issues:
helm lint ./my-helm-chart
-
Package the chart:
helm package ./my-helm-chart
-
Deploy the chart:
helm install my-helm-release ./my-helm-chart
That's it! You now have a Helm chart for deploying a Spring Boot application and PostgreSQL database, complete with a LoadBalancer and health checks.