spring-cloud / spring-cloud/spring-cloud-vault

Vault Agent Sidecar With Spring Cloud Vault Not Working

Open
#664 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
291
Forks
152
Avg merge
11h 24m
Merged PRs (30d)
3

Description

Describe the bug
Using version 2.2.7.RELEASE of spring-cloud-starter-vault-config and I have got the following bootstrap.yaml

spring:
  cloud:
    vault:
      kv:
        enabled: true
      authentication: NONE

When I deploy it into Kubernetes, with the following annotations on the Deployment

      annotations:
        vault.hashicorp.com/agent-inject: 'true'
        vault.hashicorp.com/role: 'bot-sa'
        vault.hashicorp.com/namespace: "development"
        vault.hashicorp.com/agent-init-first: "true"

I can see that the vault-init starts, then the vault-agent indeed starts and runs. When the Spring App runs, I see the following

{"@timestamp":"2022-11-18T19:17:57.910Z","@version":"1","message":"[RequestedSecret [path='secrets/dev-team/bot', mode=RENEW]] Lease [leaseId='null', leaseDuration=PT0S, renewable=false] I/O error on GET request for \"https://localhost:8200/v1/secrets/dev-team/bot\": Connect to localhost:8200 [localhost/127.0.0

Ignoring the issue that the KV Engine is Version 2 and for some reason isn't recognising it (have raised this here https://github.com/spring-projects/spring-vault/issues/738), but it doesn't seem to be connecting to the Vault Agent. Tbh, I'm not entirely sure how the whole NONE authentication stuff works, because there isn't any actual code examples of this on any docs - apart from just saying to use NONE. Am I misunderstanding the entire thing, or is the above a genuine issue?

Previous to this, we were using Kubernetes authentication to retrieve the secrets, but we want to cut down the code by just using the Vault Agent - but are having the above problems.

To note: There is nothing wrong with the injection of secrets into the main container, so we know that in terms of injecting secrets using the Vault Secret Injection Template works. We just can't figure out why Spring itself can't pull the secrets through the Vault Agent.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported bootstrap.yaml and Kubernetes Deployment annotations, then trace how spring-cloud-starter-vault-config handles authentication: NONE, the Vault Agent endpoint, and the requested secrets path. Compare this with the connection error in the application logs and the linked spring-vault issue. Done means the expected agent-based configuration behavior is documented or the defect is reproduced with a focused test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kubernetes, spring, yaml
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.