develop
Spring Cloud Config
레이니블루
2023. 5. 1. 08:37
Spring 환경에서 여러 환경 별 설정을 관리하기 위해서 Spring Cloud Config 를 사용하면 여러 장점이 있습니다. 중앙화된 하나의 한경에서 설정을 한꺼번에 관리한다던가, Spring Boot Actuator의 refresh endpoint를 이용해서 서비스 배포 없이 Bean을 재설정 할 수 있습니다.
하지만 Spring Cloud Config도 Kubernetes의 환경에서 대체되는 기능이 되었고, Cloud Native에서는 더 좋은 방법이 존재합니다.
- Kubernetes Configuration Management Options (exoscale.com)
- Chapter 11. Integrating Spring Boot with Kubernetes Red Hat Fuse 7.10 | Red Hat Customer Portal
Spring Cloud Config는 전통적으로 사용하던 Spring의 Profile의 위치를 별도의 서버를 이용해서 사용할 수 있게 해 줍니다. 하지만, Kubernetes에서 ConfigMap을 이용해서 여러 다른 설정값을 사용할 수 있기 때문에 굳이 Profile을 사용할 필요가 없습니다.
위의 Link에 있는 Spring Service 설정에 대한 장단점은 다음과 같습니다.
Pro | Con | |
Profiles | Spring native | A new environment requires updating the application and rebuilding the image |
Command-line parameters | Externalized | Need to override the Docker image entry-point |
Environment variables | Easy to setup | Not consistent across related key-value pairs |
Config map | Kubernetes native | No versioning |
Shared volumes with Git | The best money can buy | Complex setup |
제가 개발하고 있는 서비스에서는 Config map 자체를 별도의 버전 관리를 하고 있기 때문에 위의 단점에 해당되지는 않네요.