Description:

  • Spring Boot Version : 2.2.7

  • Spring Cloud Version: Hoxton.SR4

Kubernetes Service Acccount based authentication doesn't work even when all the corresponding properties are specified.

application.properties:

#Server port
server.port = 8888
spring.profiles.active=vault

#Vault prod
spring.cloud.config.server.vault.host=vault.domain.org
spring.cloud.config.server.vault.scheme=https
spring.cloud.config.server.vault.backend=<backend>
spring.cloud.config.server.vault.port=443
spring.cloud.config.server.vault.profile-separator=-
spring.cloud.config.server.vault.default-key=<defaultKey>
spring.cloud.config.server.vault.authentication=KUBERNETES
spring.cloud.config.server.vault.kubernetes.role=<rolename>
spring.cloud.config.server.vault.kubernetes.kubernetes-path=kubernetes
spring.cloud.config.server.vault.kubernetes.service-account-token-file=/var/run/secrets/kubernetes.io/serviceaccount/token
spring.cloud.config.server.vault.kv-version=2
logging.level.org.springframework.web=DEBUG

Token based authentication for Vault works perfectly, but when Kubernetes Service Account based authentication is used, below error is thrown when a Get call is made to the config server

There was an unexpected error (type=Bad Request, status=400). Missing required header in HttpServletRequest: X-Config-Token

This issue gets fixed upon adding the below dependency to the project POM.

<dependency>
    <groupId>org.springframework.vault</groupId>
    <artifactId>spring-vault-core</artifactId>
</dependency>

Is this because "spring-vault-core" dependency has been marked as optional in the spring-cloud-config-server pom.xml?

However, the pom change still doesn't solve the issue completely. The first request made to config server fails. The first request error has already been reported here

Please help me out here and let me know if there there's anything I'm missing.

Comment From: spencergibb

spring-vault-core is optional and needs to remain that way as not all projects use it.

Comment From: venkateshdatta1993

@spencergibb in that case I guess it would be helpful to update the documentation saying for kubernetes service account authentication to work, one would have to include spring-vault-core as well in the project POM

please let me know your thoughts.