Skip to content
Advertisement

Spring Cloud Config Server fallback for multiple repositories

We are using spring cloud config server backed by bitbucket for config files. We have configured multiple repositories in application.yml of config server. We want to make it available even if bitbucket is down. We are looking for a solution that can cache config repositories and in case bitbucket is down it can still be able to serve properties of different repositories. Below is my application.yml

spring:
  cloud:
    config:
      server:
        git:
          uri: git@bitbucket.org:config1.git
          ignoreLocalSshSettings: true
          privateKey: ${PEM}
          repos:
            service1:
              uri: git@bitbucket.org:config2.git
              ignoreLocalSshSettings: true
              privateKey: ${PEM}
            service2:
              uri: git@bitbucket.org:config3.git
              ignoreLocalSshSettings: true
              privateKey: ${PEM}

I have tried setting up spring.cloud.config.server.git.basedir but it clones only the base config repo. How can we make config server to serve from local if bitbucket is down.

Advertisement

Answer

Using basedir property is the only way out. This is how we use that :

spring:
  cloud:
    config:
      server:
        git:
          uri: git@bitbucket.org:config1.git
          ignoreLocalSshSettings: true
          privateKey: ${PEM}
          basedir: /home/user/config1-repo
          repos:
            service1:
              uri: git@bitbucket.org:config2.git
              ignoreLocalSshSettings: true
              privateKey: ${PEM}
              basedir: /home/user/config2-repo
            service2:
              uri: git@bitbucket.org:config3.git
              ignoreLocalSshSettings: true
              privateKey: ${PEM}
              basedir: /home/user/config3-repo

How did you try to reproduce the scenario where git is not available and forcing the config server to fetch the properties from local server path. I suggest you create the local path. And using git-bash clone the config repo inside your local repo directory. For example in this case go inside /home/user/localRepo and clone your config git repo there. Ensure to have all the files and folder be cloned properly.

Then try to reproduce the git not available scenario and check if your config server MS is able to fetch properties from local dir. This is the only way out for fallback.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement