hashicorp / terraform-provider-helm

Terraform Helm provider
https://www.terraform.io/docs/providers/helm/
Mozilla Public License 2.0
1k stars 370 forks source link

Helm Chart for "stable/instana-agent" not working with terraform 0.13 #567

Closed janekwonner closed 1 year ago

janekwonner commented 4 years ago

Hello together,

we just wanted to install instana-agent chart via terraform. Unfortunately we always get the following error:

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

on 03_service-mesh/instana.tf line 11, in resource "helm_release" "instana-agent": 11: resource "helm_release" "instana-agent" {

I've already read other threads about such issues and tried several things like verify=false but nothing helped to solve the issue.

Attached you will find a screenshot with the terraform resource. Does someone has an idea what's wrong there?

Bildschirmfoto 2020-08-27 um 14 01 36

These are our provider versions:

required_providers { google = { version = "3.36.0" source = "hashicorp/google" } google-beta = { version = "3.36.0" source = "hashicorp/google-beta" } kubectl = { version = "1.6.2" source = "hashicorp/kubectl" } helm = { version = "1.2.3" source = "hashicorp/helm" } kubernetes = { version = "1.12.0" source = "hashicorp/kubernetes" } }

In case of any further detail needed, please contact me.

Thanks in advance!

aareet commented 4 years ago

Hmm, this seems to be working for me

❯ t apply --auto-approve
helm_release.instana-agent: Creating...
helm_release.instana-agent: Creation complete after 7s [id=instana-agent]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
❯ cat main.tf
resource "helm_release" "instana-agent" {
 name = "instana-agent"
 chart = "instana-agent"
verify = false
repository = "https://kubernetes-charts.storage.googleapis.com"
namespace = "default"
}
aareet commented 4 years ago

@janekwonner can you run your apply with HELM_DEBUG=1 and share the output here so we can get more information?

https://github.com/hashicorp/terraform-provider-helm/issues/537#issuecomment-678340453

janekwonner commented 4 years ago

Hi @aareet,

this is the output (I've added "debug = true" to my helm provider). This is the output:

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions in workspace "dev"? Terraform will perform the actions described above. Only 'yes' will be accepted to approve.

Enter a value: yes

module.service_mesh.helm_release.instana-agent: Creating...

Error: no cached repo found. (try 'helm repo update'): open /Users/janek/Library/Caches/helm/repository/helm-index.yaml: no such file or directory

on 03_service-mesh/instana.tf line 11, in resource "helm_release" "instana-agent": 11: resource "helm_release" "instana-agent" {

Yesterday I've already read about that helm-index.yaml and followed some instructions to fix this error. But none of them was successful.

janekwonner commented 4 years ago

Hi @aareet

any news about that?

Thanks in advance!

janekwonner commented 4 years ago

Hi @aareet which provider versions have you used?

ib-ak commented 4 years ago

I am also getting similar error

Error: no cached repo found. (try 'helm repo update'): open C:\Users\ABHINA~1.KHA\AppData\Local\Temp\2\helm\repository\argo-index.yaml: The system cannot find the file specified.

  on modules\argocd.tf line 1, in resource "helm_release" "argo_cd":
   1: resource "helm_release" "argo_cd" {

providers version

Terraform v0.13.4
+ provider registry.terraform.io/hashicorp/aws v2.70.0
+ provider registry.terraform.io/hashicorp/helm v1.3.1
+ provider registry.terraform.io/hashicorp/kubernetes v1.13.2
+ provider registry.terraform.io/hashicorp/local v1.4.0
+ provider registry.terraform.io/hashicorp/null v2.1.2
+ provider registry.terraform.io/hashicorp/random v2.3.0
+ provider registry.terraform.io/hashicorp/template v2.1.2
aareet commented 4 years ago

I'm still having trouble reproducing this. @janekwonner can you share your entire config? Maybe the issue is elsewhere in the config. Or can you reproduce it with a config as simple as below:

❯ cat main.tf
resource "helm_release" "instana-agent" {
 name = "instana-agent"
 chart = "instana-agent"
verify = false
repository = "https://kubernetes-charts.storage.googleapis.com"
namespace = kubernetes_namespace.instana-agent.metadata[0].name
}

resource "kubernetes_namespace" "instana-agent" {
metadata {
  name = "terraform-example-namespace"
 }
}
❯ t apply

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # helm_release.instana-agent will be created
  + resource "helm_release" "instana-agent" {
      + atomic                     = false
      + chart                      = "instana-agent"
      + cleanup_on_fail            = false
      + create_namespace           = false
      + dependency_update          = false
      + disable_crd_hooks          = false
      + disable_openapi_validation = false
      + disable_webhooks           = false
      + force_update               = false
      + id                         = (known after apply)
      + lint                       = false
      + max_history                = 0
      + metadata                   = (known after apply)
      + name                       = "instana-agent"
      + namespace                  = "default"
      + recreate_pods              = false
      + render_subchart_notes      = true
      + replace                    = false
      + repository                 = "https://kubernetes-charts.storage.googleapis.com"
      + reset_values               = false
      + reuse_values               = false
      + skip_crds                  = false
      + status                     = "deployed"
      + timeout                    = 300
      + verify                     = false
      + version                    = "1.0.30"
      + wait                       = true
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

helm_release.instana-agent: Creating...
helm_release.instana-agent: Still creating... [10s elapsed]
helm_release.instana-agent: Still creating... [20s elapsed]
helm_release.instana-agent: Creation complete after 22s [id=instana-agent]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
❯ t version
Terraform v0.13.1
+ provider registry.terraform.io/hashicorp/helm v1.2.4
+ provider registry.terraform.io/hashicorp/kubernetes v1.13.2

Your version of Terraform is out of date! The latest version
is 0.13.4. You can update by downloading from https://www.terraform.io/downloads.html
~/go/src/github.com/aareet/experiments/aug27
❯
ib-ak commented 4 years ago

same error with v0.12.29

Terraform v0.12.29
+ provider.aws v2.70.0
+ provider.helm v1.3.1
+ provider.kubernetes v1.12.0
+ provider.local v1.4.0
+ provider.null v2.1.2
+ provider.random v2.3.0
+ provider.template v2.1.2
ib-ak commented 4 years ago

@aareet

$ tf init

Initializing the backend...

Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "helm" (hashicorp/helm) 1.3.1...
- Downloading plugin for provider "kubernetes" (hashicorp/kubernetes) 1.13.2...

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = "..." constraints to the
corresponding provider blocks in configuration, with the constraint strings  
suggested below.

* provider.helm: version = "~> 1.3"
* provider.kubernetes: version = "~> 1.13"

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

abhinav.khanna@abhinavkha-ltw1 MINGW64 ~/git/temp-tf
$ tf apply

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # helm_release.instana-agent will be created
  + resource "helm_release" "instana-agent" {
      + atomic                     = false
      + chart                      = "instana-agent"
      + cleanup_on_fail            = false
      + create_namespace           = false
      + dependency_update          = false
      + disable_crd_hooks          = false
      + disable_openapi_validation = false
      + disable_webhooks           = false
      + force_update               = false
      + id                         = (known after apply)
      + lint                       = false
      + max_history                = 0
      + metadata                   = (known after apply)
      + name                       = "instana-agent"
      + namespace                  = "terraform-example-namespace"
      + recreate_pods              = false
      + render_subchart_notes      = true
      + replace                    = false
      + repository                 = "https://kubernetes-charts.storage.googleapis.com"
      + reset_values               = false
      + reuse_values               = false
      + skip_crds                  = false
      + status                     = "deployed"
      + timeout                    = 300
      + verify                     = false
      + version                    = (known after apply)
      + wait                       = true
    }

  # kubernetes_namespace.instana-agent will be created
  + resource "kubernetes_namespace" "instana-agent" {
      + id = (known after apply)

      + metadata {
          + generation       = (known after apply)
          + name             = "terraform-example-namespace"
          + resource_version = (known after apply)
          + self_link        = (known after apply)
          + uid              = (known after apply)
        }
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

kubernetes_namespace.instana-agent: Creating...
kubernetes_namespace.instana-agent: Creation complete after 2s [id=terraform-example-namespace]
helm_release.instana-agent: Creating...

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

  on sonarqube.tf line 1, in resource "helm_release" "instana-agent":
   1: resource "helm_release" "instana-agent" {
ib-ak commented 4 years ago

@aareet With helm_debug = 1

$ helm_debug=1 tf apply
kubernetes_namespace.instana-agent: Refreshing state... [id=terraform-example-namespace]

An execution plan has been generated and is shown below.  
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # helm_release.instana-agent will be created
  + resource "helm_release" "instana-agent" {
      + atomic                     = false
      + chart                      = "instana-agent"      
      + cleanup_on_fail            = false
      + create_namespace           = false
      + dependency_update          = false
      + disable_crd_hooks          = false
      + disable_openapi_validation = false
      + disable_webhooks           = false
      + force_update               = false
      + id                         = (known after apply)
      + lint                       = false
      + max_history                = 0
      + metadata                   = (known after apply)
      + name                       = "instana-agent"
      + namespace                  = "terraform-example-namespace"
      + recreate_pods              = false
      + render_subchart_notes      = true
      + replace                    = false
      + repository                 = "https://kubernetes-charts.storage.googleapis.com"
      + reset_values               = false
      + reuse_values               = false
      + skip_crds                  = false
      + status                     = "deployed"
      + timeout                    = 300
      + verify                     = false
      + version                    = (known after apply)
      + wait                       = true
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

helm_release.instana-agent: Creating...

Error: no cached repo found. (try 'helm repo update'): open C:\Users\ABHINA~1.KHA\AppData\Local\Temp\2\helm\repository\argo-index.yaml: The system cannot find the file specified.

  on sonarqube.tf line 1, in resource "helm_release" "instana-agent":
   1: resource "helm_release" "instana-agent" {
aareet commented 4 years ago

@abhinavkhanna-sf what's your helm version?

aareet commented 4 years ago

Possibly some sort of Windows issue? https://github.com/helm/helm/issues/2071

janekwonner commented 4 years ago

Hi @aareet,

another colleague used my code and was able to deploy instana-agent (he has a different helm version installed locally). So this seems to cause the issue - which sounds very strange to me because IMHO terraform shouldn't be dependent on local helm version.

Best regards

ScubaDrew commented 4 years ago
terraform version
Terraform v0.13.4
+ provider registry.terraform.io/hashicorp/aws v3.11.0
+ provider registry.terraform.io/hashicorp/google v3.35.0
+ provider registry.terraform.io/hashicorp/helm v1.3.2
+ provider registry.terraform.io/hashicorp/kubernetes v1.13.2
+ provider registry.terraform.io/hashicorp/local v2.0.0
+ provider registry.terraform.io/hashicorp/template v2.2.0

With HELM_DEBUG=1 terraform apply

Error: no cached repo found. (try 'helm repo update'): open /Users/xxx/Library/Caches/helm/repository/local-index.yaml: no such file or directory

  on ../../../modules/helm/prometheus/prometheus.tf line 20, in resource "helm_release" "prometheus":
  20: resource "helm_release" "prometheus" {

without HELM_DEBUG=1

Error: failed to download "https://github.com/prometheus-community/helm-charts/releases/download/prometheus-11.16.2/prometheus-11.16.2.tgz" (hint: running `helm repo update` may help)

  on ../../../modules/helm/prometheus/prometheus.tf line 20, in resource "helm_release" "prometheus":
  20: resource "helm_release" "prometheus" {
ib-ak commented 4 years ago

@abhinavkhanna-sf what's your helm version?

helm 3.x

ib-ak commented 4 years ago

Possible Workaround

If I run helm repo update every time before running terraform apply, it does not throw any error.

Also, error seems to be on Windows OS only.

Sadarex commented 4 years ago

Hi, i had the same issue (Linux) and found the reason in my case.

If you have unindexed repositories or broken ones (in my case an unworking "local") the helm provider will fail.

unindexed = missing ~/.cache/helm/repository/<reponame>-index.yaml file

You can either fix all broken repositories and index them with "helm repo update" or delete all repositories under "helm repo list". Then the provider will work.

I would consider this a bug from the provider, because it checks ALL configured repositories for their index files. Even if they aren't needed.

a-patel commented 2 years ago

I am also facing same issue for different helm_release prometheus, grafana, loki, nginx ingress controller, metrics server, etc.

github-actions[bot] commented 1 year ago

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[bot] commented 1 year ago

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.