Code Like A Girl

Welcome to Code Like A Girl, a space that celebrates redefining society's perceptions of women in technology. Share your story with us!

Follow publication

Member-only story

DevOps, Cloud Computing

Kubernetes Persistent Volume Case Study: Deploy a Spring Boot App with a Postgres DB

Rakia Ben Sassi
Code Like A Girl
Published in
6 min readNov 26, 2024

--

This article is an excerpt from my video course Modern Software Engineering: Architecture, Cloud & Security available with a limited time discount.

Want to try something real with Kubernetes?

Let’s deploy a Spring Boot Application with a PostgreSQL database that needs persistent storage. This way, you’ll get hands-on experience managing stateful and stateless applications on Kubernetes.

Here are the steps to achieve this using Kubernetes:

  1. Create a Persistent Volume and Persistent Volume Claim for the PostgreSQL database.
  2. Set up a Deployment to manage the PostgreSQL database and ensure persistence.
  3. Deploy the Spring Boot App using a Deployment, which is a stateless application.
  4. Expose both PostgreSQL and the Spring Boot App using Services.
  5. Access the PostgreSQL database and make sure everything is running smoothly.

Note: Part 1 of my Kubernetes hands-on tutorial is available here, and part 2 is available here.

Step 1: Prerequisites

Before you begin, ensure you have the following set up:

  1. A running Kubernetes cluster: you can use Minikube, Kind, or any managed Kubernetes service like GKE, EKS, etc. In my case, I’m using Minikube and Docker Desktop for a local Kubernetes deployment on my local machine. So after starting Docker Desktop to make the Docker Daemon available, I need to start Minikube by running the command minikube start.
  2. kubectl CLI installed and configured to communicate with your cluster.
  3. Helm (optional but recommended for easier management).

Step 2: Create a Persistent Volume (PV) and Persistent Volume Claim (PVC) for PosgreSQL

PostgreSQL needs a persistent disk to store data. We’ll define a PersistentVolume and a PersistentVolumeClaim (PVC) that our database will…

--

--

Published in Code Like A Girl

Welcome to Code Like A Girl, a space that celebrates redefining society's perceptions of women in technology. Share your story with us!

Written by Rakia Ben Sassi

Google Developer Expert in Angular, WTM Ambassador, a seasoned software engineer, Content Creator | YouTube: https://www.youtube.com/@tekforge

No responses yet

Write a response