Resources:
Https://cloud.spring.io/spring-cloud-static/spring-cloud-config/1.4.0.RELEASE/single/spring-cloud-config.html
http://cloud.spring.io/spring-cloud-static/Camden.SR7/#_environment_repository
Git Backend--git back end
The default implementation of Environmentrespository uses the Git backend, which is handy for managing upgrade and environment checks and auditing changes.
To change the location of the repository, you can set the "Spring.cloud.config.server.git.uri" configuration property in the configuration server (for example, in applicaton.yml)
If you set up with the file: prefix, you should run from local storage so that you can work quickly and easily without a server, but in this case the server will run directly on the local repository without cloning it (it doesn't matter because the configuration server never changes the "remote" repository).
To extend the configuration server and make it highly available, you need to point all instances of the service to the same repository, so only the shared file system will work. Even in this case, it is better to use the SSH: protocol for the shared file system repository so that the server can clone it and use the local work service as the cache.
The repository implementation insinuate the {label} parameter of the HTTP resource to the GIT tag (commit ID, branch name, or label).
If the Git branch or tag name contains a slash ("/"), you should use the special string "(_)" To specify the label in the HTTP URL (to avoid confusion with other URL paths). For example, if the label is Foo/bar, a backslash will cause the label to look like Foo (_) bar.
The containing special string "(\_)" can also be applied to the {application} parameter.
If you use a command-line client like curl (such as using quotation marks to relay it out of the shell), be careful with the square brackets in the URL.
Placeholder for placeholders in Git Uri--git URI
Spring Cloud Config Server supports one with {application} and {profile} (as well as {label}, if needed. But keep in mind that the tag is anyway a git repository URL that is used as a placeholder for a git tag.
Therefore, you can easily support the use of an "one repo" policy, for example:
Spring: Cloud: config: server: git: uri:https://github.com/myorg/{application}
or use type mode but use the "every profile one repo" policy of {profile}.
In addition, you can enable support for multiple organizations by using the special string "(\_)" in the {application} parameter, for example:
Spring: Cloud: config: server: git: uri:https://github.com/{application}
where {application} is provided in "Organization (\_) application" format upon request.
Pattern Matching and multiple repositories--mode matching and multiple repositories
The pattern format is a comma-separated list of {application} and {profile} names with wildcards (you might need to refer to a pattern that starts with a wildcard character). For example:
Spring: Cloud: config: server: git: uri:https://github.com/spring-cloud-samples/ Config-repo repos: simple:https://github.com/simple/config-repo Special: pattern:special*/ dev*,*special*/dev* Uri:https://github.com/special/config-repo Local: pattern:local* URI: File:/home/configsvc/config-repo
If {application}/{profile} does not match any of the modes, it will use the default values defined under "Spring.cloud.config.server.git.uri".
In the example above, for the "simple" repository, the matching pattern is "simple/*" (that is, all the configuration files match only one application named "Simple"). The "local" repository matches all application names that start with "local" in all profiles (the "/*" suffix is automatically added to any pattern that does not have a profile match).
Note: The "one-liner" shortcut used in the "simple" example above can only be used if the only property you want to set is a URI. If you need to set anything else (credentials, patterns, etc.), you need to use the complete form.
The Pattern property in repo is actually an array, so you can use a YAML array (or a suffix such as [0],[1] in a property file) to bind to multiple schemas. You might want to do this if you want to run an application that has more than one configuration file. For example:
Spring: Cloud: config: server: git: uri:https://github.com/spring-cloud-samples/ Config-repo Repos: Development: pattern: -' */development ' -' */staging ' uri:https:// Github.com/development/config-repo Staging: pattern: -' */qa ' -' */production ' URI: Https://github.com/staging/config-repo
Note:spring Cloud will guess that the pattern that contains profiles that don't end with "*" means that you actually want to match the list of profiles starting with this pattern (so */staging
it's a ["*/staging","*/staging,*"]
shortcut).
Each repository can also store configuration files in subdirectories, and you can specify the mode in which these directories are searched as searchpaths. For example at the top level:
Spring: Cloud: config: server: git: uri:https://github.com/spring-cloud-samples/ Config-repo searchpaths:foo,bar*
In this example, the service searches for the configuration file in the top-level and "foo/" subdirectories and in any subdirectories whose names begin with "bar".
By default, the server clones the remote repository the first time the configuration is requested. You can configure the server to clone the repository at startup. For example at the top level:
Spring: Cloud: config: server: git: uri:https://git/common/config-repo.git Repos: Team-a: pattern:team-a-* cloneonstart:true uri:http://git/team-a/config-repo.git team-b: pattern:team-b-* cloneonstart:false uri:http://git/team-b/config-repo.git team-c: pattern:team-c-* Uri:http://git/team-a/config-repo.git
In this example, the service is cloning Team-a's config-repo at boot time before accepting any requests. All other repositories will not be cloned until the configuration is requested from the repository.
Note: Set when the configuration server clones the repository at startup, it can help to quickly identify the wrong configuration source (for example, an invalid repository URI) when the configuration server starts. When the configuration source is not enabled for Cloneonstart, the configuration server may start a successful configuration error or an invalid configuration source, and no errors are detected until the application requests configuration from that configuration source.
authentication--Certification
To use HTTP Basic authentication on the remote repository, add the "username" and "password" properties separately (not in the URL). For example:
Spring: Cloud: config: server: git: uri:https://github.com/spring-cloud-samples/ Config-repo Username:trolley Password:strongpassword
If you do not use HTTPS and user credentials, then SSH should be out of the box when you store the key in the default directory (~/.SSH) and the URI points to the SSH location. For example: "[email protected]: Configuration/cloud-configuration"
It is important to have a GIT server entry in the ~/.ssh/know_hosts file and the Ssh-rsa format. Other formats (for example: ecdsa-sha2-nistp256
) are not supported.
To avoid surprises, you should make sure that there is know_hosts
only one entry in the GIT server file and match the URL that you provided to the configuration server.
If you use a host name in the URL, use the hostname instead of the IP in the know_hosts
file.
You can access the repository using Jgit, so any documents you find should apply.
The HTTPS proxy settings can be set in ~/.git/config, or the -Dhttps.proxyHost
-Dhttps.proxyPort
HTTPS proxy settings can be set in the same way as any other JVM process through System properties (and).
Note: If you do not know where your ~/.git directory is, use git config --global
to manipulate the settings (for example: git config --global http.sslVerify false
)
Authentication with AWS codecommit--using AWS CodeCommit for authentication
git SSH configuration using properties--use properties git ssh config
By default, when you use the SSH URI to connect to a git repository, the Jgit library used by Spring Cloud Config uses an SSH configuration file, for example: ~/.ssh/known_hosts and/etc/ssh/ssh_config.
In cloud environments such as foundry, the local file system may be short-lived or inaccessible. For this scenario, you can use Java properties to set the SSH configuration. In order to activate an attribute-based SSH configuration, you must spring.cloud.config.server.git.ignoreLocalSshSettings
set the property to True. For example:
Spring:cloud:config:server:git:uri: [Email protected]:team/repo1.git Ignorelocalsshsettings:true Hostkey:somehostkey Hostkeyalgorithm:ssh-rsa Privatekey : | -----BEGIN RSA PRIVATE KEY-----MIIEPGIBAAKCAQEAX4UBADZY5XJW6HC9JWN0MX33XPTDVW9WQHP5AKARBTAC3DQX IXFMPGW3K45JXRB93F8TV9VL3RD9CUG1GV4FM+O7DS7FRES5RTJV2RT/JVNJCOQF Ol8+nglqrz Cybtqn7zybywmrirpgoduqdpyrj2yq+obbbnhg5n+howkjjpzdj2ud 1L7R+WXIQMJO1IYYY16XS8WSJYQUYC0LL456QKD5BDZ 0ag8j2x9h9d5220ln7s9i oeztipxips7p7jekf3ywx6abjwomb0rx79dv4qincggzatng1pkxxqt76vhcga0w Ddvheeygbsq6higsh0i7bqun0alrzojfe3gqhqidaqabaoibaqczmgrk8bk6txcd Fy6ytikxfzwb38iqp0oj iuwnrq0+9xt+nsypvilhkxfxxckku4zuheigvrq5mn9b bo56/rrcqhhoojduwuov2qmqjvputc0cpgkd+valhfd75mxoxU7S3FK7YJXY3RSG EMFA6THV8/4A5UMO5TQSD2YTM5B19AHRQIUUVI1WTB41DJULUGIMYRNYRHZQLVVJ 5mjnktlyu3v8poydfv1gmxpph6vlpafxeeeyn8vb97e5x3dghjz5ururamtltdo8 +aahyoksiy612tkkqthjlt7fja Wncgmgy6podzzvziclfmmtxyiz/28i4bx/mose Pzvnfrixaogbao6uiwt40/pks53mcewngslscsh9ogaaltf/xdvmns5vmuy yaykg TI8OL5WQBMI4GIUZJBGUVSUT+IOWIRG3F5TN85WPJQ1UGVCPTNL5QO9XAS1PFSCQ XRT WZ9ENJ2TSIAMP/SVJSYGG3OIBXFNUAIPSXNQIJPWRLW3IRZPGGVX/AOGBANYW DNHSHUCEHMJI3AXWR12OTDNALOANVGLWLNKQ Lsyuza7zegpkq90uaubdcefgdpyi Phkpeaeiiaannfo8m9aotkr+7i6/umtlwrvnfrsvtzv3orxjwqv20yibcvrkd1ux vhe0ozpzxwwkspafocpywpghgregf1aiybe9ubtjaogbai8bfpgjpyfymigbjo6z Fwljc/xlfqdus Rchl7abw5qq0l4v3r+frjw3zyufzltvckfdj6gelwjjo+8wbm+r Gtkyjiteht48duliftdyiphgvm9+i1mghh5zkucqihxiyr 9jhlobb7krm0rpvyy4 Vaykcngydvtavodp+4m6jvhjaogbalbttqerkn47v0+jjpaplnf0kxgrqegijirv Cya6v4wygr7nei Fesecfoc356pyhgpfpcvyeztwlvwtkb3rzit1tzn8fh4ybr6ee ktbtjefrfhvujqqnucavfgi29f+9oe3ei9f7wa+h35ocf6j vtyushnmio/3gz38n Cpjycma9aogbamhsitne3qcbsxabdur00ddsifvrozyfj2m40i4kcrm35bc/bibs Q0TY3WE+ERB40U8Z2BVU61QUWAUNJ2+UGADHO58VSVDGGQAO0BSKH58INNKKT96J 69pcvh/4rmlbxdcmnygm6iu+ Mlpqk4buzknhsmvhifdj0epupvaq8rht-----END RSA PRIVATE KEY-----
SSH Configuration Properties:
Property
Name |
Remarks |
Ignorelocalsshsettings |
If true, use property based SSH Config instead of file based. Must spring.cloud.config.server.git.ignoreLocalSshSettings is set at AS, not inside a repository definition. |
Privatekey |
Valid SSH private key. Must be set if are ignoreLocalSshSettings true and Git URI is SSH format |
Hostkey |
Valid SSH host key. Must be set if is hostKeyAlgorithm also set |
Hostkeyalgorithm |
One of ssh-dss, ssh-rsa, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384 ,ecdsa-sha2-nistp521 . Must be set if is hostKey also set |
Stricthostkeychecking |
true or false . If false, ignore errors with host key
|
Knownhostsfile |
Location of custom. known_hosts file |
Preferredauthentications |
Override Server authentication Method order. This should allow evade login prompts if server have keyboard-interactive authentication before publickey method. |
Placeholders in Git search paths--git the placeholder in the path
Spring Cloud Config Server also supports search paths using {application} and {profile} (as well as {label}, if required) placeholders. For example:
Spring: Cloud: config: server: git: uri:https://github.com/spring-cloud-samples/ Config-repo searchpaths: ' {application} '
Search the repository for files with the same name as the directory (and the top level). Wildcards are also valid in search paths with placeholders (any matching directories are included in the search)
Force pulls int git repositories--forces pull into git repository
As mentioned earlier, Spring Cloud Config server clones the remote Git repository, and if the local copy does not know how to dirty (for example, the folder contents are changed by the operating system process), the Spring Cloud Config The server was unable to update the local copy from the remote repository.
To solve this problem, if the local copy is dirty, there will be a force pull property, Force-pull, to force the spring Cloud Config server to pull from the remote repository. For example:
Spring: Cloud: config: server: git: uri:https://github.com/spring-cloud-samples/ Config-repo Force-pull:true
If you have multiple repository configurations, you can configure the Force pull property force-pull for each repository. For example:
Spring: Cloud: config: server: git: uri:https://git/common/config-repo.git force-pull: True repos: team-a: pattern:team-a-* uri:http://git/team-a/config-repo.git force-pull: True team-b: pattern:team-b-* uri:http://git/team-b/config-repo.git force-pull:true Team-c: pattern:team-c-* uri:http://git/team-a/config-repo.git
Note: The default value of the Force Pull property Force-pull is False
Spring-cloud-config-server--environment Repository (Git backend)