More Related Content
Similar to Living on the Edge With Spring Cloud Gateway - Cora Iberkleid (20)
More from VMware Tanzu (20)
Living on the Edge With Spring Cloud Gateway - Cora Iberkleid
- 1. Living on the Edge
with Spring Cloud Gateway
Cora Iberkleid
@ciberkleid
SpringOne Tour 2019
- 2. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Agenda
● API Gateway Basics
● Spring Cloud Gateway
● Design Considerations
● Demo 1 - App Concerns
○ Discovery & circuit breaker
● Demo 2 - Enterprise Concerns
○ Auth, rate limits, & service broker
- 3. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway Basics
- 4. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
What Is An API Gateway?
Server Side
MVC App
Microservice A
JS or Mobile
App
Microservice B
Microservice C
- 5. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
What Is An API Gateway?
Server Side
MVC App
Microservice A
JS or Mobile
App
Microservice B
Microservice C
Gateway
- 6. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway Responsibilities
● Routing
● Security
● Monitoring
● Canarying
● Monolith Strangling
● Resiliency
- 7. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud Gateway Basics
- 8. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud Gateway Foundations
- 9. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Reactive Gateway
- 10. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway Flow
Client Predicates Pre-Filters Global Filters
Post-Filters
Downstream
Service
Gateway
Handler Mapping Web Handler
- 11. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway
Gateway Flow
Client Predicates Pre-Filters Global Filters
Post-Filters
Downstream
Service
Handler Mapping Web Handler
Predicates
● Path
● Host
● Date/Time
● Method
● Headers
● Query Params
● Cookies
● Read Body
● Anything….
- 12. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway
Gateway Flow
Client Predicates Pre-Filters Global Filters
Post-Filters
Downstream
Service
Handler Mapping Web Handler
Pre-Filters
● Headers
● Path
● Rate Limiting
● Cookies
● Hystrix
● Modify Body
● Anything
- 13. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway
Gateway Flow
Client Predicates Pre-Filters Global Filters
Post-Filters
Downstream
Service
Handler Mapping Web Handler
Global Filters
● Netty Router
● Web Sockets
● Load Balancer
● Metrics
- 14. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Gateway
Gateway Flow
Client Predicates Pre-Filters Global Filters
Post-Filters
Downstream
Service
Handler Mapping Web Handler
Post Filters
● Set status
● Headers
● Cookies
● Anything...
- 15. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Design Considerations
- 16. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
App
Embedded
Gate
way
Sample Use Case
● When latency is essential - no added network hops
- 17. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Embedded
App
Sample Use Case
● Fine-grained access control for pay-per-use
service or fragile backing service
App
Gate
way App
Gate
way App
Gate
way
App
- 18. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Facade
Gateway AppClient
Sample Use Cases
● Prevent direct access to apps
● Polyglot compatible
- 19. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Facade
Gateway App BClient
Sample Use Cases
● Cross-cutting concerns
● Present common API to clients
● Shield clients from app refactoring
(monolith → microservices)
App C
App A
- 20. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Cross-Cutting + App-Specific
App-Specific
Gateway
App B
Client
Sample Use Cases
● Delegate cross-cutting concerns to a separate
common gateway (and a separate dev team!)
App C
App A
App-Specific
Gateway
App E
App F
App D
Common
Gateway
- 21. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Demo Part I:
Spring Cloud Gateway
Photo Credit: Aerosmith, Living On The Edge
- 22. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Demo (Logical)
Blue
Service
Green
Service
Frontend
App
- 23. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Demo Architecture
Gateway Blue
Service
Green
Service
Frontend
App
Service
Discovery
(Eureka)
1
2
3
- 24. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Demo Architecture
Gateway Blue
Service
Green
Service
Frontend
App
Service
Discovery
(Eureka)
Yellow
Service
1
2
3
- 25. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Demo Part II:
Gateway On Cloud Foundry
- 26. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
User Stories - Subscription SLA Management
● As a consumer, I want features in accordance with my subscription.
● As a developer, I want to focus on my app.
● As a product owner, I want to ensure a consistent and unified consumer experience.
● As an operator, I want the the solution to be resilient and scalable.
- 27. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
configs:
- name: trial
replenishRate: 2
burstCapacity: 2
- name: basic
replenishRate: 10
burstCapacity: 15
- name: premium
replenishRate: 50
burstCapacity: 100
Consumers… need subscriptions
Trial
Basic
Premium
- 28. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Developers want…
Aut t a n
Aut za
Rat i n
Req En i h t
Req For d
…as a service
- 29. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Product Owners want… consistency
Open Service
Broker API
Instances
Bindings
Catalog
- 30. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Operators want… resilience and scalability
3
0

Rate Limiters
(Redis)
Service
Instance Info
(MongoDB)
Service Broker + Gateway
- 31. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
To the demo...
- 32. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Recap
● API Gateway Basics
● Spring Cloud Gateway
● Design Considerations
● Demo 1 - App Concerns
○ Discovery & circuit breaker
● Demo 2 - Enterprise Concerns
○ Auth, rate limits, & service broker
- 33. Unless otherwise indicated, these slides are © 2013-2018 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license:
http://creativecommons.org/licenses/by-nc/3.0/
Q&A
Spring Cloud Gateway: https://github.com/spring-cloud/spring-cloud-gateway
Session Code: https://github.com/ryanjbaxter/gateway-s1p-2018