terraform-provider-helm
terraform-provider-helm copied to clipboard
Always do `helm repo update`
Description
I was trying to install the following manifest:
resource "helm_release" "certmanager" {
# name of the installation (release)
name = "cert-manager"
repository = "https://charts.jetstack.io"
chart = "cert-manager"
version = "1.1.0"
namespace = "cert-manager"
create_namespace = true
timeout = 120
}
And it did not work. I set SET HELM_DEBUG=1
and it showed me the following error:
Error: no cached repo found. (try 'helm repo update'): open C:\Users\xxx\AppData\Local\Temp\helm\repository\jetstack-index.yaml: The system cannot find the file specified.
I solved it by doing a manual helm repo update
in the console, then I ran again tf apply
and it worked.
Potential Terraform Configuration
It would be nice to have a new argument so we could decide whether to do a previous helm repo update
.
resource "helm_release" "certmanager" {
# name of the installation (release)
name = "cert-manager"
repository = "https://charts.jetstack.io"
chart = "cert-manager"
version = "1.1.0"
namespace = "cert-manager"
create_namespace = true
timeout = 120
repo_update = true/false
}
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Could you please share the versions of provider and Terraform that you're using? Also, can you confirm this is happening specifically on Windows?
I have the same issues running on Auzre Pipeliens Agents (Ubuntu 20.04) and MacOS (Big Sur 11.1 Beta) locally.
Terraform 0.13.5 Helm 1.3.2
Terraform v0.14.0
- provider registry.terraform.io/hashicorp/azurerm v2.39.0
- provider registry.terraform.io/hashicorp/helm v1.3.2
- provider registry.terraform.io/hashicorp/kubernetes v1.13.3
Initially I ran the below (identical inputs to OP but in a different order...);
resource "helm_release" "helm_jetstack_cert_manager" {
name = "cert-manager"
namespace = "cert-manager"
create_namespace = true
repository = "https://charts.jetstack.io"
chart = "cert-manager"
version = "1.1.0"
timeout = 120
}
I received Error: failed to download "https://charts.jetstack.io/charts/cert-manager-v1.1.0.tgz"
like https://github.com/rancher/quickstart/issues/141 then by just changing the 'order' of the inputs to match OP I then started getting, no cached repo found. (try 'helm repo update')
.
I ran helm repo update
manually and one of my helm repos failed (my ACR repo failed because I hadn't yet authorised via az acr login
), so I removed the XXXXX.azurecr.io helm chart repo and re-ran terraform apply -auto-approve
and cert-manager release was then created with no problem - hope that helps someone.
I don't understand how running the same inputs in a different order would cause different error messages!?
Provider Version: 2.2.0
resource "helm_release" "argo-cd" {
name = "argo-cd"
repository = "https://argoproj.github.io/argo-helm"
chart = "argo-cd"
version = "3.11.1"
namespace = kubernetes_namespace.infra-namespaces["infra-argo-cd"].metadata[0].name
wait = true
timeout = 300
atomic = true
cleanup_on_fail = true
values = [""]
}
I could confirm, this error only occurs, if the local helm installation has some contained helm repo
Based on that, I modified the environment variable HELM_REPOSITORY_CONFIG=repositories.yaml
Then, terraform runs successfully.
Could someone confirm that?
Edit: I could resolve the issue, by setting registry_config_path
inside
provider "helm" {
registry_config_path = "repositories.yaml"
kubernetes {
...
}
}
To the specific value. I could be any value, the file does not need to be exist.
Confirming removing extra repos (helm repo list
then helm repo remove <repo>
) solved the issue.
Confirming removing extra repos (
helm repo list
thenhelm repo remove <repo>
) solved the issue.
You might also need to actually run helm repo update
after removing repo. But worked for me, thank you @j-martin.
My workaround for this issue:
provider "helm" {
repository_config_path = "${path.module}/.helm/repositories.yaml"
repository_cache = "${path.module}/.helm"
kubernetes {
host = module.cluster_linux.cluster_endpoint
cluster_ca_certificate = base64decode(module.cluster_linux.cluster_ca[0].data)
token = data.aws_eks_cluster_auth.this.token
}
}
I notice this issue struck me this time, and the answer is to run "helm repo update" before running helm_release. Previously, I didnt find any problem in my terraform because I deploy some of the resource via helm manually. Then, when I automate everything in terraform - the helm_release complain cannot download the chart *.tgz file. Adding repository_config_path did not help resolve the issue, but running helm repo update resolve the problem.
My workaround for this issue:
provider "helm" { repository_config_path = "${path.module}/.helm/repositories.yaml" repository_cache = "${path.module}/.helm" kubernetes { host = module.cluster_linux.cluster_endpoint cluster_ca_certificate = base64decode(module.cluster_linux.cluster_ca[0].data) token = data.aws_eks_cluster_auth.this.token } }
Im confused about what this is doing. Does it use your local helm cache by default and not run update every time, but if you set it to any other value (even if the folder and repositories.yaml doesn't exist like one poster said) it will update every time?
@red8888, these two strings instruct the provider to look and use the .helm
folder in the same directory where you call Terraform, assuming this is your root (aka project directory) TF module and you don't have provider definitions in child modules, of course.
repository_config_path = "${path.module}/.helm/repositories.yaml"
repository_cache = "${path.module}/.helm"
https://www.terraform.io/language/expressions/references#filesystem-and-workspace-info
I'm runing the automated pipeline in a remote host, but I'm not able to get a Last version of an helm, I'm instaled the helm 6 months ago, and I need update this chart to lastest version, locally works, but runing on pipeline I got 404 error, on same .tf file but with another target, another state backend, and another runner, repository_config_path and repository_cache doesn't change anything, same 404 error.
I am currently considering using the unix ticks as the version in the helm chart to make sure it runs.
in our pipeline project with checked out values next to repo references, we ALWAYS use helm update -- install .....
This should be an option.
Currently (2.9) this is missing badly because a helm update can decide on its own what needs to be changed.
Confirming removing extra repos (
helm repo list
thenhelm repo remove <repo>
) solved the issue.
Confirm this worked for me also. A more elegant solution would be nice, but this quick fix did it for me
Provider Version: 2.2.0
resource "helm_release" "argo-cd" { name = "argo-cd" repository = "https://argoproj.github.io/argo-helm" chart = "argo-cd" version = "3.11.1" namespace = kubernetes_namespace.infra-namespaces["infra-argo-cd"].metadata[0].name wait = true timeout = 300 atomic = true cleanup_on_fail = true values = [""] }
I could confirm, this error only occurs, if the local helm installation has some contained
helm repo
Based on that, I modified the environment variable
HELM_REPOSITORY_CONFIG=repositories.yaml
Then, terraform runs successfully.
Could someone confirm that?
Edit: I could resolve the issue, by setting
registry_config_path
insideprovider "helm" { registry_config_path = "repositories.yaml" kubernetes { ... } }
To the specific value. I could be any value, the file does not need to be exist.
export HELM_REPOSITORY_CONFIG=repositories.yaml
worked for me. Thanks @jkroepke saved my day.