Skip to content

hunglp9397/spring-microservices-full

Repository files navigation

SPRING MICROSERVICES FULL

1. Part-1 : Base service

  • Init base service : Product Service, Order Service, Inventory Service

2. Part-2 : Communicate service

3. Part-3 : Service Discovery

4. Part-4 : Api gateway

5. Part-5 : Security keycloak

 docker run -p 8181:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:18.0.0 start-dev
  • Truy cập url : localhost:8181
  • Đăng nhập keycloack : admin/admin 1
  • Tạo realm: 2
  • Tạo client với tên : spring-cloud-client 2
  • Setting client như sau: 2
  • Sau khi save setting client. Tại tab Credentials, copy giá trị secret: zF3mUlEVRk7FFIocet3py6u98R3TxGAi 2
  • Tại Realme settings, Tại mục endPoints, bấm vào link OpenID Endpoint Configuration 2
  • Copy giá trị issuer paste vào applications.properties của api-gateway 2
    spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:8181/realms/springboot-microservices-full-realm
  • Test Authen của api:
    • Gọi api get all product thông qua api gateway: 2 Trong hình trên thì giá trị của accces-token-url là : http://localhost:8181/realms/springboot-microservices-full-realm/protocol/openid-connect/token
    • Authen thành công: 2 ( Lưu ý : Khi bị Unauthorized(sau 300ms) thì bấm vào "Get new acccess token" Rồi sau đó "Use token" để refresh lại access_token để dùng lại )
    • Một ví dụ khác, TEST api Create Order thông qua api-gateway
      • Trường hợp ko dùng authen: 2
      • Khi authen token, tạo order thành công: 2

6. Part-6 : Circuit-breaker (bỏ qua)

7. Part-7 : Distributed-tracing (bỏ qua)

  • Chỉ cần chạy container: docker run -d -p 9411:9411 openzipkin/zipkin

8. Part-8 : Event driven Kafka

  • Tạo file docker-compose.yaml để run instance kafka : docker compose up -d

9. Part-9 : Dockerize

  • api-gateway-images : docker build -t apigateway-dockerfile .

About

Spring microservices, K8S, Kafka, Prometheus

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors