hashicorp / terraform-provider-helm

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

How to configure k8s username/password authentication #1260

Open gsbraman opened 1 year ago

gsbraman commented 1 year ago

If you prefer, you can also ask your question in the Kubernetes community Slack channel #terraform-providers. (Sign up here)

Terraform version, Kubernetes provider version and Kubernetes version

Terraform version: 1.6.1 on linux_amd64
Helm Provider version: ~> 2.10
Kubernetes version: ~> 2.21

Terraform configuration

terraform {
  required_providers {
    kubernetes = {
      source  = "hashicorp/kubernetes"
      version = "~> 2.21"      
    }
    tls = {
      source  = "hashicorp/tls"
      version = "~> 4.0"
    }
    helm = {
      source  = "hashicorp/helm"
      version = "~> 2.10"  
    }
  }
 }

# +------------+
# | This works |
# +------------+

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

# +--------------------------------------------------------------------------------------------------------+
# | This throws the follwong error when running terraform apply:                                           |
# | "Error: could not get apiVersions from Kubernetes: could not get apiVersions from Kubernetes: unknown" |
# +--------------------------------------------------------------------------------------------------------+

provider "helm" {  
 kubernetes {
   host     = "https://api.crc.testing:6443"
   username = "my_user"
   password = "my_password"   
   insecure = true
 }
}

resource "helm_release" "gitops" {
  name        = "gitops"
  chart       = "gitops"
  repository  = "."
  namespace   = "helm-gitops"
  max_history = 3
  create_namespace = true
  wait             = true
  reset_values     = true
}

Question

When running terraform apply using the username / password option, the following error is returned: Error: could not get apiVersions from Kubernetes: could not get apiVersions from Kubernetes: unknown │ │ with helm_release.gitops, │ on main.tf line 43, in resource "helm_release" "gitops": │ 43: resource "helm_release" "gitops" { Is this the proper syntax? Thanks in advance
github-actions[bot] commented 1 week 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!