- β Concurrency and Resiliency Patterns in Saga Transactions for Spring Boot Microservices
- β Part 5: Reliable Long-Running Saga Processes, using Kafka and JPA Transactions with Outbox Pattern
- β Long-running Saga Processes, with dynamic recursive process steps, using Kafka and JPA Transactions with Outbox Pattern
- β Event Collaboration and Concurrency Control in Saga Transactions, using Kafka Consumer Groups, Partitions adn Transactions
- β Splitter/Aggregator Pattern for starting and aggregating Long-running Saga Process Jobs, using Kafka and JPA Transactions with Outbox Table
- β Cloud-Native Spring Boot Development and Production Environment with Spring Boot, Kafka, Kubernetes, Skaffold and Terraform
- β Reliable Asynchronous Long-Running Saga Processes with Event-Driven Kafka Transactions and Outbox Pattern
- β At-least once processing guarantee and Idempotency Key for Event Deduplication in Saga Transactions
- β Event-Driven Choreography Saga with Spring Kafka Listeners and Kafka Transactions
- β Outbox Pattern with JPA ACID Transactions
- β Synchronizing Kafka and Database Transactions with Kafka and JPA Transaction Manager
- β Handling Concurrency and Parallelization with Kafka Consumer Groups and Partitions
- β Sequential processing guarantee for messages with the same key in Kafka
- β Parallel processing for messages in different Kafka Partitions
- β Handling Resiliency with Kafka Consumers and Retryable Exceptions
- β Retryable Exceptions and Dead-Letter Queue Error Channel with Spring Kafka
- β E2E Concurrency Testing Framework with Completable Futures using Spring Cloud OpenFeign
- π This Cloud-Native Full-Stack Developer Template provides fully functional Development and Production Environment
- π Next.js and React UI
- π Event-Driven Microservices with Spring Boot, Kafka, PostgreSQL and Outbox Pattern
- π Swagger UI Gateway with Keycloak Authorization
- π Kafka UI
- π Kafka Cluster with Kubernetes Strimzi Operator
- π E2E Testing Service with Spring Cloud OpenFeign REST Client
- π Local Kubernetes Development Environment with Skaffold
- π Production Kubernetes Development Environment with Skaffold
- π Github Actions CI/CD GitOps pipeline
- π Azure Terraform Infrastructure with AKS Kubernetes Cluster and Private Container Registry
- β React UI
- β Next.js React Framework with Keycloak Authorization
- β Event-Driven Microservices with Spring Boot and Kafka
- β Spring Kafka Event Listeners
- β Synchronized Kafka and JPA Transactions for Outbox Pattern
- β Safe Idempotent Retry Transactions with Idempotency Key and At-Least Once Delivery Guarantee
- β Lookup Tables for Safe Idempotent Retries using Idempotency Key and PostgreSQL Database
- β PostgreSQL Database
- β Keycloak OAuth2 Authorization Server
- β Spring Cloud Gateway with Keycloak Authorization
- β Spring Cloud OpenFeign
- β Swagger UI with Keycloak Authorization
- β Kafka UI
- β Terraform
- β Kubernetes
- β Github Actions
- β Github Secrets and envsubst Environment Variables parser
- β Kubernetes Secrets and Configmap Variables
- β Local Kubernetes Development Environment with Skaffold
- β Production Kubernetes Development Environment with Skaffold
- β Custom Kubernetes Manfiests Generation for Local and Production Environments with sh scripts
- β Custom Skaffold Manifests Generation for Local and Production Environments with sh scripts
- β Hot reload of Next.js React Javascript code for Local and Production Environments with Skaffold
- β Hot reload of Spring Boot Java code for Local and Production Environments with Skaffold
- β Hot reload of Docker Containers for Local and Production Environments with Skaffold
- Concurrency and Resiliency Patterns in Saga Transactions for Spring Boot Microservices, Parts 1-4
- Apache Kafka for Event-Driven Spring Boot Microservices Udemy Course
- Demo Saga Pattern, Outbox Pattern using Spring Boot, Debezium, Kafka, Kafka Connect
- Stock Tracking Platform with Outbox Pattern, Kafka Event Streaming, Debezium CDC Connector and PostgreSQL
- Video Streaming Platform with Debezium CDC Kafka Connector, Kafka Event Streaming, Minio File Storage and FFmpeg Video Processing
- E2E Testing Pipeline for Spring Boot Microservices using OpenFeign Client and Github Actions
- Microservices with Node JS and React Udemy Course
- Make sure you have your own Github Account
- Clone this repository and copy the source code to your new repository
- Make sure you have your own Azure Account with enough permissions (Sign Up for a Free Trial, if you don't have one)
- Edit ".github/workflows/deploy-*.yaml" files: replace "master" with the name of your main branch (you can change default main branch name in github repository settings)
- Edit "k8s/prod/ingress-srv.yaml" file: replace "skycomposer.net" with the name of your registered domain (see Step 5 and section Azure Production Environment for more details)
- You need a registered domain to provide TLS connection with trusted Certificate Authority.
- For more details on setting up TLS on AKS Ingress with LetsEncrypt see this article: https://medium.com/@jainchirag8001/tls-on-aks-ingress-with-letsencrypt-f42d65725a3
- This article will show you how to configure TLS on AKS with LetsEncrypt for any registered domain, including AWS Route 53.
- Make sure that you know how to create Hosted Zone and Record A for your domain provider.
- For more details, see the section Azure Production Environment
-
Create local Kubernetes Cluster. If you have Docker Desktop, just go to Settings -> Kubernetes -> Enable Kubernetes -> Apply & Restart
-
Switch context to local Kubernetes Cluster. If you have Docker Desktop, just go to Kubernetes Context and select "docker-desktop"
-
create
.env.local
file inenv
folder and provide the following parameters:
CONTAINER_REGISTRY="moviebets.azurecr.io"
DOCKER_FILE_NAME="Dockerfile"
DOCKER_PUSH="false"
VERSION="latest"
BASE_URL="http://ingress-nginx-controller.ingress-nginx.svc.cluster.local"
API_BASE_URL="http://ingress-nginx-controller.ingress-nginx.svc.cluster.local/api"
KEYCLOAK_BASE_URL="http://localhost/keycloak"
- Build:
mvn clean install -DskipTests
This command will prepare java libraries for deployment
- Deploy:
sh skaffold-local.sh
This script will build docker images and start local kubernetes environment with hot reloading of your code changes
- Open
http://localhost
and test the app.
- Make sure that Keycloak
Login
andRegister
works, and you are able toCreate Movie Event
and place bet on it. - You can use credentials:
admin
/admin
for user with admin privileges and credentials:user
/user
for regular user - Any new user, registered with Keycloak, is automatically assigned regular user privileges
- Optionally, create 2 test accounts by clicking
Register
on theKeycloak Login
Page, create movie event and place bet with one account and do the same with another account. - If the winner exists at the move event close time, then the movie event is closed, and the bets start to settle by recursively triggering kafka events during settlement, until all settlement jobs are finished.
- Note: If the winner doesn't exist, then the movie event is configured to be closed later, after configurable amount of time (6Γ seconds by default)
- The winner exists only if the movie has more votes than another movie. If the votes are equal, the movie event is extended for configurable duration, until there is a winner.
- You successfuly tested
Movie Bets App
locally!
- Create
terraform.auto.tfvars
file ininfra
folder and provide following parameters:
kubernetes_version= "1.32.2"
app_name = "{provide_your_own_globally_unique_name}"
location = "westeurope" (use any other azure location, for example, "germanywestcentral", if you have any issues with "westeurope")
-
Replace
moviebets
with your own globally unique name (see filescontainer-registry.tf
,kubernetes-cluster.tf
andresource-group.tf
) -
Login to Azure Cloud with
az login
CLI -
CD to
infra
folder -
Run
terraform init
andterraform apply --auto-approve
-
After the script is successfully finished, run the following command:
az aks get-credentials --resource-group {your_app_name} --name {your_app_name}
- Make sure that your context is switched from local Kubernetes Cluster to Azure Kubernetes Cluster. If you have Docker Desktop, just open Kubernetes Context and make sure that the name of the context corresponds to your Azure Kubernetes Cluster
-
run
kubectl get pods
and make sure thatkubectl
works correctly and returns 0 resources -
Login to Azure Container registry with the following command:
docker login {login_server}
- You can find docker login server, username and password in Azure Cloud (go to Container Registry -> Settings -> Access Keys)
- In
env
folder create.env.prod
file and set the following environment variables:
CONTAINER_REGISTRY="moviebets.azurecr.io" (provide your own globally unique container registry)
DOCKER_FILE_NAME="Dockerfile"
DOCKER_PUSH="true"
VERSION="latest"
BASE_URL="https://skycomposer.net" (provide your own domain name, see `Step-05` and notes below for more details)
API_BASE_URL="https://skycomposer.net/api"
KEYCLOAK_BASE_URL="https://skycomposer.net/keycloak"
- Make sure you set your own values for CONTAINER_REGISTRY, BASE_URL, API_BASE_URL and KEYCLOAK_BASE_URL (replace
skycomposer.net
with the name of your domain)
- Register your domain and enable TLS on AKS Ingress with Lestencrypt: https://medium.com/@jainchirag8001/tls-on-aks-ingress-with-letsencrypt-f42d65725a3
- Make sure you provide your email for CA cluster issuer in
k8s/cert/cluser-issuer.yml
Kubernetes resource (see more details in the article) - You can find production Ingress Kubernetes Resource in
k8s/prod/ingress-srv.yaml
. This resource will be applied withsh skaffold-prod.sh
script. Make sure that you replacedskycomposer.net
with your registered domain name - When you run
sh skaffold-prod.sh
, you will also install ingress controller and letsencrypt kubernetes resources, described in the article, see the details inscripts/prod/prepare-k8s.sh
file
- run
sh skaffold-prod.sh
- This script will build docker images, push them to azure container registry and deploy images to production kubernetes cluster with hot reloading of your code changes
-
Run
kubectl get pods
and make sure that all containers are RUNNING -
Edit ingress
cm-acme-http-solver
, as described in the article: https://medium.com/@jainchirag8001/tls-on-aks-ingress-with-letsencrypt-f42d65725a3 -
Verify that certificate
tls-secret
is working (Ready = True, see the article for more details) -
Open https url with your registered domain in your Browser and make sure that Keycloak
Login
andRegister
works, you are able toCreate a Movie Event
and place a bet on it
- Optionally, register 2 new users, create movie event with one account and place bet with another account
- The only difference between
skaffold dev
andskaffold run
is thatskaffold dev
allows hot reloading of your code changes on production! Try to make any code change with your IDE and you will immediately see this change on production! - If you run
sh skaffold-local.sh
orsh skaffold-prod.sh
you will see logs in real-time. After closing the cli window, all kubernetes resources will be destroyed! Therefore, in order to deploy final changes to production, replaceskaffold dev
withskaffold run
in theskaffold-prod.sh
script. You will not have hot reloading withskaffold run
anymore, but kubernetes resources will not be destroyed after you close cli window.
- You successfully tested
Moive Bets App
in production!
- Create the following Github Secrets (Go to Your Repository -> Settings -> Secrets and Variables -> Actions -> New Repository Secret):
CONTAINER_REGISTRY=... (Azure Container Registry)
KUBE_CONFIG=.. (Base64 encoded ~/.kube/config file contents)
REGISTRY_UN=... (Azure Container Registry Username)
REGISTRY_PW=... (Azure Container Registry Password)
- You can find values for CONTAINER_REGISTRY, REGISTRY_UN and REGISTRY_PW in Azure Cloud (go to Container Registry -> Settings -> Access Keys)
- You can get the value of KUBE_CONFIG with this command
cat ~/.kube/config | base64
(make sure you switched context to Azure Production Kubernetes Cluster before running this command!)
-
Make any code changes (for example change
SkyComposer
toSkyComposer 2
inmoviebets-ui/components/header.js
file) -
Push changes with
git add .
,git commit -m "test changes"
andgit push origin
-
Go to "Your repository -> Actions" and make sure that the Deployment Pipeline is automatically started and successfully finished
- This pipeline will build changed docker image, push it to container registry and deploy changed image with new version to kubernetes cluster
- Open https link for your registered domain in your Browser and make sure that you can see
SkyComposer 2
title on the top left
- You successfully tested
Movie Bets App
code changes with Github Actions Deployment Pipeline!