2. FROM SPIKE
IMPLEMENT WAYS
• Spring-Cloud-Config
• Spring-Cloud-Config + MySQL
• Spring-Cloud-Config + MySQL Standalone
3. WHAT IS IT ?
SPRING-CLOUD-CONFIG
• Spring Cloud Config provides server and client-side support
for externalized configuration in a distributed system.
• With the Config Server you have a central place to manage
external properties for applications across all environments.
• The concepts on both client and server map identically to
the Spring Environment and PropertySource abstractions,
so they fit very well with Spring applications, but can be
used with any application running in any language.
• As an application moves through the deployment pipeline
from dev to test and into production you can manage the
configuration between those environments and be certain
that applications have everything they need to run when
they migrate.
• The default implementation of the server storage backend
uses git so it easily supports labelled versions of
configuration environments, as well as being accessible to
a wide range of tooling for managing the content.
• It is easy to add alternative implementations and plug them
in with Spring configuration.
7. SPRING-CLOUD-CONFIG
FIRST WAY
• file on Git repository
keep as plain files
• file name is {project-
name}-{envi}.properties
• If no set envi that means
use “default”
9. SPRING-CLOUD-CONFIG
FIRST WAY
The HTTP service has resources in the form.
• /{application}/{profile}[/{label}]
/foo/development
/ppc-service/alpha
• /{application}-{profile}.yml
• /{label}/{application}-{profile}.yml
• /{application}-{profile}.properties
• /{label}/{application}-{profile}.properties
10. SPRING-CLOUD-CONFIG
FIRST WAY
• {application} maps to "spring.application.name" on the client side;
• {profile} maps to "spring.profiles.active" on the client (comma
separated list);
• {label} which is a server side feature labelling a "versioned" set of
config files.It is an optional git label (defaults to "master".)
13. SPRING-CLOUD-CONFIG
FIRST WAY
• Add library spring-cloud-
client-config
• Add library actuator
• Set spring-project-name
• Set spring-config-server
14. SPRING-CLOUD-CONFIG
FIRST WAY
• Should run with Active
profiles (It will be set as
environment)
• Or set
“spring.profiles.active” in
properties file
• Or run ‘mvn spring-boot:run
-Drun.jvmArguments=“-
Dspring.profiles.active=pro
duction" ‘
15. SPRING-CLOUD-CONFIG
FIRST WAY
Refreshing
• The class below shows how you
can use the 'Actuator' to update
running clients with a new
configuration.
• Use @RefreshScope when we
need to change properties on the
fly
• Can’t use @RefreshScope with
@Configuration , They will
conflicted
• Use @Component instead
@Configuration for Bean creation
18. SPRING-CLOUD-CONFIG
FIRST WAY
Pro
- Can track the history of config with git repository (when, who, where)
- It already have module for management environment
- Zero down time
- Easy to setup
Con
- May be found human error editing the config with wrong
environment
- If this server have config many projects or many keyword then It’s
hard to find them
- Single point of failure
23. SPRING-CLOUD-CONFIG + MYSQL
SECOND WAY
• For Client
• Create project as a spring-boot
• Add library spring-cloud-config
• Set spring-project-name
• Set spring-config-server
24. SPRING-CLOUD-CONFIG + MYSQL
SECOND WAY
Pro
- Easy to searching the configuration with SQL script
- Use SQL (Most developers can use SQL)
- No zero down time while changing config
Con
- Single point of failure
- It’s must strict the pattern same spring cloud
- supported only spring properties (can’t keep JSON type)
- Developer should coding the client-lib (Can resolved it with spring cloud)
- When accident configuration changed It need DBA to find the root cause
- Need admin report to changing configuration
27. SPRING-CLOUD-CONFIG + MYSQL (STNLN)
THIRD WAY
• Add library spring-cloud-
client-config
• Add library actuator
• Set spring-project-name
• Set spring-config-server :
Itself URI
29. SPRING-CLOUD-CONFIG + MYSQL (STNLN)
THIRD WAY
Pro
- Config each application
- Use SQL (Most developers can use SQL)
- No zero down time while changing config
Con
- Detour calling method update config
- Application push effort to find the configuration from database
- Need same table fix in database for each applications
- When accident configuration changed It need DBA to find the root cause
- Need admin report to changing configuration
30. WHY NOT
CAN ALL CONFIGS ARE EXTERNAL?
• Try to find a victim project
• Set config server
• Set name of application
• delete spring.datasource.url
31. WHY NOT
CAN ALL CONFIGS ARE EXTERNAL?
• Add spring.datasource.url in
Database for server
• Run!
• Client will get data from server
first
• If key is required,and
you didn’t set then application
will be got error same key in
properties is not found
• Can’t change database.url on
the fly(need restart)
32.
33. YES
CAN ALMOST KEYS GET FROM SERVER?
• Remain keys at least
• Some keys can not load from
server
• Some keys use as bootstrap