Spring microservices · mid
Gateway, configuration and service discovery
A gateway routes and protects traffic at the edge. Configuration comes from Git, ConfigMaps or a secrets manager. In Kubernetes use native services for discovery.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- A gateway route has an id, a destination (a URL or
lb://service-name), predicates (path, host, header, method) and filters. - Spring Cloud Gateway has a reactive server (WebFlux and Netty) and a servlet server on Spring MVC.
- Gateway jobs: routing, TLS, a first token check, rate limiting (Redis-backed
RequestRateLimiter), CORS, request ids, removing internal headers. Services still check authorisation themselves. - Set per-route response timeouts and circuit breakers: a slow backend ties up gateway connections.
- Config Server: backed by Git, versioned per application and profile, loaded with
spring.config.import=configserver:.... - Kubernetes ConfigMaps and Secrets are mounted as files or environment variables. Changes usually need a restart or reload.
- Secrets belong in a secrets manager (Vault, AWS Secrets Manager, Azure Key Vault) through Spring Cloud Vault or the External Secrets Operator.
- Live refresh:
@RefreshScopebeans and@ConfigurationPropertiesare rebound on/actuator/refreshor a bus event. Audit: Git history for config, the secrets manager's access log for secrets. Eureka: services register and send heartbeats; clients pick an instance (Spring Cloud LoadBalancer,lb://orders). Kubernetes: a Service gives a stable DNS name and spreads traffic across ready pods. Inside Kubernetes prefer native Services and drop Eureka. Long-lived connections (HTTP/2, gRPC) are not spread well by a plain ClusterIP Service.
The red pen
Common traps: mistake → fix
Mistake: The gateway can replace service-level authorisation
Fix: services must check too.
Mistake: Secrets can live in Git config
Fix: use a secrets manager.
Mistake: Eureka is needed on Kubernetes
Fix: Kubernetes Services already do discovery.
Easy to hard
Questions interviewers ask, easy to hard
- What does Spring Cloud Gateway do and what should stay in services?
- Config Server, ConfigMaps or Vault for 15 services?
- Keep Eureka or use Kubernetes services?
- How does a config change reach running pods?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.