美文网首页
Spring cloud config

Spring cloud config

作者: jaymz明 | 来源:发表于2019-10-16 13:27 被阅读0次

    ref: https://spring.io/projects/spring-cloud-config

    • Spring Cloud Config Server features:
      1. HTTP, resource-based API for external configuration (name-value pairs, or equivalent YAML content)
      2. Encrypt and decrypt property values (symmetric or asymmetric)
      3. Embeddable easily in a Spring Boot application using @EnableConfigServer
    • Config Client features (for Spring applications):
      1. Bind to the Config Server and initialize Spring Environment with remote property sources
      2. Encrypt and decrypt property values (symmetric or asymmetric)

    • demo
      使用官网的spring initialzar生成config依赖。主要的pom依赖:
    <dependency>    
    <groupId>org.springframework.cloud</groupId>    
    <artifactId>spring-cloud-config-server</artifactId></dependency><dependency>    
    <groupId>org.springframework.cloud</groupId>    
    <artifactId>spring-cloud-starter-config</artifactId></dependency>
    

    在resources目录下面配置需要的信息。(application-jenkins-dev.yml)

    # jenkins configjenkins:  
    config:    
      proxy: xxx.xxx.xxx
      url: jaymz.jenkins.com
    # tool
    custom:
      tool:
        name:
          maven:
             version: maven-3.3.9
             url: xxx.xxx.xxx
          IA:
            version: InstallAnywhere_2018
            url: xxx.xxx.xxx
         JDK:
            version: openjdk-8u171
            url: xxx.xxx.xxx
    

    然后我们启动springboot,访问:
    http://localhost:8888/spring-config-demo/jenkins-dev,如下图所示:

    image.png

    为了让结果readable,我们用shell:
    curl -k url |jq .
    如下

    image.png

    配置中心的雏形出来了。下面就是整合散落在各个地方的config(application,infra等)。
    未来还需要take actions:

    1. 整合需要移到配置中心的config(并翻译成yml)
    2. config server长活(加入到k8s中)
    3. 修改需要获取配置的代码
    4. 针对特殊场景(一旦code freeze,需要将配置中心的关于pipeline的代码作相应的更改,否则定时的job不受code freeze的规则约束)

    相关文章

      网友评论

          本文标题:Spring cloud config

          本文链接:https://www.haomeiwen.com/subject/mnoymctx.html