0

I wanted to fetch properties from two git repos. one is https://username@bitbucket.my.domain.com/share.git - which will have a property file contains some common key value pair and the other one is https://username@bitbucket.my.domain.com/service.git - it will have property files of all the micro services.
While I am deploying the service only one yml file (which is in https://username@bitbucket.my.domain.com/share.git repo) is read by the config server. What I am missing? How to read the property file from another repo i.e. https://username@bitbucket.my.domain.com/service.git too?

I wanted to deploy the service in PCF. So I configured the config-server in PCF with the following json.

{
    "count": 1,
    "git": {
        "label": "feature",
        "uri": "https://username@bitbucket.my.domain.com/share.git",
        "username": "username",
        "password": "password",
        "repos": {
            "configserver": {
                "password": "password",
                "label": "feature",
                "uri": "https://username@bitbucket.my.domain.com/service.git"
                "username": "username"
            }
        }
    }
}

Name of my service is LogDemo and spring profile is active. I have created two yml files and placed in the corresponding repo. (I have given same name two both the files like LogDemo-active.yml). While I am deploying the service only one yml file (which is in https://username@bitbucket.my.domain.com/share.git repo) is read by the config server. /env is giving me the following:

{
  "profiles": [
    "active",
    "cloud"
  ],
  "server.ports": {
    "local.server.port": 8080
  },
  "configService:configClient": {
    "config.client.version": "234e59d4a9f80f035f00fdf07e6f9f16e5560a55"
  },
  "configService:https://username@bitbucket.my.domain.com/share.git/LogDemo-active.yml": {
    "key1": "value1",
    "key2": "value2"
  },
  ...................
  ...................

What I am missing? How to read the property file from other repo i.e. https://username@bitbucket.my.domain.com/service.git too?

Below is my bootstrap.yml

spring:
  application:
    name: LogDemo
  mvc:
    view:
      prefix: /
      suffix: .jsp

Here is my manifest file

---
inherit: baseManifest.yml
applications:
- name: LogDemo
  host: LogDemo
  env:
    LOG_LEVEL: INFO
    spring.profiles.active: active
    TZ: America/New_York
  memory: 1024M
  domain: my.domain.com
  services:
  - config-server-comp
Sayan
  • 15
  • 8
  • It looks like it may be a pattern matching issue. Your `spring.application.name` is `LogDemo`, but the config server repo that's not being used has a name of `configserver`. That means the pattern to indicate this repo should be used is `configserver/*`. I think it would work if you renamed this to `LogDemo`, or renamed your app to `configserver`. See https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html#_pattern_matching_and_multiple_repositories. If you don't want to deal with this, I think you could use a composite backend with two Git repos. – Daniel Mikusa May 19 '19 at 13:17
  • @DanielMikusa Yes. You are right. it's a matching issue.I renamed the tag from 'configserer' to 'LogDemo' and it worked. In fact, if i add a field like "pattern": "LogDemo/active then also it worked". But in both the cases then, properties from https://username@bitbucket.my.domain.com/share.git or first URI is not being read. – Sayan May 20 '19 at 08:30
  • Thanks @DanielMikusa. It worked perfectly with composite backend. – Sayan May 20 '19 at 09:19

1 Answers1

0

When using multiple repos, the repos that will be applied depend on the pattern's defined for those repos. The default pattern is <repo-name>/*. Thus changing the repo name to LogDemo will activate the repo for your app, because the app name, spring.application.name, is LogDemo.

If one or more patterns match, then the repo for the matched patterns will be used. If no pattern matches then the default is used.

Full details are described in the docs here.

https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html#_pattern_matching_and_multiple_repositories

If you don't need or want the pattern matching feature, you can use the [composite backend]( https://docs.pivotal.io/spring-cloud-services/2-0/common/config-server/composite-backends.html). The composite backend allows you to define multiple Git repositories. See the first config example here.

https://docs.pivotal.io/spring-cloud-services/2-0/common/config-server/composite-backends.html#general-configuration

Daniel Mikusa
  • 13,716
  • 1
  • 22
  • 28