Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using remote namespace with VaultAuthRef doesn't work with approle secretid unless copied to local namespace #560

Open
MyCodeIsSchmidt opened this issue Jan 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@MyCodeIsSchmidt
Copy link

Describe the bug

Not sure if this is a bug report or feature request, or if its even possible.

When using vauthAuthRef to point to a VaultAuth in an external namespace, it is unable to reference the approle secretid when stored in a kubernetes secret.

apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultStaticSecret
metadata:
  name: test-vault-sync
  namespace: notvault
spec:
  type: kv-v2
  mount: prod
  path: test/config
  destination:
    name: testsecret1
    create: true
  refreshAfter: 30s
  vaultAuthRef: vault/static-auth

apiVersion: secrets.hashicorp.com/v1beta1
kind: VaultAuth
metadata:
  name: static-auth
  namespace: vault
spec:
  method: appRole
  mount: vault-secrets-operator-approle
  vaultConnectionRef: vault/default
  allowedNamespaces:
    - "*"
  appRole:
    roleId: 'xxxx'
    secretRef: vault-secrets-operator-approlesecret

Results in the following error:

Failed to get cacheKey from obj, err=Secret "vault-secrets-operator-approlesecret" not found    {"type": "Warning", "object": {"kind":"VaultStaticSecret","namespace":"notvault
","name":"test-vault-sync","uid":"xxxx","apiVersion":"secrets.hashicorp.com/v1beta1","resourceVersion":"1062772150"}, "reason": "Unrecoverable"}

Failed to get Vault auth login: Secret "vault-secrets-operator-approlesecret" not found    {"type": "Warning", "object": {"kind":"VaultStaticSecret","namespace":"notvault","na
me":"test-vault-sync","uid":"xxxx","apiVersion":"secrets.hashicorp.com/v1beta1","resourceVersion":"1062772150"}, "reason": "VaultClientConfigError"}

As soon as I add the kube secret 'vault-secrets-operator-approlesecret' to the 'notvault' namespace as well, it starts to work again.

Obviously it is not ideal to have to copy the secretid into every namespace that requires it, as rotating that secret would now become costly in an environment with dozens of namespaces. Is there a better way to do this? Or am I asking for something that just isn't possible? Thank you.

Expected behavior

VaultStaticSecret in a namespace outside of the VaultAuth object, but referenced with refVaultAuth, is able to use the secrets referenced in VaultAuth without copying them to the local namespace.

Environment

  • Kubernetes version: GKE 1.26
  • vault-secrets-operator version: 0.4.3
@MyCodeIsSchmidt MyCodeIsSchmidt added the bug Something isn't working label Jan 23, 2024
@AlexanderK46
Copy link

AlexanderK46 commented Mar 20, 2024

Hi!. We also encountered this problem.

The VaultAuth resource containing the reference to the AppRole secret and the Secret resource containing the AppRole SecretID were created in the operator namespace. They are managed by the infrastructure team.

VaultStaticSecret resources have been created in the product namespace. They contain references to the VaultAuth resource with an explicitly specified operator namespace. They are managed by the product team.

The infrastructure team, as the owner of the AppRole SecretID, does not share it with the product team.

We expect that the operator will be able to create Secrets in the product namespace if this namespace is included in the list of allowed ones in the VaultAuth, and we do not need to duplicate the Secret resource containing the AppRole SecretId in the product namespace.

Environment

  • Kubernetes version: 1.25.6
  • vault-secrets-operator version: 0.5.2

@TJM
Copy link

TJM commented Apr 10, 2024

Suggestion: Use Kubernetes Auth. Approle is little more than a username/password, if you use kubernetes auth, you can specify a list of service accounts, in a list of namespaces (hint: '*' works here). You could then avoid having to manage the approle secret in the first place, you just need a kubernetes service account and the VaultAuth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants