{"id":26580094,"url":"https://github.com/kuldeepsingh99/spring-cloud-gateway","last_synced_at":"2025-03-23T06:30:26.466Z","repository":{"id":210589611,"uuid":"322249983","full_name":"kuldeepsingh99/spring-cloud-gateway","owner":"kuldeepsingh99","description":"Spring Cloud Gateway with Keycloak for Access and Identity Management and Resilience4j for fault tolerance and resiliency, Prometheus and grafana for monitoring, jaeger for distributed tracing on kubernetes","archived":false,"fork":false,"pushed_at":"2021-03-08T05:03:49.000Z","size":1451,"stargazers_count":19,"open_issues_count":0,"forks_count":19,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-12-03T22:22:06.990Z","etag":null,"topics":["api-gateway","circuit-breaker","gateway","grafana","jaeger","jaegertracing","keycloak","keycloak-configuration","kubernetes","kubernetes-deployment","loki","microservice","prometheus","resilience4j","resilliency","spring-boot","spring-cloud-gateway"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kuldeepsingh99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-12-17T09:49:50.000Z","updated_at":"2023-12-03T22:22:09.069Z","dependencies_parsed_at":"2023-12-03T22:32:13.780Z","dependency_job_id":null,"html_url":"https://github.com/kuldeepsingh99/spring-cloud-gateway","commit_stats":null,"previous_names":["kuldeepsingh99/spring-cloud-gateway"],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepsingh99%2Fspring-cloud-gateway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepsingh99%2Fspring-cloud-gateway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepsingh99%2Fspring-cloud-gateway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kuldeepsingh99%2Fspring-cloud-gateway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kuldeepsingh99","download_url":"https://codeload.github.com/kuldeepsingh99/spring-cloud-gateway/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245066496,"owners_count":20555402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-gateway","circuit-breaker","gateway","grafana","jaeger","jaegertracing","keycloak","keycloak-configuration","kubernetes","kubernetes-deployment","loki","microservice","prometheus","resilience4j","resilliency","spring-boot","spring-cloud-gateway"],"created_at":"2025-03-23T06:30:25.589Z","updated_at":"2025-03-23T06:30:26.431Z","avatar_url":"https://github.com/kuldeepsingh99.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Cloud Gateway with Resilience4j and Keycloak Integration\n\n![Architecture](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/img/arch.PNG)\n\n## This project contains 4 Spring boot Projects and Keycloak for access and identity management\n\n* [Gateway](https://github.com/kuldeepsingh99/spring-cloud-gateway/tree/main/gateway)  - (This is an API Gateway, where spring cloud gateway is used with Resilience4j and keycloak integration)\n* [Micro Service 1](https://github.com/kuldeepsingh99/spring-cloud-gateway/tree/main/ms1)  - (This is a reative microservice where Resilience4j patterns are implemented with keycloak integration)\n* [Micro Service 2](https://github.com/kuldeepsingh99/spring-cloud-gateway/tree/main/ms2)  - (This is a reative microservice)\n* [Micro Service 3](https://github.com/kuldeepsingh99/spring-cloud-gateway/tree/main/ms3)  - (This is a reative microservice)\n\n## Libraries and Tech Stack\n\n* [Spring Cloud Gateway](https://spring.io/projects/spring-cloud-gateway) - as an API Gateaway\n* [Resilience4j](https://resilience4j.readme.io/docs) - for resilience patterns\n* [Spring Boot](https://spring.io/projects/spring-boot) - to build microservices\n* [Keycloak](https://www.keycloak.org/) - for identity and access managment\n* [Jaeger](https://www.jaegertracing.io/) - for distributed tracing\n* [Prometheus](https://prometheus.io/) - for monitoring\n* [Grafana](https://grafana.com/) - for monitoring\n* [Loki](https://grafana.com/docs/loki/latest/getting-started/get-logs-into-loki/) - for log monitoring\n\n## GateWay and Microservice Configuration\n\nPlease refer [Keycloak](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/gateway/keycloak.md) readme Keycloak configuration\n\nPlease refer [Gateway](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/gateway/README.md) readme for Spring Cloud Gateway, Resilience4j and Keycloak configuration\n\nPlease refer [Micro service 1](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/ms1/README.md) readme for Resilience4j and Keycloak configuration\n\nPlease refer [Grafana](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/grafana.md) how to configure datasources\n\nPlease refer [Prometheus](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/prometheus.md) for prometheus details\n\nPlease refer [Jaeger](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/jaeger.md) for jaeger details\n\n## Deployment \n\nWe have deployed everything on [kubernetes](https://kubernetes.io/)\n\n## Steps for Deployment\n\n#### Creating NameSpace\n\nExecute this [file](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/namespace.yml) to create namespace\n\n```kubectl apply -f namespace.yml```\n\n#### Create redis Instance\n\nExecute this [file](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/redis.yml) to create redis instance\n\n```kubectl apply -f redis.yml```\n\n\n#### Create NGINX Ingress Controller\n\nExecute this to deploy NGINX Ingress controller\n\n```kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/aws/deploy.yaml```\n\nVerify pod progress\n\n```kubectl get pods -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx --watch```\n\n#### Install Prometheus\n\nExecute this command to deploy prometheus\n\n```\nhelm repo add stable https://kubernetes-charts.storage.googleapis.com/\nhelm repo update\n```\n\n```helm install -name prom -n monitor stable/prometheus-operator```\n\nExecute this [file](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/promingress.yml) to setup ingress for Prometheus\n\n```kubectl apply -f promingress.yml```\n\nVerify pod progress\n\n```kubectl get pods -n monitor```\n\nTry accessing Prometheus with http://prometheus.practice.com\n\n#### Install Grafana\n\nExecute this command to deploy Grafana\n\n```helm install -name graph -n monitor stable/grafana```\n\nExecute this [file](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/grafanaingress.yml) to setup ingress for Grafana\n\n```kubectl apply -f grafanaingress.yml```\n\nTry accessing Grafana with http://grafana.practice.com\n\n#### Install Jaeger\n\nExecute the following command\n\n```\nkubectl create -n monitor -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/crds/jaegertracing.io_jaegers_crd.yaml\nkubectl create -n monitor -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/service_account.yaml\nkubectl create -n monitor -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/role.yaml\nkubectl create -n monitor -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/role_binding.yaml\nkubectl create -n monitor -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/operator.yaml\n```\n\nExecute this [file](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/jaeger_new.yml) to deploy jaeger\n\n```kubectl apply -f jaeger_new.yml```\n\nExecute this [file](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/jaegeringress.yml) to setup ingress for jaeger\n\n```kubectl apply -f jaegeringress.yml```\n\nVerify pod progress\n\n```kubectl get pods -n monitor```\n\nTry accessing jaeger with http://jaeger.practice.com\n\n#### Create Keycloak Instance\n\nExecute this [file](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/keycloak.yml) to setup keycloak\n\n```kubectl apply -f keycloak.yml```\n\nExecute this [file](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/keycloakingress.yml) to setup keycloak Ingress controller\n\n```kubectl apply -f keycloakingress.yml```\n\nNote :- After Keycload is up and Running create realm and configure client\n\n\n#### Create Gateway Instance\n\nExecute this [gateway](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/gateway.yml) file to create gateway instance\n\n```kubectl apply -f gateway.yml```\n\nExecute this [gateway ingress](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/gatewayingress.yml) file to create gateway ingress\n\n```kubectl apply -f gatewayingress.yml```\n\nTry accessing http://test.practice.com\n\nHow Prometheus know where to scrap prometheus end, we need to create service monitor\n\nExecute this [gateway service monitor](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/gatewayservicemonitor.yml) file to create gateway service monitor\n\n```kubectl apply -f gatewayservicemonitor.yml```\n\nCheck the target in Prometheus\n\n#### Create Microservices instance\n\nExecute this [micro service 1 config map](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/ms1configmap.yml) file to create config Map for micro service 1, this is used to inject other service URL and Port\n\nWe can create config map based on environment and we don't have to change code on different envoronments \n\n```kubectl apply -f ms1configmap.yml```\n\nExecute this [micro service 1](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/ms1.yml) file to create micro service 1 instance\n\n```kubectl apply -f ms1.yml```\n\nExecute this [micro service 2](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/ms2.yml) file to create micro service 2 instance\n\n```kubectl apply -f ms2.yml```\n\nExecute this [micro service 3](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/ms3.yml) file to create micro service 3 instance\n\n```kubectl apply -f ms3.yml```\n\nVerify pod progress\n\n```kubectl get pods -n monitor```\n\nCreate service Monitor for these services [micro service 1](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/ms1servicemonitor.yml), [micro service 2](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/ms2servicemonitor.yml) and [micro service 3](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/deployment/ms3servicemonitor.yml)\n\n\n```\nkubectl apply -f ms1servicemonitor.yml\nkubectl apply -f ms2servicemonitor.yml\nkubectl apply -f ms3servicemonitor.yml\n```\n\nVerify the Target in Prometheus\n\n#### Loki\n\n[Loki](https://grafana.com/oss/loki/) is a log aggregation system inspired by Prometheus.\n\nExcecute this command to install loki\n\n```\nhelm repo add loki https://grafana.github.io/loki/charts\nhelm repo update\nhelm install loki-stack loki/loki-stack --namespace monitor --set promtail.enabled=true,loki.persistence.enabled=true,loki.persistence.size=1Gi\n```\n\n#### Pods\n![](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/img/pod.PNG)\n\n#### Service\n![](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/img/svc.PNG)\n\n#### Service Monitor\n![](https://github.com/kuldeepsingh99/spring-cloud-gateway/blob/main/img/servicemonitor.PNG)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuldeepsingh99%2Fspring-cloud-gateway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkuldeepsingh99%2Fspring-cloud-gateway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkuldeepsingh99%2Fspring-cloud-gateway/lists"}