Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Error: Failed to construct REST client #199

Closed
anyght opened this issue May 4, 2021 · 7 comments
Closed

Error: Failed to construct REST client #199

anyght opened this issue May 4, 2021 · 7 comments
Labels
bug Something isn't working

Comments

@anyght
Copy link

anyght commented May 4, 2021

Hello, I have this error when I'm using kubernetest-alpha provider
image

terraform {
  required_providers {
    kubernetes-alpha = {
      source = "hashicorp/kubernetes-alpha"
      version = "0.3.2"
    }
  }
}

provider "kubernetes-alpha" {
  host                   = "https://${data.google_container_cluster.primary.endpoint}"
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(data.google_container_cluster.primary.master_auth[0].cluster_ca_certificate)
}

resource "kubernetes_manifest" "test-configmap" {
  provider = kubernetes-alpha

  manifest = {
    "apiVersion" = "v1"
    "kind" = "ConfigMap"
    "metadata" = {
      "name" = "test-config"
      "namespace" = "default"
    }
    "data" = {
      "foo" = "bar"
    }
  }
}

somebody known this error?

@anyght anyght added the bug Something isn't working label May 4, 2021
@alexsomesan
Copy link
Member

alexsomesan commented May 4, 2021

@anyght The error message explains that the provider has no valid configuration and thus cannot initialise the API clients.

How does your provider block look like in TF? Scratch that, I found it in the issue description.

How is the google_container_cluster data-source configured?

@anyght
Copy link
Author

anyght commented May 4, 2021

data "google_client_config" "default" {
  depends_on = [
    google_container_cluster.primary,
  ]
}

data "google_container_cluster" "primary" {
  name     = var.cluster_name
  location     = var.location
  depends_on = [
    google_container_cluster.primary,
  ]
}

I have the same configuration for the kubernetes provider and helm provider, and both work

provider "kubernetes" {
  host                   = "https://${data.google_container_cluster.primary.endpoint}"
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(data.google_container_cluster.primary.master_auth[0].cluster_ca_certificate)
}


provider "helm" {
  kubernetes {
    host                   = "https://${data.google_container_cluster.primary.endpoint}"
    token                  = data.google_client_config.default.access_token
    cluster_ca_certificate = base64decode(data.google_container_cluster.primary.master_auth[0].cluster_ca_certificate)

  }
}

@anyght The error message explains that the provider has no valid configuration and thus cannot initialise the API clients.

How does your provider block look like in TF? Scratch that, I found it in the issue description.

How is the google_container_cluster data-source configured?

@alexsomesan
Copy link
Member

Is google_container_cluster.primary (referenced by depends_on) already created at the time when you run the terraform operation that produces this error?

@anyght
Copy link
Author

anyght commented May 5, 2021

Is google_container_cluster.primary (referenced by depends_on) already created at the time when you run the terraform operation that produces this error?

The cluster is not ready yet. I want to create it at the same time as my deployment.

@alexsomesan
Copy link
Member

So there's the issue. Unlike the Kubernetes and Helm providers, this provider doesn't support creating the cluster at the same time. The reason is that this provider requires access to the cluster API at plan time, to extract schema information for its resources from the cluster OpenAPI spec.

You would have to perform the cluster creation in a separate apply operation which should finish before applying any kubernetes_manifest resources.

This is also explained in the usage docs, here: https://github.com/hashicorp/terraform-provider-kubernetes-alpha/blob/master/docs/usage.md

@anyght anyght closed this as completed May 5, 2021
@Kampe
Copy link

Kampe commented Jun 4, 2021

This just isn't an acceptable resolution. Why does this act any differently than the current kubernetes provider....

@github-actions
Copy link

github-actions bot commented Jul 5, 2021

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants