KubernetesSeries

If you have any questions or encounter any issues, feel free to leave a comment below! I’ll respond or update the content accordingly. “:)”

🚀 Table of Contents

  1. ➡️ Create a Spring Boot Project
  2. Dockerize the Application
  3. Deploy to Kubernetes (NodePort)
  4. Configure Ingress Routing
  5. Install Local GitLab
  6. Connect Git to GitLab
  7. Install ArgoCD
  8. Create ArgoCD Application
  9. Setup GitOps Flow
  10. Setup GitLab Runner
  11. Auto Image Tag & Sync

✅ Step 1: Create a Spring Boot Project using start.spring.io

In this step, we’ll create a basic Spring Boot application using Spring’s official initializer website.
This application will be used later to containerize with Docker and deploy to Kubernetes.


🧱 1.1 Generate the Project

Go to 👉 https://start.spring.io

Fill in the form with the following configuration:

image-20250727203702836

Then, click Generate to download the .zip file.
Unzip it and open the folder in your terminal or IDE.

image-20250727203811535


🧪 1.2 Run the Project

In terminal, navigate to the project directory and run:

cd k8sdemo
./mvnw spring-boot:run

image-20250727204050982

image-20250727204016531

✨ 1.3 Add /hello Endpoint

Open the main application file src/main/java/com/example/k8sdemo/K8sdemoApplication.java and update it as follows:

package com.example.k8sdemo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class K8sdemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(K8sdemoApplication.class, args);
    }

    @GetMapping("/hello")
    public String hello() {
        return "Hello, Kubernetes!";
    }
}

Now restart the application and access the endpoint:

cd k8sdemo
./mvnw spring-boot:run

Now restart the application and access the endpoint:

curl http://localhost:8080/hello

You should see the response:

Hello, Kubernetes!

image-20250727210924232

This confirms your Spring Boot REST endpoint is working as expected.

top

댓글남기기