Deploy Spring boot and Next.js application with PostgreSQL in K8s Cluster #2.

Deploy Spring boot and Next.js application with PostgreSQL in K8s Cluster #2.

Run application to local environment

Prerequisite: -

You should have the following installed into your local system mentioned below.

1) Node.js

2) Apache Maven

3) Podman or Docker

4) Java version - 17.0

5) IntelliJ IDEA

6) Visual Studio Code

STEP 1:- SETUP PostgreSQL

Link: - github.com/dnisha/DevOps-Boot-Camp.git

Pull the repository link above, after you pulled the repository the folder structure looks like below.

Pull the repository inside the Documents folder of the Linux System.

Run the postgres.sh script

./postgres.sh

I recommend you to go through the script before you execute.

If you have docker installed in your system replace the podman marked above in the script with docker.

After executing the script if you see output into the terminal like below, then Congratulations you have successfully set up PostgreSQL in your local system.

STEP 2:- SETUP Backend

Link: - https://github.com/dnisha/todoApp-Backend.git

Pull the repository link above, after you pulled the repository the folder structure looks like the below in IntelliJ IDEA.

check if your application.yml file is like the above inside /src/main/resources file if not replace the content from below

#spring:
#  r2dbc:
#    url: r2dbc:postgresql://${DB_HOST}:5432/postgres?currentSchema=${DB_NAME}
#    username: ${POSTGRES_USER}
#    password: ${POSTGRES_PASSWORD}

#for local to run uncomment below
spring:
  r2dbc:
    url: r2dbc:postgresql://localhost:5432/postgres?currentSchema=todoApp
    username: postgres
    password: mysecretpassword

Compile and build the java code.

mvn clean install -Dskiptests

Run the spring boot application.

mvn spring-boot:run

If you get the output into the terminal like below, then your backend is up and running at port 8080.

To check backend is running or not enter the below URL into a browser.

http://localhost:8080/v1/todo/health

If you get output like below, then you are good to go for the next step.

STEP 2:- SETUP FrontEnd

Link: - https://github.com/dnisha/todoApp-FrontEnd.git

Pull the repository link above, after you pulled the repository the folder structure looks like the below in Visual Studio Code

Install packages by command below.

npm i --force

Run the next.js application.

npm run dev

Paste the below URL into a browser.

http://localhost:3000/v1/todo/Posts

The output should be.

Now that have our frontend, backend and database running to our local system. We are ready to containerize our application and deploy it into Kubernetes.