Skip to content

Latest commit

 

History

History
212 lines (120 loc) · 8.68 KB

README.md

File metadata and controls

212 lines (120 loc) · 8.68 KB

Spring Cloud Gateway with Resilience4j and Keycloak Integration

Architecture

This project contains 4 Spring boot Projects and Keycloak for access and identity management

  • Gateway - (This is an API Gateway, where spring cloud gateway is used with Resilience4j and keycloak integration)
  • Micro Service 1 - (This is a reative microservice where Resilience4j patterns are implemented with keycloak integration)
  • Micro Service 2 - (This is a reative microservice)
  • Micro Service 3 - (This is a reative microservice)

Libraries and Tech Stack

GateWay and Microservice Configuration

Please refer Keycloak readme Keycloak configuration

Please refer Gateway readme for Spring Cloud Gateway, Resilience4j and Keycloak configuration

Please refer Micro service 1 readme for Resilience4j and Keycloak configuration

Please refer Grafana how to configure datasources

Please refer Prometheus for prometheus details

Please refer Jaeger for jaeger details

Deployment

We have deployed everything on kubernetes

Steps for Deployment

Creating NameSpace

Execute this file to create namespace

kubectl apply -f namespace.yml

Create redis Instance

Execute this file to create redis instance

kubectl apply -f redis.yml

Create NGINX Ingress Controller

Execute this to deploy NGINX Ingress controller

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/aws/deploy.yaml

Verify pod progress

kubectl get pods -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx --watch

Install Prometheus

Execute this command to deploy prometheus

helm repo add stable https://kubernetes-charts.storage.googleapis.com/
helm repo update

helm install -name prom -n monitor stable/prometheus-operator

Execute this file to setup ingress for Prometheus

kubectl apply -f promingress.yml

Verify pod progress

kubectl get pods -n monitor

Try accessing Prometheus with http://prometheus.practice.com

Install Grafana

Execute this command to deploy Grafana

helm install -name graph -n monitor stable/grafana

Execute this file to setup ingress for Grafana

kubectl apply -f grafanaingress.yml

Try accessing Grafana with http://grafana.practice.com

Install Jaeger

Execute the following command

kubectl create -n monitor -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/crds/jaegertracing.io_jaegers_crd.yaml
kubectl create -n monitor -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/service_account.yaml
kubectl create -n monitor -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/role.yaml
kubectl create -n monitor -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/role_binding.yaml
kubectl create -n monitor -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/operator.yaml

Execute this file to deploy jaeger

kubectl apply -f jaeger_new.yml

Execute this file to setup ingress for jaeger

kubectl apply -f jaegeringress.yml

Verify pod progress

kubectl get pods -n monitor

Try accessing jaeger with http://jaeger.practice.com

Create Keycloak Instance

Execute this file to setup keycloak

kubectl apply -f keycloak.yml

Execute this file to setup keycloak Ingress controller

kubectl apply -f keycloakingress.yml

Note :- After Keycload is up and Running create realm and configure client

Create Gateway Instance

Execute this gateway file to create gateway instance

kubectl apply -f gateway.yml

Execute this gateway ingress file to create gateway ingress

kubectl apply -f gatewayingress.yml

Try accessing http://test.practice.com

How Prometheus know where to scrap prometheus end, we need to create service monitor

Execute this gateway service monitor file to create gateway service monitor

kubectl apply -f gatewayservicemonitor.yml

Check the target in Prometheus

Create Microservices instance

Execute this micro service 1 config map file to create config Map for micro service 1, this is used to inject other service URL and Port

We can create config map based on environment and we don't have to change code on different envoronments

kubectl apply -f ms1configmap.yml

Execute this micro service 1 file to create micro service 1 instance

kubectl apply -f ms1.yml

Execute this micro service 2 file to create micro service 2 instance

kubectl apply -f ms2.yml

Execute this micro service 3 file to create micro service 3 instance

kubectl apply -f ms3.yml

Verify pod progress

kubectl get pods -n monitor

Create service Monitor for these services micro service 1, micro service 2 and micro service 3

kubectl apply -f ms1servicemonitor.yml
kubectl apply -f ms2servicemonitor.yml
kubectl apply -f ms3servicemonitor.yml

Verify the Target in Prometheus

Loki

Loki is a log aggregation system inspired by Prometheus.

Excecute this command to install loki

helm repo add loki https://grafana.github.io/loki/charts
helm repo update
helm install loki-stack loki/loki-stack --namespace monitor --set promtail.enabled=true,loki.persistence.enabled=true,loki.persistence.size=1Gi

Pods

Service

Service Monitor