Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Lease TTL (with dynamic secrets Vault backend) #766

Closed
zarko-a opened this issue Jun 2, 2021 · 11 comments
Closed

Lease TTL (with dynamic secrets Vault backend) #766

zarko-a opened this issue Jun 2, 2021 · 11 comments
Labels
enhancement New feature or request Stale vault

Comments

@zarko-a
Copy link

zarko-a commented Jun 2, 2021

Hi there,

I started testing KES and it works quite well with static KV secrets (where retrieved secret is always the same). But as soon as I tried to use it with AWS secret engine from HashiCorp Vault I noticed a potential problem.

KES reads the secret based on the POLLER_INTERVAL_MILLISECONDS which defaults to 10s. HashiCorp Vault provisions AWS IAM user each time a secret is read and this causes multiplication of IAM users. In our specific case, we also need to restart the application pod to reload the secret, so it's not really practical to do it frequently.

TLDR:

  1. I'm wondering if it's possible for KES to utilize lease TTL information for secret polling. Is this supported?
  2. Is KES even meant to be used with dynamically provisioned AWS credentials (or only with static)?
  3. Can KES use lease lookup to query if lease is active instead of polling the secret? Specifically Vault API provides lease lookup with expiry information. https://www.vaultproject.io/api/system/leases

I realize I can increase the global polling interval, but then rotating the credentials on demand would require a change to that value, at least temporarily. Also, if polling is missed due to some outage, the leases can expire without KES being aware and impacting applications.

@moolen
Copy link
Member

moolen commented Jun 14, 2021

Are you refering to this feature: https://www.vaultproject.io/docs/secrets/aws ?

So, you use vault to generate an IAM users ? That's not a use-case previously covered with KES. Generating AWS IAM users is (generally) considered an anti-pattern (there may be exceptions to this rule).

I'm wondering if it's possible for KES to utilize lease TTL information for secret polling

No, that's not supported. every secret/poller iteration get it's own new, fresh client to fetch secrets from.

Is KES even meant to be used with dynamically provisioned AWS credentials

If you're running on AWS there's no need to use static credentials, just attach an IAM Roles to KES. When running in EKS: you should use IRSA.

Can KES use lease lookup to query if lease is active instead of polling the secret?

I'm not sure if i correctly understand you use-case. I think supporting the AWS secrets engine in Vault would essentially be a new secret provider (RN we support the Vault KV engine only). To answer your question: sure, the new provider should preferably use the lease semantics!

@moolen moolen added vault enhancement New feature or request labels Jun 14, 2021
@zarko-a
Copy link
Author

zarko-a commented Jun 23, 2021

Thanks for the reply @moolen

Are you refering to this feature: https://www.vaultproject.io/docs/secrets/aws ?

Yes.

So, you use vault to generate an IAM users ? That's not a use-case previously covered with KES. Generating AWS IAM users is (generally) considered an anti-pattern (there may be exceptions to this rule).

Yes, we generate IAM users and associated keys (keys are the main goal). Maybe I'm missing something, but if we have an application that runs outside AWS and needs access to AWS I don't see many ways of providing access. We are using Vault's AWS secrets engine to provision dynamic/ephemeral credentials for apps that don't have native Vault support.

I'm not sure if i correctly understand you use-case. I think supporting the AWS secrets engine in Vault would essentially be a new secret provider (RN we support the Vault KV engine only). To answer your question: sure, the new provider should preferably use the lease semantics!

Primary focus of this use case is providing AWS dynamic credentials to an app that has no Vault awareness. Hence we started looking into KES to update existing Kubernetes secrets automatically.
Thanks for confirming this is not really supported, I thought I was missing something.

A disappointed that only KV engine is supported in KES considering the main advantage of Vault lies in dynamically provisioned credentials.

@vaidik
Copy link

vaidik commented Jul 30, 2021

There is a use-case for lease based rotating credentials when using databases such as postgres. Vault can be configured to generate credentials when the lease is about to expire. Can KES handle that in a graceful way that credentials generated after the lease expires - the new credentials are exposed to pods transparently and there is a way to gracefully reload the application or restart the pods?

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Oct 29, 2021
@github-actions github-actions bot removed the Stale label Nov 16, 2021
@derbeneviv
Copy link

+1 to the request.
Common use-cases are:

dynamodb credentials (aws secret engine)
database credentials (https://www.vaultproject.io/docs/secrets/databases secret engine)
SSH keys (https://www.vaultproject.io/docs/secrets/ssh)

well, mostly all places, where HashiVault is used for dynamic secret generation

@Flydiverny
Copy link
Member

See #864
That said a PR would still be possible

@vaidik
Copy link

vaidik commented Dec 29, 2021

Is this still being tracked actively for ESO? I think this will be a great feature to have. Literally the only blocker right now for us to roll out ESO in my company.

@justinas-b
Copy link
Contributor

+1 interested in this

@Flydiverny
Copy link
Member

Is this still being tracked actively for ESO? I think this will be a great feature to have. Literally the only blocker right now for us to roll out ESO in my company.

I think it's best to make a new issue in ESO repo if this isn't available in ESO!

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Apr 15, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request Stale vault
Projects
None yet
Development

No branches or pull requests

6 participants