hashicorp / hashicorp/vault-secrets-operator

Populate a single kubernetes secret from multiple Vault secrets

Open
#923 4 comments 17 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
600
Forks
146
Avg merge
3d 8h
Merged PRs (30d)
6

Description

**Is your feature request related to a problem? Please describe.**
Currently, for `VaultStaticSecrets` we can only specify a single secret in Vault as the source, which forces us to, weather create and mount many k8s secrets when we have those distributed in many Vault secrets, or to create secrets in Vault with a lot of key/values, that might be repeated across many more Vault secrets.

Also, there is another use case. We would like to remove read permissions to (human) users, and allow them to only create/update/delete secrets in the KV engines. However, by doing that, the UI won't show which are the existing keys in a secret when creating a new version, forcing users to re-enter each key/value for the new secret version. This could be solved by the new feature [KV patch+subkey](https://github.com/hashicorp/vault/pull/28212), however that seems to be just for the Enterprise edition, not the community one. So, another solution for this problem would be to allow `VaultStaticSecrets` to get data from multiple paths, and instruct our users to create secrets in Vault with a single `key/value`, where the key is a known word, or same as the secret name.

**Describe the solution you'd like**
It would be great if we could populate a single k8s secret with the values from different secrets in Vault.

**Describe alternatives you've considered**
The [External Secrets](https://external-secrets.io/latest/provider/hashicorp-vault/) project allows to specify different paths on the `ExternalSecret` for the vault provider. Eg:

```yaml
---
apiVersion: external-secrets.io/v1beta1
kind: SecretStore
metadata:
name: example-store
namespace: example
spec:
provider:
vault:
server: "https://vault.example.com"
path: "kv-v2-example-secrets"
version: "v2"
auth:
kubernetes:
mountPath: "kubernetes"
role: "kubernetes-service-account"
serviceAccountRef:
name: "example"
---
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: example-external-secret
namespace: example
spec:
refreshInterval: "60s"
secretStoreRef:
name: example-store
kind: SecretStore
target:
name: example-sync
data:
- secretKey: keyforsecret1
remoteRef:
key: testing/secret1
property: secret1
- secretKey: keyforsecret2
remoteRef:
key: testing/secret2
property: secret2
# It creates the following secret
# apiVersion: v1
# kind: Secret
# metadata:
# ...
# name: example-sync
# namespace: example
# data:
# keyforsecret1:
# keyforsecret2:
# immutable: false
# type: Opaque
```

**Additional context**
Although it's possible to use `External Secrets`, we would really like to have a similar feature in VSO, since not only `External Secrets` doesn't support `DynamicSecrets`, but also it will be one more tool to maintain.

Thanks in advance!

Contributor guide

No contributing guide indexed for this repository

Research direction

No repository file or test is named. Start by locating the VaultStaticSecrets API and its controller or reconciliation path, then trace how one Vault path becomes Kubernetes Secret data. Done means defining the multi-path input, merging values into one Kubernetes Secret, handling conflicts and errors, and adding coverage for the requested behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
backend, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.