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

Always do helm repo update #630

Open
katlimruiz opened this issue Nov 25, 2020 · 16 comments
Open

Always do helm repo update #630

katlimruiz opened this issue Nov 25, 2020 · 16 comments

Comments

@katlimruiz
Copy link

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
@alexsomesan
Copy link
Member

Could you please share the versions of provider and Terraform that you're using?
Also, can you confirm this is happening specifically on Windows?

@anhdle14
Copy link

anhdle14 commented Dec 8, 2020

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

@ghost ghost removed the waiting-response label Dec 8, 2020
@f2calv
Copy link

f2calv commented Dec 11, 2020

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 rancher/quickstart#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!?

@jkroepke
Copy link

jkroepke commented Aug 12, 2021

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.

@j-martin
Copy link

Confirming removing extra repos (helm repo list then helm repo remove <repo>) solved the issue.

@aram-karapetyan-ada
Copy link

Confirming removing extra repos (helm repo list then helm 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.

@vasylenko
Copy link

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
  }
}

@cakriwut
Copy link

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.

@red8888
Copy link

red8888 commented Sep 30, 2022

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?

@vasylenko
Copy link

@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

@felpasl
Copy link

felpasl commented Feb 23, 2023

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.

@uvwildos
Copy link

uvwildos commented May 6, 2023

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.

@KyMidd
Copy link

KyMidd commented Feb 5, 2024

Confirming removing extra repos (helm repo list then helm 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

@sivanagireddyb
Copy link

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.

export HELM_REPOSITORY_CONFIG=repositories.yaml worked for me. Thanks @jkroepke saved my day.

wombelix added a commit to wombelix/fork_rancher_quickstart that referenced this issue Oct 12, 2024
Workaround for:

Error: could not download chart: no cached repo found. (try 'helm repo update')

Refs: hashicorp/terraform-provider-helm#630
Copy link

Marking this issue as stale due to inactivity. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. This helps our maintainers find and focus on the active issues. Maintainers may also remove the stale label at their discretion. Thank you!

@github-actions github-actions bot added the stale label Feb 21, 2025
@tculp
Copy link

tculp commented Feb 27, 2025

Bad bot

@github-actions github-actions bot removed the stale label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests