Spring boot running in GKE fetch secret from secret manager

55 views Asked by At

I am running a spring boot application in GKE and I want to fetch application properties from the secret manager. I have setup it up to run using a service account that has the role: roles/secretmanager.admin.

It tried these 2 guides:

https://spring-gcp.saturnism.me/app-dev/cloud-services/secret-management

https://codelabs.developers.google.com/codelabs/cloud-spring-cloud-gcp-secret-manager#0

When I try to start the application I get the following exception:

ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'googleCredentials' defined in class path resource [com/google/cloud/spring/autoconfigure/core/GcpContextAutoConfiguration.class]: Failed to instantiate [com.google.api.gax.core.CredentialsProvider]: Factory method 'googleCredentials' threw exception with message: io/grpc/Context

However, I am not running locally, I am running in GKE with a service account. How can I configure the application to work in that setup?

I this question: How to specify the GCP Credential Location in application.properties file (for using the Pub/Sub in GCP)? guillaume blaquiere says that you do not have to use key file, but I cannot make it work or find documentation.

my pom dependency

<dependency>
    <groupId>com.google.cloud</groupId>
    <artifactId>spring-cloud-gcp-starter-secretmanager</artifactId>
    <version>4.8.2</version>
</dependency>
0

There are 0 answers