-
Notifications
You must be signed in to change notification settings - Fork 198
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
feat: Enable multiple token caching and add option to disable caching… #660
feat: Enable multiple token caching and add option to disable caching… #660
Conversation
… completely Signed-off-by: sbene <[email protected]>
404604c
to
3a27b24
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #660 +/- ##
==========================================
+ Coverage 72.16% 72.91% +0.74%
==========================================
Files 26 26
Lines 1994 1606 -388
==========================================
- Hits 1439 1171 -268
+ Misses 458 326 -132
- Partials 97 109 +12 ☔ View full report in Codecov by Sentry. |
Can't wait to see this merged soon! |
@DaThumpingRabbit Just a question, does this improve the performance of the plugin? We are experiencing issues in our vault using approle method and vault seals itself. We have around 500 apps using this plugin via Argo. And we see millions of info logs shown below. Wondering if token caching would help here.
|
@sabinayakc It should definitely improve performance as you will contact the vault instance less (as long as there is a valid token for the auth method you are using, it will be used instead of performing a new login) However, it will also depend on your configuration, if you have one approle per app (taking an extreme use case) with a very short TTL, it will do nothing for you (please note that this PR is not available in any current release of the plugin for now, cf #666) |
We are experiencing this issue as well. When will be a new release available containing this fix? It has been merged 30th of September 2024 and not release yet. Thanks |
@jakuboskera @DaThumpingRabbit I went ahead and created a release on my fork since its a bit urgent. https://github.com/sabinayakc/argocd-vault-plugin/releases/tag/v1.18.2 Update the following if you want to use it while we wait for this repo to update.
|
Hmm I just tried it and it is not working as expected. My setup is Vault Enterprise with multiple namespaces (in this example /dev/foo and /dev/bar), JWT Kubernetes auth, one sidecar plugin. Error: # ConfigMap where should be replaced value of .data.title
argocd-repo-server-5c66cb68f5-2tb8q:~$ cat cm.yaml
apiVersion: v1
data:
title: <title>
kind: ConfigMap
metadata:
annotations:
avp.kubernetes.io/path: kv/data/my-app
name: my-app
# no cached token
argocd-repo-server-5c66cb68f5-2tb8q:~$ ls -al /tmp/.avp
total 8
drwxr-xr-x 2 999 root 4096 Feb 13 11:12 .
drwxrwxrwt 1 root root 4096 Feb 13 11:08 ..
# First generate for /dev/foo namespace is ok as there is no cached vault token
argocd-repo-server-5c66cb68f5-2tb8q:~$ cat cm.yaml | VAULT_NAMESPACE=/dev/foo argocd-vault-plugin generate -
apiVersion: v1
data:
title: /dev/foo
kind: ConfigMap
metadata:
annotations:
avp.kubernetes.io/path: kv/data/my-app
name: my-app
---
# vault token cached for /dev/foo
argocd-repo-server-5c66cb68f5-2tb8q:~$ ls -al /tmp/.avp
total 12
drwxr-xr-x 2 999 root 4096 Feb 13 11:13 .
drwxrwxrwt 1 root root 4096 Feb 13 11:08 ..
-rw-r--r-- 1 999 root 133 Feb 13 11:13 kubernetes_config.json
# Second generate for /dev/bar namespace is not ok as cached token is used but this token was issued for /dev/foo namespace
argocd-repo-server-5c66cb68f5-2tb8q:~$ cat cm.yaml | VAULT_NAMESPACE=/dev/bar argocd-vault-plugin generate -
Error: Error making API request.
Namespace: /dev/bar
URL: GET https://vault/v1/kv/data/my-app
Code: 403. Errors:
* 1 error occurred:
* permission denied
Usage:
argocd-vault-plugin generate <path> [flags]
Flags:
-c, --config-path string path to a file containing Vault configuration (YAML, JSON, envfile) to use
--disable-token-cache disable the automatic token cache feature that store tokens locally
-h, --help help for generate
-s, --secret-name string name of a Kubernetes Secret in the argocd namespace containing Vault configuration data in the argocd namespace of your ArgoCD host (Only available when used in ArgoCD). The namespace can be overridden by using the format <namespace>:<name>
--verbose-sensitive-output enable verbose mode for detailed info to help with debugging. Includes sensitive data (credentials), logged to stderr
# still cached vault token for /dev/foo
argocd-repo-server-5c66cb68f5-2tb8q:~$ ls -al /tmp/.avp
total 12
drwxr-xr-x 2 999 root 4096 Feb 13 11:13 .
drwxrwxrwt 1 root root 4096 Feb 13 11:08 ..
-rw-r--r-- 1 999 root 133 Feb 13 11:13 kubernetes_config.json
argocd-repo-server-5c66cb68f5-2tb8q:~$
# remove cached token for /dev/foo namespace
argocd-repo-server-5c66cb68f5-2tb8q:~$ rm -v /tmp/.avp/kubernetes_config.json
removed '/tmp/.avp/kubernetes_config.json'
# Third generate for /dev/bar namespace when cached token for /dev/foo was removed
argocd-repo-server-5c66cb68f5-2tb8q:~$ cat cm.yaml | VAULT_NAMESPACE=/dev/bar argocd-vault-plugin generate -
apiVersion: v1
data:
title: /dev/bar
kind: ConfigMap
metadata:
annotations:
avp.kubernetes.io/path: kv/data/my-app
name: my-app
---
# vault token cached for /dev/foo
argocd-repo-server-5c66cb68f5-2tb8q:~$ ls -al /tmp/.avp
total 12
drwxr-xr-x 2 999 root 4096 Feb 13 11:22 .
drwxrwxrwt 1 root root 4096 Feb 13 11:08 ..
-rw-r--r-- 1 999 root 133 Feb 13 11:22 kubernetes_config.json However when I use |
@jakuboskera indeed the kubernetes auth is stored in a single cache with that update because I did not see on what parameter to build the filename I could work on another PR that would look for the VAULT_NAMESPACE environment variable and use that to build different cache files, it should solve your issue I will try to work on this soon and I'll let you know |
Thanks @DaThumpingRabbit. For now I will use App Role which create separated cache files according ROLE ID which is for me ok now. |
@jakuboskera |
Description
Due to the previous PR #544 fixing the cache behavior, users are not able to use multiple credentials anymore with the same AVP
This new PR's goal is to fix that issue by adding the following features
Fixes: #658
Checklist
Please make sure that your PR fulfills the following requirements:
go mod tidy -compat=1.21
to ensure only the minimum is pulled in.Type of Change