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

bug: When using Github Actions to deploy terraform, it returns an error due to helm and a missing environment variable. #13

Open
Vermyndax opened this issue Mar 30, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@Vermyndax
Copy link

Summary

I'm trying to use this module to navigate the bizarre reality known as deploying the AWS load balancer. I finally got this to work locally, but it will not work in Github Actions. The error is thrown:

Error: Kubernetes cluster unreachable: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

I suspect this is because I have a Kubernetes alias for the provider for this cluster. Does this module support using an alias?

Issue Type

Bug Report

Terraform Version

Terraform v1.4.1
on darwin_arm64
+ provider registry.terraform.io/cloudposse/utils v1.7.1
+ provider registry.terraform.io/hashicorp/aws v4.59.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.3.2
+ provider registry.terraform.io/hashicorp/helm v2.9.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.19.0
+ provider registry.terraform.io/hashicorp/time v0.9.1
+ provider registry.terraform.io/hashicorp/tls v4.0.4

Steps to Reproduce

provider "kubernetes" {
  alias                  = "trogdor_kubernetes"
  host                   = module.trogdor_eks.cluster_endpoint
  cluster_ca_certificate = base64decode(module.trogdor_eks.cluster_certificate_authority_data)

  exec {
    api_version = "client.authentication.k8s.io/v1beta1"
    command     = "aws"
    # This requires the awscli to be installed locally where Terraform is executed
    args = ["eks", "get-token", "--cluster-name", module.trogdor_eks.cluster_name]
  }
}

provider "helm" {
  alias = "trogdor_helm"
  kubernetes {
    host                   = module.trogdor_eks.cluster_endpoint
    cluster_ca_certificate = base64decode(module.trogdor_eks.cluster_certificate_authority_data)

    exec {
      api_version = "client.authentication.k8s.io/v1beta1"
      command     = "aws"
      # This requires the awscli to be installed locally where Terraform is executed
      args = ["eks", "get-token", "--cluster-name", module.trogdor_eks.cluster_name]
    }
  }
}

module "trogdor_eks_load_balancer_controller" {
  source  = "lablabs/eks-load-balancer-controller/aws"
  version = "1.2.0"

  cluster_identity_oidc_issuer     = module.trogdor_eks.cluster_oidc_issuer_url
  cluster_identity_oidc_issuer_arn = module.trogdor_eks.oidc_provider_arn
  cluster_name                     = module.trogdor_eks.cluster_name
  irsa_role_name_prefix            = "${var.environment}-${var.app_name}-trogdor-eks-lb"
}

Expected Results

I wish my Github Action would work :(

Actual Results

Planning failed. Terraform encountered an error while generating this plan.

Error: Kubernetes cluster unreachable: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

  with module.trogdor_eks_load_balancer_controller.helm_release.this[0],
  on .terraform/modules/trogdor_eks_load_balancer_controller/helm.tf line 1, in resource "helm_release" "this":
   1: resource "helm_release" "this" {
@Vermyndax Vermyndax added the bug Something isn't working label Mar 30, 2023
@thetoolsmith
Copy link

thetoolsmith commented Apr 25, 2023

@Vermyndax I adde this to the kubernetes block within the provider block and it fixed the issue for me.

provider "helm" {
  kubernetes {
    config_path = "~/.kube/config"
  }
}

@jaygridley
Copy link
Member

Hi @Vermyndax, in your configuration you have alias defined for both Helm a Kubernetes providers. You might want to pass them explicitly to the module trogdor_eks_load_balancer_controller, see https://developer.hashicorp.com/terraform/language/modules/develop/providers#passing-providers-explicitly for the reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants