Marcin
Marcin

Reputation: 21

Spring boot config server doesn't load properties from Vault

I have a problem with the Spring Boot Config Server.

Here is my pom.xml

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.4.2</version>
  </parent>

  <groupId>pl.silent</groupId>
  <artifactId>config-server</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>config-server</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-config-server</artifactId>
    </dependency>
  </dependencies>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>2024.0.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>

Here is my application.yml:

server:
  port: 6611

spring:
  application:
    name: config-server
  profiles:
    active: git, vault
  cloud:
    config:
      server:
        vault:
          host: 127.0.0.1
          port: 8200
          authentication: token
          token: test
          order: 1
        git:
          uri: file://${user.home}/application-configuration
          search-paths: '{application}'
          default-label: master
          username: test
          password: test
          order: 2

When my application calls the Config Server with the application name silent and profile dev, the Config Server doesn't call Vault. It only returns configurations from Git.

I have checked everything: in Vault, the key exists, and I have verified the token. When I connect the Config Server to Vault directly, the properties load correctly into the Config Server application. However, when the internal application calls the Config Server, it doesn't work. I have verified this using curl, and it works fine.

Upvotes: 2

Views: 32

Answers (1)

Pavlo.P
Pavlo.P

Reputation: 38

It seems that your Vault is overriden by Git. Try this in your application.yml:

...
    spring:
...
      cloud:
        config:
          allowOverride: false
          overrideNone: true
...

see: https://docs.spring.io/spring-cloud-config/reference/server/environment-repository/using-bootstrap-to-override-properties.html

Upvotes: 0

Related Questions