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

data helm_repository requires helm repo update #438

Closed
mllu opened this issue Mar 12, 2020 · 14 comments
Closed

data helm_repository requires helm repo update #438

mllu opened this issue Mar 12, 2020 · 14 comments

Comments

@mllu
Copy link

mllu commented Mar 12, 2020

Terraform Version

Terraform v0.12.23

Affected Resource(s)

helm_repository

Terraform Configuration Files

data "helm_repository" "my_repo" {
  name = "$MY_REPO_NAME"
  url  = "https://$MY_REPO_CHART.com"
}

resource "helm_release" "my_release" {
  name       = "my-release"
  repository = data.helm_repository.my_repo.metadata[0].name
  chart      = "$MY_CHART_NAME"
  ...
  depends_on = [
    data.helm_repository.my_repo,
  ]
}

Debug Output

�Terraform v0.12.23
Initializing plugins and modules...
2020/03/12 01:01:26 [DEBUG] Using modified User-Agent: Terraform/0.12.23 TFC/1fc524aa9c
helm_release.my_release: Modifying... [id=my-release]

Error: failed to download "$MY_REPO_NAME/$MY_CHART_NAME" (hint: running `helm repo update` may help)

Expected Behavior

helm_repository data resource should help download required charts

Actual Behavior

The corresponding terrafoom apply on Terraform cloud showed the above error message asking to run helm repo update

@busbyjon
Copy link

+1 also seeing this issue

@kevincheema
Copy link

+1 also seeing this as well

@mllu
Copy link
Author

mllu commented Mar 13, 2020

I kinda work around by appending uuid after the name value of helm_repository, but the side effect is it get updated every time.

@jrhouston
Copy link
Contributor

I suspect this is the same issue as #416

@miguel-chacon
Copy link

Replacing data.helm_repository.my_repo.metadata[0].name by data.helm_repository.my_repo.metadata[0].url works

@nagonzalez
Copy link

I'm ditching the data helm_repository altogether and just hardcoding the chart info. See below:

# install kube2iam helm chart
resource "helm_release" "kube2iam" {

  repository = "https://kubernetes-charts.storage.googleapis.com"
  chart      = "kube2iam"
  version    = var.eks_addon_kube2iam_helm_version
  name       = "kube2iam"
  namespace  = "kube-system"

  values = [
    <<EOT
extraArgs:
  auto-discover-base-arn: ''
  default-role: ${module.iam_assumable_role_default.this_iam_role_name}
host:
  iptables: true
  interface: eni+
rbac:
  create: true
verbose: true
EOT
  ]
}

@timmjd
Copy link

timmjd commented Apr 16, 2020

Thanks for the hint!
Taking the URL for the repository seems to work only if you also apply the version.

If version is missing:

Error: failed to download "https://kubernetes-charts.storage.googleapis.com/jenkins-1.9.24.tgz" (hint: running `helm repo update` may help)

  on .terraform/modules/jenkins/main.tf line 13, in resource "helm_release" "helm":
  13: resource "helm_release" "helm" {

The root of the issue seems to be:

  • The data "helm_repository" is triggering the download of the chart.
  • If you use this data as input for the resource "helm_release" this will lead to an error if you simply follow the example:
    • If you make use of terraform plan -out out.plan copy the out.plan to a different machine and do trigger the terraform apply out.plan there.

Doing so will lead to the error:

Error: failed to download "stable/jenkins" (hint: running `helm repo update` may help)

  on .terraform/modules/jenkins/main.tf line 18, in resource "helm_release" "helm":
  18: resource "helm_release" "helm" {

So the requirement to checkout the chart is part of the terraform plan and the dependency to checkout is not stored within the outputted plan out.plan.

@MajorBreakfast
Copy link

MajorBreakfast commented Apr 23, 2020

We're running into this issue as well. We have exactly a setup as @timmjd describes: In our case we're running GitLab. We have a plan and an apply ci job and they both run in Docker containers. The plan job generates the plan which is then passed as an artifact to the apply job. Then, the apply job fails applying it with an error like above.

viccuad added a commit to SUSE/cap-terraform that referenced this issue Apr 27, 2020
When installing external-dns, it doesn't do helm update:
  Error: failed to download "bitnami/external-dns" (hint: running `helm repo update` may help)
See: hashicorp/terraform-provider-helm#438

Using the .url instead of .name (and therefore changing the chart name too)
fixes it.
viccuad added a commit to SUSE/cap-terraform that referenced this issue Apr 27, 2020
When installing external-dns, it doesn't do helm update:
  Error: failed to download "bitnami/external-dns" (hint: running `helm repo update` may help)
See: hashicorp/terraform-provider-helm#438

Using the .url instead of .name (and therefore changing the chart name too)
fixes it.
satadruroy pushed a commit to SUSE/cap-terraform that referenced this issue Apr 27, 2020
When installing external-dns, it doesn't do helm update:
  Error: failed to download "bitnami/external-dns" (hint: running `helm repo update` may help)
See: hashicorp/terraform-provider-helm#438

Using the .url instead of .name (and therefore changing the chart name too)
fixes it.
@Bluesboy
Copy link

Bluesboy commented May 4, 2020

As a workaround I defined URL to chart in the chart field like that:

resource "helm_release" "external_dns" {
  name       = "dns-bot"
  chart      = "https://kubernetes-charts.storage.googleapis.com/external-dns-2.14.1.tgz"
  namespace  = "kube-system"
  values = [
    "${file("external-dns/values.yaml")}"
  ]
}

Everything works fine. However I use terraform-0.12.24. Hope it helps.

@mbarrien
Copy link

mbarrien commented May 7, 2020

Note that in #466 the helm_repository data source has been deprecated, with the new recommended way is putting the repo URL directly in as the "repository" field of the helm_release.

@MajorBreakfast
Copy link

With the docs now clearly saying that the repo data source is deprecated and the example on the helm_release page updated without it, I think this issue can be closed.

@mllu
Copy link
Author

mllu commented May 7, 2020

sounds good to me, will close this issue.

@mllu mllu closed this as completed May 7, 2020
@tcoates1362
Copy link

Posting this in case someone else lands here looking for answers.

I was still having issues after removing the data source and converting to using the repo url in the "repository" field.

Example:

resource "helm_release" "gitlab" {
  name = "gitlab"
  repository = "https://charts.gitlab.io"
  chart = "gitlab"
  version = "3.3.3"
  namespace = "gitlab"
...
}

would yield:

helm_release.gitlab: Creating...

Error: failed to download "https://gitlab-charts.s3.amazonaws.com/gitlab-3.3.3.tgz" (hint: running `helm repo update` may help)

  on tf\gitlab.tf line 60, in resource "helm_release" "gitlab":
  60: resource "helm_release" "gitlab" {

I ended up clearing out my helm cache which resolved the issue. Apparently if you've installed the chart prior to converting, there are some remnants left that cause issues.

@ghost
Copy link

ghost commented Jun 7, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Jun 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests