aws-ia / terraform-aws-eks-blueprints

Configure and deploy complete EKS clusters.
https://aws-ia.github.io/terraform-aws-eks-blueprints/
Apache License 2.0
2.71k stars 1.42k forks source link

[Bug]: could not download chart: Chart.yaml file is missing #825

Closed kderck closed 1 year ago

kderck commented 2 years ago

Welcome to Amazon EKS Blueprints!

Amazon EKS Blueprints Release version

v4.6.1

What is your environment, configuration and the example used?

My terragrunt.hcl

Terraform v1.1.1
on darwin_arm64
+ provider registry.terraform.io/gavinbunney/kubectl v1.14.0
+ provider registry.terraform.io/hashicorp/aws v4.25.0
+ provider registry.terraform.io/hashicorp/helm v2.6.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.12.1
+ provider registry.terraform.io/hashicorp/time v0.7.2
terragrunt version v0.36.3

What did you do and What did you see instead?

 Error: could not download chart: Chart.yaml file is missing
│ 
│   with module.metrics_server[0].module.helm_addon.helm_release.addon[0],
│   on helm-addon/main.tf line 1, in resource "helm_release" "addon":
│    1: resource "helm_release" "addon" {
│ 
╵
╷
│ Error: could not download chart: Chart.yaml file is missing
│ 
│   with module.prometheus[0].module.helm_addon.helm_release.addon[0],
│   on helm-addon/main.tf line 1, in resource "helm_release" "addon":
│    1: resource "helm_release" "addon" {
│ 
╵
╷
│ Error: could not download chart: Chart.yaml file is missing
│ 
│   with module.cluster_autoscaler[0].module.helm_addon.helm_release.addon[0],
│   on helm-addon/main.tf line 1, in resource "helm_release" "addon":
│    1: resource "helm_release" "addon" {
│ 
╵
╷
│ Error: could not download chart: Chart.yaml file is missing
│ 
│   with module.aws_load_balancer_controller[0].module.helm_addon.helm_release.addon[0],
│   on helm-addon/main.tf line 1, in resource "helm_release" "addon":
│    1: resource "helm_release" "addon" {
│ 
╵
ERRO[0086] 1 error occurred:
        * exit status 1

Additional Information

I have tried https://github.com/aws-ia/terraform-aws-eks-blueprints/issues/785.
Zvikan commented 2 years ago

Thank you for reporting this. Can you please run this with TRACE/debug mode and see where the chart is being downloaded from?

A quick search showed https://github.com/hashicorp/terraform-provider-helm/issues/735 which might be the issue, please take a look and let me know if that helps.

Another thing that I saw in your terragrunt.hcl missing under the addons:

  eks_cluster_endpoint = module.eks_blueprints.eks_cluster_endpoint
  eks_oidc_provider    = module.eks_blueprints.oidc_provider
  eks_cluster_version  = module.eks_blueprints.eks_cluster_version

(make sure to replace module.eks_blueprints... with the relevant dependency setup you have)

Some charts might use the cluster version (cluster-autoscaler IIRC) as part of the chart version, not sure if this is related but worth to try as-well.

kderck commented 2 years ago

Hi.

I've added ...

eks_cluster_id              = dependency.kubernetes.outputs.cluster_id
eks_cluster_endpoint = dependency.kubernetes.outputs.cluster_endpoint
eks_oidc_provider      = dependency.kubernetes.outputs.oidc_provider
eks_cluster_version   = dependency.kubernetes.outputs.cluster_version  

And I still get...

Error: could not download chart: Chart.yaml file is missing

I'm doing a trace now.

kderck commented 2 years ago

Please find the Debug Logs.

Zvikan commented 2 years ago

Hmmm...unfortunately I couldn't see anything interesting from the logs, wanted to check if it's actually downloading the chart from the correct place.

Do you mind trying this without Terragrunt and see if its working? Also, did you check the provider issues I linked above?

kderck commented 2 years ago

Hi @Zvikan. Please allow me some time to come back to this, I can see the log is incomplete. I will spike and come back to you with a log and any other discoveries I've found.

epalchan commented 2 years ago

Hi @Zvikan, I'm encountering the same exact issue. I was able to temporarily resolve it by cloning the repo and changing the folder names and source references to them in the modules (simple name changes of - to _) and pointing my terragrunt source to the local folder.

When pointing terragrunt directly to the modules folder on the repo I'm getting the same- │ Error: could not download chart: Chart.yaml file is missing

kderck commented 2 years ago

Can confirm issue seems to be - in folder names.

Zvikan commented 2 years ago

Hey folks, I just finished testing this again, I can confirm that I can reproduce the steps mentioned in https://github.com/hashicorp/terraform-provider-helm/issues/735 . If I created empty folder in the example root example folder (where i'm running the terraform commands), where the folder name is the same as the chart name (e.g. a folder named prometheus), I will get the Chart.yaml file is missing , as mentioned in https://github.com/hashicorp/terraform-provider-helm/issues/735#issuecomment-828779466 this is how helm works.

To my understanding, we need to make sure that wherever we run the terraform commands, there's no folder matching the chart name, otherwise helm will pick that folder path and will check its structure and dependencies, leading to the Chart.yaml missing error.

I haven't tested this with terragrunt yet, but without it I can't reproduce this issue (using the k8s-addons module as local/remote git source), I believe that terragrunt is running within the module folder path itself, that's why you may see this behavior with terragrunt only.

I'm not a terragrunt expert, but I wonder if there's a way to tell terragrunt to run TF commands from specific folder? maybe the terragrunt-working-dir arg?

epalchan commented 2 years ago

Hi @Zvikan, Due to the fact that terragrunt is just a wrapper for terraform, it caches the referenced source terraform folder structure from the git repo in the terragrunt-download-dir as it currently is, without making any modifications to the files/folders within.

The terragrunt-working-dir only controls which folder to find the terragrunt .hcl files within, which are the ones referencing the terraform modules.

For reference, this is the dry inputs block in my terragrunt.hcl file which is used to call the modules at /modules/kubernetes-addons:

inputs = {
    eks_cluster_endpoint                =   dependency.cluster.outputs.cluster_endpoint
    eks_cluster_id                      =   dependency.cluster.outputs.cluster_id
    eks_cluster_version                 =   dependency.cluster.outputs.cluster_version
    eks_oidc_provider                   =   dependency.cluster.outputs.cluster_oidc_issuer_url
    eks_worker_security_group_id        =   dependency.cluster.outputs.node_security_group_id

    enable_metrics_server               =   true
    enable_kubernetes_dashboard         =   true

    metrics_server_helm_config          =   local.helm_values.inputs.metrics_server_helm_config

    tags                                =   dependency.label.outputs.tags
}

I've used this for testing so far and am planning on adding additional modules as we test them out one at a time, but can't implement this due to the current folder names matching the helm chart names.

ThaSami commented 2 years ago

any solution here? having the same issue with terragrunt and eks-addons

ThaSami commented 2 years ago

The following workaround works. in terragrunt.hcl you need to put the direct link for the chart and remove repository and version.

  enable_metrics_server               = true
  metrics_server_helm_config = {
  name                       = "metrics-server"
  chart                      = "https://github.com/kubernetes-sigs/metrics-server/releases/download/metrics-server-helm-chart-3.8.2/metrics-server-3.8.2.tgz"
  repository                 = ""
  version                     =  ""
  namespace                  = "kube-system"
  }
danygielow commented 2 years ago

I also had this problem with terragrunt.

My workaround was to not use the kubernetes-addons module directly, but to create an intermediate terraform module which then uses the kubernetes-addons module. This way the helm_release resource context is different and it doesn't find the similarly named directories.

In terragrunt.hcl:

terraform {
  source = "${get_repo_root()}/modules/kubernetes-addons"
}

And in the modules/kubernetes-addons/main.tf:

module "kubernetes_addons" {
    source = "git@github.com:aws-ia/terraform-aws-eks-blueprints.git//modules/kubernetes-addons/?ref=v4.12.1"
    ...
}
AErmie commented 2 years ago

I'm also experiencing this issue with the latest Blueprint release (v4.12.2). However, I'm not using TerraGrunt at all, I'm just calling the module from the source (source = "github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons?ref=v4.12.2").

│ Error: could not download chart: looks like "[https://aws.github.io/eks-charts"](https://aws.github.io/eks-charts%22) is not a valid chart repository or cannot be reached: open /.cache/helm/repository/eL69i4IpgmNHWlXNPGw8YGtS1E8=-index.yaml: no such file or directory with module.eks_blueprints_kubernetes_addons.module.aws_for_fluent_bit[0].module.helm_addon.helm_release.addon[0], on .terraform/modules/eks_blueprints_kubernetes_addons/modules/kubernetes-addons/helm-addon/main.tf line 1, in resource "helm_release" "addon":
│    1: resource "helm_release" "addon" {

│ Error: could not download chart: looks like "[https://kubernetes-sigs.github.io/metrics-server/"](https://kubernetes-sigs.github.io/metrics-server/%22) is not a valid chart repository or cannot be reached: open /.cache/helm/repository/6lXb-uVFtpEGjA757okrE62EazU=-index.yaml: no such file or directory with module.eks_blueprints_kubernetes_addons.module.metrics_server[0].module.helm_addon.helm_release.addon[0], on .terraform/modules/eks_blueprints_kubernetes_addons/modules/kubernetes-addons/helm-addon/main.tf line 1, in resource "helm_release" "addon":
│    1: resource "helm_release" "addon" {

│ Error: could not download chart: looks like "[https://argoproj.github.io/argo-helm"](https://argoproj.github.io/argo-helm%22) is not a valid chart repository or cannot be reached: open /.cache/helm/repository/OELa7V5FYkwirMLcE1KvKEzCEps=-index.yaml: no such file or directory with module.eks_blueprints_kubernetes_addons.module.argocd[0].module.helm_addon.helm_release.addon[0], on .terraform/modules/eks_blueprints_kubernetes_addons/modules/kubernetes-addons/helm-addon/main.tf line 1, in resource "helm_release" "addon":
│    1: resource "helm_release" "addon" {

│ Error: could not download chart: looks like "[https://aws.github.io/eks-charts"](https://aws.github.io/eks-charts%22) is not a valid chart repository or cannot be reached: open /.cache/helm/repository/BD6W6OeuqNxOXE8JbWv7F-6HGWI=-index.yaml: no such file or directory with module.eks_blueprints_kubernetes_addons.module.aws_load_balancer_controller[0].module.helm_addon.helm_release.addon[0], on .terraform/modules/eks_blueprints_kubernetes_addons/modules/kubernetes-addons/helm-addon/main.tf line 1, in resource "helm_release" "addon":
│    1: resource "helm_release" "addon" {

│ Error: could not download chart: looks like "[https://prometheus-community.github.io/helm-charts"](https://prometheus-community.github.io/helm-charts%22) is not a valid chart repository or cannot be reached: open /.cache/helm/repository/uIVrF5yQHNcVcJdhPDyTKQQZ98g=-index.yaml: no such file or directory with module.eks_blueprints_kubernetes_addons.module.prometheus[0].module.helm_addon.helm_release.addon[0], on .terraform/modules/eks_blueprints_kubernetes_addons/modules/kubernetes-addons/helm-addon/main.tf line 1, in resource "helm_release" "addon":
│    1: resource "helm_release" "addon" {

│ Error: could not download chart: looks like "[https://kubernetes.github.io/autoscaler"](https://kubernetes.github.io/autoscaler%22) is not a valid chart repository or cannot be reached: open /.cache/helm/repository/7uR5TZKcgSnoUpe9s7ifdF2bRyE=-index.yaml: no such file or directory with module.eks_blueprints_kubernetes_addons.module.cluster_autoscaler[0].module.helm_addon.helm_release.addon[0], on .terraform/modules/eks_blueprints_kubernetes_addons/modules/kubernetes-addons/helm-addon/main.tf line 1, in resource "helm_release" "addon":
│    1: resource "helm_release" "addon" {
mldevpants commented 1 year ago

Hi Thanks to @danygielow , I've followed his workaround and it finally worked. I've been hitting the wall for the past month, and I can't believe I didn't find this thread earlier. I just copied the variables.tf from the main addons folder, added the relevant part:

module "kubernetes_addons" {
  source = "git@github.com:aws-ia/terraform-aws-eks-blueprints.git//modules/kubernetes-addons/?ref=v4.14.0"
  # EKS Data
  eks_cluster_id       = var.eks_cluster_id
  eks_oidc_provider    = var.eks_oidc_provider
  eks_cluster_endpoint = var.eks_cluster_endpoint
  eks_cluster_version  = var.eks_cluster_version

  # EKS Managed Add-ons
  enable_amazon_eks_vpc_cni            = var.enable_amazon_eks_vpc_cni
  enable_amazon_eks_coredns            = var.enable_amazon_eks_coredns
  enable_amazon_eks_kube_proxy         = var.enable_amazon_eks_kube_proxy
  enable_amazon_eks_aws_ebs_csi_driver = var.enable_amazon_eks_aws_ebs_csi_driver

  #K8s Add-ons
  enable_argocd                                = var.enable_argocd
  argocd_manage_add_ons                        = var.argocd_manage_add_ons
  argocd_helm_config                           = var.argocd_helm_config
  enable_argo_rollouts                         = var.enable_argo_rollouts
  enable_aws_load_balancer_controller          = var.enable_aws_load_balancer_controller
  enable_aws_node_termination_handler          = var.enable_aws_node_termination_handler
  enable_secrets_store_csi_driver              = var.enable_secrets_store_csi_driver
  enable_secrets_store_csi_driver_provider_aws = var.enable_secrets_store_csi_driver_provider_aws
  enable_cluster_autoscaler                    = var.enable_cluster_autoscaler
  enable_metrics_server                        = var.enable_metrics_server
  enable_kubecost                              = var.enable_kubecost
  tags                                         = var.tags
}

I figured I'd add more as I go along adopting addons.

Thanks

VerosK commented 1 year ago

It seems that there is already an issue for this issue in helm. https://github.com/helm/helm/issues/9731

bryantbiggs commented 1 year ago

closing for now since the issue is originating from the Helm provider and not from the module/implementation