argocd-vault-plugin
argocd-vault-plugin copied to clipboard
`sh -c helm dependency build ` failed exit status 1: Error: no cached repository
Describe the bug An Argo CD application is configured to use the vault plugin with an umbrella Helm Chart hosted in git:
apiVersion: argoproj.io/v1alpha1
kind: Application
(...)
source:
plugin:
name: argocd-vault-plugin-helm
path: the/path
repoURL: 'ssh://[email protected]:7999/repos/repo.git'
targetRevision: thebranch
(...)
The umbrella Chart has another Helm Chart as dependency.
apiVersion: v2
(...)
dependencies:
- name: another-chart
version: 0.1.5
repository: https://helm-example.com/charts/name/helm-poc
The plugin is configured like this:
configManagementPlugins: |
- name: argocd-vault-plugin
generate:
command: ["argocd-vault-plugin"]
args: ["generate", "./"]
- name: argocd-vault-plugin-helm
init:
command: [sh, -c]
args: ["helm dependency build"]
generate:
command: ["sh", "-c"]
args: ["helm template $ARGOCD_APP_NAME . | argocd-vault-plugin generate -"]
Both the git repo and the Helm repo are successfully added in Argo CD as repositories. The "helm dependency build" command fails with the following error message:
rpc error: code = Unknown desc = Manifest generation error (cached): `sh -c helm dependency build ` failed exit status 1: Error: no cached repository for helm-manager-9894e008a23e82901a4adbd36642eca2d4d8848dbfd3afba46e82d8c440a41de found. (try 'helm repo update'): open /.cache/helm/repository/helm-manager-9894e008a23e82901a4adbd36642eca2d4d8848dbfd3afba46e82d8c440a41de-index.yaml: no such file or directory
Expected behavior Dependencies should be downloaded
Additional context Red Hat OpenShift GitOps 1.5.5 argocd-vault-plugin v1.12.0 OpenShift version 4.8.44 Kubernetes version v1.21.11+6b3cbdd Argo CD { "Version": "v2.3.7+unknown", "BuildDate": "2022-08-01T21:40:18Z", "GitTreeState": "clean", "GoVersion": "go1.17.12", "Compiler": "gc", "Platform": "linux/amd64", "KsonnetVersion": "unable to determine ksonnet version: exec: "ks": executable file not found in $PATH", "KustomizeVersion": "v4.4.1 1970-01-01T00:00:00Z", "HelmVersion": "v3.8.0+g7ddadb4", "KubectlVersion": "v0.23.1", "JsonnetVersion": "v0.18.0" }
This might help https://github.com/argoproj/argo-cd/issues/7768 i dont think this is an AVP issue but a larger Helm with Argo CD thing.
You get this error
open /.cache/helm/repository/helm-manager-9894e008a23e82901a4adbd36642eca2d4d8848dbfd3afba46e82d8c440a41de-index.yaml: no such file or directory
because helm has no permission to write the directory /.cache.
Here, setting the HOME environment variable to /tmp has solved the issue.
Here, setting the HOME environment variable to /tmp has solved the issue.
For more fine-grained control, it's also possible to set just Helm variables:
HELM_CACHE_HOMEto/tmp/helm/cacheHELM_CONFIG_HOMEto/tmp/helm/configHELM_DATA_HOMEto/tmp/helm/data
After this, there may still be an error because Helm doesn't know about the dependency repo. There are two options:
helm repo add <name> <url>for every repo that you needhelm dependency updateinstead ofhelm dependency build- this will ignore the lock file, but doesn't require adding repos
I think I ran into a similar issue. I got the following error in my ArgoCD UI:
rpc error: code = Unknown desc = Manifest generation error (cached): plugin sidecar failed. error generating manifests in cmp: rpc error: code = Unknown desc = error generating manifests: `sh -c "helm registry login \"$HELM_REGISTRY_URL\" -u \"$HELM_REGISTRY_USERNAME\" -p \"$HELM_REGISTRY_PASSWORD\" && helm dependency build"` failed exit status 1: WARNING: Using --password via the CLI is insecure. Use --password-stdin. Login Succeeded Error: no repository definition for https://charts.bitnami.com/bitnami. Please add the missing repos via 'helm repo add'
I also used helm dependency build.
Add env HELM_CACHE_HOME in repo server solved my issue, argo version 2.3.4
I spent quite some time trying to set this plugin up for applications with dependencies. Turns out it's easier to not go through all these hoops to restore default behavior and instead use https://github.com/crumbhole/argocd-lovely-plugin which has a nice feature to chain plugins.
There's also a build of it which has this vault plugin bundled and ready to use out of the box.