Skip to content

mcruzdev/pizza-quarkus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloud-Native Pizza Delivery system

This repository contains a simple example for a Pizza Store application using Kubernetes, Dapr and Testcontainers with Quarkus to enable developers with an awesome developer experience.

This repository is a copy of the https://github.com/salaboy/pizza repository, rewritten using Quarkus.

testcontainers-dapr-and-quarkus-logo

You can run this application on any Kubernetes cluster by following the step-by-step insturctions described in this document.

Installation

If you don't have a Kubernetes Cluster you can install KinD to create a local cluster to run the application.

Once you have KinD installed you can run the following command to create a local Cluster:

kind create cluster

Then we will install Dapr into our fresh new cluster by running the following command:

helm repo add dapr https://dapr.github.io/helm-charts/
helm repo update
helm upgrade --install dapr dapr/dapr \
--version=1.12.0 \
--namespace dapr-system \
--create-namespace \
--wait

Installing infrastructure for the application

We will be using Kafka for sending messages between services:

helm install kafka oci://registry-1.docker.io/bitnamicharts/kafka --version 22.1.5 --set "provisioning.topics[0].name=events-topic" --set "provisioning.topics[0].partitions=1" --set "persistence.size=1Gi" 

We will be using PostgreSQL as our persistent store, but before installing the PostgreSQL Chart run:

kubectl apply -f k8s/pizza-init-sql-cm.yaml

Then:

helm install postgresql oci://registry-1.docker.io/bitnamicharts/postgresql --version 12.5.7 --set "image.debug=true" --set "primary.initdb.user=postgres" --set "primary.initdb.password=postgres" --set "primary.initdb.scriptsConfigMap=pizza-init-sql" --set "global.postgresql.auth.postgresPassword=postgres" --set "primary.persistence.size=1Gi"

Installing the Application

To install the application you only need to run the following command:

kubectl apply -f k8s/

This install all the application services. To avoid dealing with Ingresses you can access the application by using kubectl port-forward, run to access the application on port 8080:

kubectl port-forward svc/pizza-store 8080:80

Then you can point your browser to http://localhost:8080 and you should see:

Pizza Store

Building from source / changing the services

The application services are written using Java + Quarkus. These services use the Dapr Extension to interact with the Dapr PubSub and Statestore APIs.

To run the services locally you can use the Testcontainer integration already included in the projects.

For example you can start a local version of the pizza-store service by running the following command inside the pizza-store/ directory (this requires having Java and Maven installed locally):

quarkus dev

This, not only start the pizza-store service, but it also uses the Testcontainers + Dev Services for Dapr integration to configure and wire up a Dapr configuration for local development. In other words, you can now use Dapr outside of Kubernetes, for writing your service tests without the need to know how Dapr is configured.

Once the service is up, you can place orders and simulate other events coming from the Kitchen and Delivery services by sending HTTP requests to the /events endpoint.

Using httpie this look like this:

http :8080/events Content-Type:application/cloudevents+json < pizza-store/event-in-prep.json

In the Application you should see the event recieved that the order moving forward.

Resources and references

Feedback / Comments / Contribute

Feel free to create issues or get in touch with us using Issues or via Twitter @Salaboy

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published