This commit is contained in:
Marcin Grzejszczak
2023-09-08 16:59:24 +02:00
committed by spencergibb
parent b5fa7dcac0
commit 10a5f611c0
22 changed files with 435 additions and 158 deletions

View File

@@ -39,7 +39,3 @@
** xref:spring-cloud-config/client.adoc[]
* xref:intro.adoc[]
* xref:quickstart.adoc[]
* xref:_observability.adoc[]
* xref:README.adoc[]
* xref:_configprops.adoc[]
* xref:sagan-index.adoc[]

View File

@@ -1,86 +0,0 @@
image::https://circleci.com/gh/spring-cloud/spring-cloud-config/tree/master.svg?style=svg["CircleCI", link="https://circleci.com/gh/spring-cloud/spring-cloud-config/tree/master"]
image::https://codecov.io/gh/spring-cloud/spring-cloud-config/branch/master/graph/badge.svg["Codecov", link="https://codecov.io/gh/spring-cloud/spring-cloud-config/branch/master"]
image::https://api.codacy.com/project/badge/Grade/f064024a072c477e97dca6ed5a70fccd?branch=master["Codacy code quality", link="https://www.codacy.com/app/Spring-Cloud/spring-cloud-config?branch=master&utm_source=github.com&utm_medium=referral&utm_content=spring-cloud/spring-cloud-config&utm_campaign=Badge_Grade"]
[[features]]
= Features
[[spring-cloud-config-server]]
== Spring Cloud Config Server
Spring Cloud Config Server offers the following benefits:
* HTTP resource-based API for external configuration (name-value pairs or equivalent YAML content)
* Encrypt and decrypt property values (symmetric or asymmetric)
* Embeddable easily in a Spring Boot application using `@EnableConfigServer`
[[spring-cloud-config-client]]
== Spring Cloud Config Client
Specifically for Spring applications, Spring Cloud Config Client lets you:
* Bind to the Config Server and initialize Spring `Environment` with remote property sources.
* Encrypt and decrypt property values (symmetric or asymmetric).
* `@RefreshScope` for Spring `@Beans` that want to be re-initialized when configuration changes.
* Use management endpoints:
** `/env` for updating `Environment` and rebinding `@ConfigurationProperties` and log levels.
** `/refresh` for refreshing the `@RefreshScope` beans.
** `/restart` for restarting the Spring context (disabled by default).
** `/pause` and `/resume` for calling the `Lifecycle` methods (`stop()` and `start()` on the `ApplicationContext`).
* Bootstrap application context: a parent context for the main application that can be trained to do anything (by default, it binds to the Config Server and decrypts property values).
[[quick-start]]
= Quick Start
[[sample-application]]
== Sample Application
You can find a sample application https://github.com/spring-cloud/spring-cloud-config/tree/master/spring-cloud-config-sample[here].
It is a Spring Boot application, so you can run it by using the usual mechanisms (for instance, `mvn spring-boot:run`).
When it runs, it looks for the config server on `http://localhost:8888` (a configurable default), so you can run the server as well to see it all working together.
The sample has a test case where the config server is also started in the same JVM (with a different port), and the test asserts that an
environment property from the git configuration repo is present.
To change the location of the config server, you can set `spring.cloud.config.uri` in `bootstrap.yml` (or in system properties and other places).
The test case has a `main()` method that runs the server in the same way (watch the logs for its port), so you can run the whole system in one process and play with it (for example, you can run the `main()` method in your IDE).
The `main()` method uses `target/config` for the working directory of the git repository, so you can make local changes there and see them reflected in the running app. The following example shows a session of tinkering with the test case:
----
$ curl localhost:8080/env/sample
mytest
$ vi target/config/mytest.properties
.. change value of "sample", optionally commit
$ curl -X POST localhost:8080/refresh
["sample"]
$ curl localhost:8080/env/sample
sampleValue
----
The refresh endpoint reports that the "sample" property changed.
[[building]]
= Building
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/modules/ROOT/partials/building.adoc[]
[[jce]]
== JCE
If you get an exception due to "Illegal key size" and you are using Suns JDK, you need to install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files.
See the following links for more information:
https://www.oracle.com/technetwork/java/javase/downloads/jce-6-download-429243.html[Java 6 JCE]
https://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html[Java 7 JCE]
https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html[Java 8 JCE]
Extract the JCE files into the `JDK/jre/lib/security` folder for whichever version of JRE/JDK x64/x86 you use.
[[contributing]]
= Contributing
include::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/main/docs/modules/ROOT/partials/contributing.adoc[]

View File

@@ -1,31 +0,0 @@
|===
|Name | Default | Description
|spring.cloud.config.allow-override | `+++true+++` | Flag to indicate that {@link #isOverrideSystemProperties() systemPropertiesOverride} can be used. Set to false to prevent users from changing the default accidentally. Default true.
|spring.cloud.config.discovery.enabled | `+++false+++` | Flag to indicate that config server discovery is enabled (config server URL will be looked up via discovery).
|spring.cloud.config.discovery.service-id | `+++configserver+++` | Service id to locate config server.
|spring.cloud.config.enabled | `+++true+++` | Flag to say that remote configuration is enabled. Default true;
|spring.cloud.config.fail-fast | `+++false+++` | Flag to indicate that failure to connect to the server is fatal (default false).
|spring.cloud.config.headers | | Additional headers used to create the client request.
|spring.cloud.config.initialize-on-context-refresh | `+++false+++` | Flag to initialize bootstrap configuration on context refresh event. Default false.
|spring.cloud.config.label | | The label name to use to pull remote configuration properties. The default is set on the server (generally "main" for a git based server).
|spring.cloud.config.media-type | | The Accept header media type to send to config server.
|spring.cloud.config.multiple-uri-strategy | | The strategy to use when call to server fails and there are multiple URLs configured on the uri property (default {@link MultipleUriStrategy#ALWAYS}).
|spring.cloud.config.name | | Name of application used to fetch remote properties.
|spring.cloud.config.override-none | `+++false+++` | Flag to indicate that when {@link #setAllowOverride(boolean) allowOverride} is true, external properties should take lowest priority and should not override any existing property sources (including local config files). Default false. This will only have an effect when using config first bootstrap.
|spring.cloud.config.override-system-properties | `+++true+++` | Flag to indicate that the external properties should override system properties. Default true.
|spring.cloud.config.password | | The password to use (HTTP Basic) when contacting the remote server.
|spring.cloud.config.profile | `+++default+++` | The default profile to use when fetching remote configuration (comma-separated). Default is "default".
|spring.cloud.config.request-connect-timeout | `+++0+++` | timeout on waiting to connect to the Config Server.
|spring.cloud.config.request-read-timeout | `+++0+++` | timeout on waiting to read data from the Config Server.
|spring.cloud.config.retry.initial-interval | `+++1000+++` | Initial retry interval in milliseconds.
|spring.cloud.config.retry.max-attempts | `+++6+++` | Maximum number of attempts.
|spring.cloud.config.retry.max-interval | `+++2000+++` | Maximum interval for backoff.
|spring.cloud.config.retry.multiplier | `+++1.1+++` | Multiplier for next interval.
|spring.cloud.config.send-state | `+++true+++` | Flag to indicate whether to send state. Default true.
|spring.cloud.config.tls | | TLS properties.
|spring.cloud.config.token | | Security Token passed thru to underlying environment repository.
|spring.cloud.config.uri | `+++[http://localhost:8888]+++` | The URI of the remote server (default http://localhost:8888).
|spring.cloud.config.username | | The username to use (HTTP Basic) when contacting the remote server.
|===

View File

@@ -1,9 +0,0 @@
:root-target: ../../../target/
[[observability]]
= Observability metadata
:page-section-summary-toc: 1
include::{root-target}_metrics.adoc[]
include::{root-target}_spans.adoc[]

View File

@@ -0,0 +1,6 @@
[[configuration-properties]]
= Configuration Properties
Below you can find a list of configuration properties.
include::partial$_configprops.adoc[]

View File

@@ -0,0 +1,6 @@
[[observability]]
== Observability metadata
include::partial$_metrics.adoc[]
include::partial$_spans.adoc[]

View File

@@ -1,49 +0,0 @@
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.
## Features
Spring Cloud Config Server features:
* HTTP, resource-based API for external configuration (name-value pairs, or equivalent YAML content)
* Encrypt and decrypt property values (symmetric or asymmetric)
* Embeddable easily in a Spring Boot application using `@EnableConfigServer`
Config Client features (for Spring applications):
* Bind to the Config Server and initialize Spring `Environment` with remote property sources
* Encrypt and decrypt property values (symmetric or asymmetric)
## Getting Started
As long as Spring Boot Actuator and Spring Config Client are on the
classpath any Spring Boot application will try to contact a config
server on `http://localhost:8888`, the default value of
`spring.cloud.config.uri`. If you would like to change this default,
you can set `spring.cloud.config.uri` in `bootstrap.[yml | properties]`
or via system properties or environment variables.
```java
@Configuration
@EnableAutoConfiguration
@RestController
public class Application {
@Value("${config.name}")
String name = "World";
@RequestMapping("/")
public String home() {
return "Hello " + name;
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
```
The value of `config.name` in the sample (or any other values you bind to in the normal Spring Boot way) can come from local configuration or from the remote Config Server. The Config Server will take precedence by default. To see this look at the `/env` endpoint in the application and see the `configServer` property sources.
To run your own server use the `spring-cloud-config-server` dependency and `@EnableConfigServer`. If you set `spring.config.name=configserver` the app will run on port 8888 and serve data from a sample repository. You need a `spring.cloud.config.server.git.uri` to locate the configuration data for your own needs (by default it is the location of a git repository, and can be a local `file:..` URL).

View File

@@ -8,17 +8,14 @@ In order to serve binary files from the config server you will need to send an `
Consider the following example for a GIT or SVN repository or a native backend:
====
[source]
----
application.yml
nginx.conf
----
====
The `nginx.conf` might resemble the following listing:
====
[source]
----
server {
@@ -26,11 +23,9 @@ server {
server_name ${nginx.server.name};
}
----
====
`application.yml` might resemble the following listing:
====
[source,yaml]
----
nginx:
@@ -43,11 +38,9 @@ nginx:
server:
name: develop.com
----
====
The `/sample/default/master/nginx.conf` resource might be as follows:
====
[source]
----
server {
@@ -55,11 +48,9 @@ server {
server_name example.com;
}
----
====
`/sample/development/master/nginx.conf` might be as follows:
====
[source]
----
server {
@@ -67,7 +58,6 @@ server {
server_name develop.com;
}
----
====
[[spring-cloud-config-serving-plain-text-aws-s3]]
== AWS S3

View File

@@ -0,0 +1,10 @@
[[observability-conventions]]
=== Observability - Conventions
Below you can find a list of all `GlobalObservationConvention` and `ObservationConvention` declared by this project.
.ObservationConvention implementations
|===
|ObservationConvention Class Name | Applicable ObservationContext Class Name
|`org.springframework.cloud.config.server.environment.ObservationEnvironmentRepositoryObservationConvention`|`ObservationEnvironmentRepositoryContext`
|===

View File

@@ -0,0 +1,41 @@
[[observability-metrics]]
=== Observability - Metrics
Below you can find a list of all metrics declared by this project.
[[observability-metrics-environment-repository]]
==== Environment Repository
____
Observation created around an EnvironmentRepository.
____
**Metric name** `spring.cloud.config.environment.find` (defined by convention class `org.springframework.cloud.config.server.environment.ObservationEnvironmentRepositoryObservationConvention`). **Type** `timer`.
**Metric name** `spring.cloud.config.environment.find.active` (defined by convention class `org.springframework.cloud.config.server.environment.ObservationEnvironmentRepositoryObservationConvention`). **Type** `long task timer`.
IMPORTANT: KeyValues that are added after starting the Observation might be missing from the *.active metrics.
IMPORTANT: Micrometer internally uses `nanoseconds` for the baseunit. However, each backend determines the actual baseunit. (i.e. Prometheus uses seconds)
Fully qualified name of the enclosing class `org.springframework.cloud.config.server.environment.DocumentedConfigObservation`.
IMPORTANT: All tags must be prefixed with `spring.cloud.config.environment` prefix!
.Low cardinality Keys
[cols="a,a"]
|===
|Name | Description
|`spring.cloud.config.environment.application` _(required)_|Application name for which properties are being queried for.
|`spring.cloud.config.environment.class` _(required)_|Implementation of the EnvironmentRepository.
|`spring.cloud.config.environment.label` _(required)_|Label for which properties are being queried for.
|`spring.cloud.config.environment.profile` _(required)_|Application name for which properties are being queried for.
|===

View File

@@ -0,0 +1,28 @@
[[observability-spans]]
=== Observability - Spans
Below you can find a list of all spans declared by this project.
[[observability-spans-environment-repository]]
==== Environment Repository Span
> Observation created around an EnvironmentRepository.
**Span name** `spring.cloud.config.environment.find` (defined by convention class `org.springframework.cloud.config.server.environment.ObservationEnvironmentRepositoryObservationConvention`).
Fully qualified name of the enclosing class `org.springframework.cloud.config.server.environment.DocumentedConfigObservation`.
IMPORTANT: All tags must be prefixed with `spring.cloud.config.environment` prefix!
.Tag Keys
|===
|Name | Description
|`spring.cloud.config.environment.application` _(required)_|Application name for which properties are being queried for.
|`spring.cloud.config.environment.class` _(required)_|Implementation of the EnvironmentRepository.
|`spring.cloud.config.environment.label` _(required)_|Label for which properties are being queried for.
|`spring.cloud.config.environment.profile` _(required)_|Application name for which properties are being queried for.
|===