Skip to content

bottled-lightning/better-adventure

Repository files navigation

Kitchensink Quickstart - Migrated to Quarkus with MongoDB

This project demonstrates the migration of the JBoss EAP Kitchensink quickstart application to Quarkus with MongoDB as the database.

  1. Updated the pom.xml to use Quarkus dependencies and build plugins
  2. Replaced XML configuration files with Quarkus application.properties
  3. Updated CDI components to use Quarkus-compatible annotations
  4. Migrated from JPA/Hibernate to MongoDB with Panache
  5. Replaced JSF web interface with Quarkus Qute templates
  6. Created new Quarkus-compatible tests using REST Assured
  7. Added embedded MongoDB support for development and testing
  8. Added Kubernetes deployment support with dev mode capabilities

Notes

  • prompts.txt includes some of the original prompts I used for various migrations
  • analyze-project.ps1 is a PowerShell script that analyzes the project and outputs guidance into the analysis folder

Project Structure

  • src/main/java/model - MongoDB entity classes
  • src/main/java/data - MongoDB repository classes
  • src/main/java/service - Service classes
  • src/main/java/rest - REST endpoints
  • src/main/java/config - Configuration classes including MongoDB lifecycle management
  • src/main/resources/templates - Qute templates for the web interface
  • src/main/resources/META-INF/resources - Static resources (CSS, images)

Development Mode

Local Development with Embedded MongoDB

./mvnw quarkus:dev

This command:

  • Starts the application in development mode with live coding enabled
  • Automatically starts an embedded MongoDB instance on port 27017
  • Initializes the database with sample data
  • No external MongoDB installation is required

The embedded MongoDB is managed by the MongoConfig class, which starts MongoDB when the application starts and stops it when the application stops.

Kubernetes Development Mode

To run the application in development mode on Kubernetes:

./mvnw quarkus:dev -Dquarkus.profile=kube-dev

This command:

  • Starts the application in development mode with the kube-dev profile
  • Automatically starts an embedded MongoDB instance on port 27017 (same as local dev mode)
  • Enables live coding while running in a Kubernetes environment
  • No external MongoDB instance is required

Production Mode

Local Production Mode

./mvnw package
java -jar target/quarkus-app/quarkus-run.jar

For native executable:

./mvnw package -Dnative
./target/modernized-kitchensink-1.0.0-SNAPSHOT-runner

Kubernetes Deployment

To deploy the application to Kubernetes:

  1. Build the application and container image:

    ./mvnw clean package -DskipTests
    ./mvnw quarkus:container-image-build
  2. Apply the Kubernetes manifests:

    kubectl apply -k kubernetes/

Alternatively, use the provided deployment script:

  • On Windows: .\deploy-to-kubernetes.ps1
  • On Linux/macOS: ./deploy-to-kubernetes.sh

The script will:

  1. Build the application
  2. Create a container image
  3. Create the necessary Kubernetes resources
  4. Wait for the deployments to be ready

Testing the Application

Running Tests

./mvnw test

Manual Testing

  1. Access the web interface at http://localhost:8080/kitchensink/
  2. Register a new member using the form
  3. View the list of members
  4. Access the REST API at http://localhost:8080/kitchensink/rest/members

MongoDB Configuration

  1. Development Mode: Uses embedded MongoDB

    %dev.quarkus.mongodb.devservices.enabled=true
    %dev.quarkus.mongodb.database=kitchensink-dev
    
  2. Kubernetes Development Mode: Uses embedded MongoDB (same as local dev mode)

    %kube-dev.quarkus.mongodb.devservices.enabled=true
    %kube-dev.quarkus.mongodb.devservices.port=27017
    %kube-dev.quarkus.mongodb.database=kitchensink-dev
    
  3. Production Mode: Uses an external MongoDB instance

    %prod.quarkus.mongodb.connection-string=mongodb://localhost:27017
    %prod.quarkus.mongodb.database=kitchensink
    

For more details, see the application.properties file.

Kubernetes Resources

The application includes the following Kubernetes resources:

  1. Deployment: Manages the application pods
  2. Service: Exposes the application within the cluster
  3. ConfigMap: Stores configuration values (including the profile setting)
  4. Ingress: Exposes the application externally

All resources are defined in the kubernetes/ directory and can be applied using kubectl apply -k kubernetes/.

Note: Unlike the production deployment, the Kubernetes dev mode uses embedded MongoDB just like local development, so no separate MongoDB deployment is needed.

Key Differences from JBoss EAP Version

  1. Database: Uses MongoDB instead of a relational database
  2. Startup Time: Quarkus offers significantly faster startup times
  3. Memory Usage: Lower memory footprint compared to JBoss EAP
  4. Development Experience: Live coding with near-instant feedback and embedded MongoDB
  5. Native Compilation: Option to compile to native code for even better performance
  6. Configuration: Simplified configuration with application.properties instead of XML files
  7. Web Interface: Uses Qute templates instead of JSF
  8. Kubernetes Support: Built-in support for Kubernetes deployment and development

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors