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

webhook: transit engine use batch api calls for better performance #1697

Merged

Conversation

BojanZelic
Copy link
Contributor

@BojanZelic BojanZelic commented Oct 12, 2022

Q A
Bug fix? no
New feature? yes
API breaks? no
Deprecations? no
Related tickets n/a
License Apache 2.0

What's in this PR?

This PR improves performance when using the transit engine with lots of secrets coming in from vault;

Why?

When you have lots of secrets that use the transit engine, the webhook is really slow to respond; This is because it's making N number of API calls to vault; We can leverage batch_input to send multiple secrets at once, reducing the overhead and improving the response time of the webhook.

For example - If I have a secret with 20 Values coming from vault... previously this would take about 1.5-2 seconds for the webhook to respond; After this PR since it's only making 1 API call, it takes < 250 ms

Additional context

I've tested it extensively with ConfigMaps, and Secrets; The code for secret mutation was simplified in order to share the logic for prefetching transit secrets;

Mutating Custom Resources or Pods still has the old behavior

Checklist

@BojanZelic BojanZelic force-pushed the batch-decrypt-transit-secrets branch 4 times, most recently from 6b3c78e to c07def4 Compare October 13, 2022 17:23
@BojanZelic BojanZelic force-pushed the batch-decrypt-transit-secrets branch from c07def4 to b1271dd Compare October 13, 2022 17:50
@bonifaido bonifaido self-assigned this Nov 2, 2022
Copy link
Member

@bonifaido bonifaido left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thank you!

@bonifaido bonifaido merged commit 62200bf into bank-vaults:main Nov 2, 2022
NitriKx referenced this pull request in NitriKx/bank-vaults Jan 27, 2023
Since https://github.com/banzaicloud/bank-vaults/pull/1697 we are experimenting
issues with `vault-env`: the generated environment has all the `vault:` env
vars duplicated, one version in its original version and a second one with the
secret instead of the token.

I have noticed that the new `preprocessTransitSecrets` is calling `inject` even
 if nothing has been replaced with values from the transit cache. In case you
are working with "maps" (ConfigMap, Secret) this does not matter as the "old"
code will still overwrite the key with the secret. But in the case of
`vault-env` you will have the same env var set twice and most the the time only
 the first occurence (without the secret) is taken into account.
NitriKx referenced this pull request in backmarket-oss/bank-vaults Feb 1, 2023
Since https://github.com/banzaicloud/bank-vaults/pull/1697 we are experimenting
issues with `vault-env`: the generated environment has all the `vault:` env
vars duplicated, one version in its original version and a second one with the
secret instead of the token.

I have noticed that the new `preprocessTransitSecrets` is calling `inject` even
 if nothing has been replaced with values from the transit cache. In case you
are working with "maps" (ConfigMap, Secret) this does not matter as the "old"
code will still overwrite the key with the secret. But in the case of
`vault-env` you will have the same env var set twice and most the the time only
 the first occurence (without the secret) is taken into account.
NitriKx referenced this pull request in backmarket-oss/bank-vaults Feb 2, 2023
fix: fix vault-env generated env which may contain duplicates

Since https://github.com/banzaicloud/bank-vaults/pull/1697 we are experimenting
issues with `vault-env`: the generated environment has all the `vault:` env
vars duplicated, one version in its original version and a second one with the
secret instead of the token.

I have noticed that the new `preprocessTransitSecrets` is calling `inject` even
 if nothing has been replaced with values from the transit cache. In case you
are working with "maps" (ConfigMap, Secret) this does not matter as the "old"
code will still overwrite the key with the secret. But in the case of
`vault-env` you will have the same env var set twice and most the the time only
 the first occurence (without the secret) is taken into account.

build: try to use chart-releaser to publish our chart in GitHub pages

build: only consider tags ending with `+bm`

build: fix the registry when building the docker images

build: fix yaml syntax

build: use `-bm` suffix docker images and binaries (and `+bm` for helm charts)

build: use chart-releaser to package the helm chart

build: relies on versioning in the Charts.yaml to make chart-releaser happy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants