-
Notifications
You must be signed in to change notification settings - Fork 986
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
Kubernetes provider does not respect data when kubernetes_manifest is used #1391
Comments
Hi. Same issue |
It doesn't work with |
started running into the following error which I think is related on destroy, didn't work with tostring() either: │ Error: Provider configuration: failed to assert type of element in 'args' value
│
│ with module.services_tools.provider["registry.terraform.io/hashicorp/kubernetes"],
│ on ../../modules/services_tools/versions.tf line 23, in provider "kubernetes":
│ 23: provider "kubernetes" { // this is required in order to pass information to the underlying kube provider for the above eks see https://github.com/terraform-aws-modules/terraform-aws-eks/issues/1280
provider "kubernetes" {
experiments {
manifest_resource = true
}
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
exec {
api_version = "client.authentication.k8s.io/v1alpha1"
args = ["eks", "get-token", "--cluster-name", data.aws_eks_cluster.cluster.name]
command = "aws"
}
} |
Same error when using GCP and applying multiple manifests from the same file --
data "google_client_config" "current" {}
data "google_container_cluster" "cluster" {
name = var.cluster_name
location = var.cluster_location
}
provider "kubernetes" {
host = data.google_container_cluster.cluster.endpoint
client_certificate = base64decode(data.google_container_cluster.cluster.master_auth.0.client_certificate)
client_key = base64decode(data.google_container_cluster.cluster.master_auth.0.client_key)
cluster_ca_certificate = base64decode(data.google_container_cluster.cluster.master_auth.0.cluster_ca_certificate)
token = data.google_client_config.current.access_token
experiments {
manifest_resource = true
}
}
resource "kubernetes_manifest" "default" {
# Create a map { "kind--name" => yaml_doc } from the multi-document yaml text.
# Each element is a separate kubernetes resource.
# Must use \n---\n to avoid splitting on strings and comments containing "---".
# YAML allows "---" to be the first and last line of a file, so make sure
# raw yaml begins and ends with a newline.
# The "---" can be followed by spaces, so need to remove those too.
# Skip blocks that are empty or comments-only in case yaml began with a comment before "---".
for_each = {
for value in [
for yaml in split(
"\n---\n",
"\n${replace(file("manifests.yaml"), "/(?m)^---[[:blank:]]+$/", "---")}\n"
) :
yamldecode(yaml)
if trimspace(replace(yaml, "/(?m)(^[[:blank:]]*(#.*)?$)+/", "")) != ""
] : "${value["kind"]}--${value["metadata"]["name"]}" => value
}
manifest = each.value
} |
When using kubernetes provider v2.6.1 and terraform v1.x.x, the error shown is the following:
|
The error:
is likely because: host = data.google_container_cluster.this.endpoint should have been (as per #1468): host = "https://${data.google_container_cluster.this.endpoint}" but:
is happening for me despite Edit:
so it looks like this code path is being taken. I noted the comment:
so perhaps |
This may have been evident from the issue title, but those looking for a workaround can remove dynamic/data values from the provider configuration. E.g., given a suitably configured provider "kubernetes" {
host = "https://${data.google_container_cluster.default.endpoint}"
token = data.google_client_config.default.access_token
cluster_ca_certificate = base64decode(data.google_container_cluster.default.master_auth.0.cluster_ca_certificate)
} with: provider "kubernetes" {
config_path = "~/.kube/config"
config_context = "gke_my-project_my-region_my-cluster"
} |
Getting Failed to construct REST client when I try to deploy argocd app on
|
Apparently, the It would be great to see the issue with |
Same problem with cert-manager: Error: Failed to construct REST client |
Same issue here. Serious blocker for us. :( |
Still seeing this on provider version 2.10.0 |
I ended up moving my |
how is this still an issue? Still affected. |
The problem is actual, a big request to fix it. |
Still an issue, please fix this |
+1 |
Same here. |
+1 this is significant problem |
+1 - Even occurs if I try and run a plan using -target to try to deploy the cluster first
|
Still an issue with TF Plan when cluster is not yet present! |
same here |
+1 |
I have this issue as well |
Same here, 1.5 year and counting. |
Also running into this issue, since I have a custom resource I want to use the kubernetes_manifest resource, however according to the documentation:
|
+1 |
Same issue here : |
Same...
|
Still an issue! |
I don't want to post another How can we get the attention of the maintainers here? This issue is open for almost two years affecting many users.. |
I'm experiencing the same issue. And also many others related to Kubernetes provider :( |
@jrhouston can you help us with this issue? |
+1 |
still an issue +1 |
The This is documented in the "before you use" section of the resource documentation. We are exploring solutions to this, but they require changes to Terraform itself and the underlying provider SDKs so we can't anticipate when one will become available. The recommendation remains to split the configuration into two apply operations: a first one to create the cluster and it's infrastructure and a second one to create the Kubernetes resources. |
the kubernetes provider might fail on building the rest client for k8s under various circumstances e.g. hashicorp/terraform-provider-kubernetes#1391
But why does this work with non _manifest resources then? They can be created in the same apply, while setting up the provider from module outputs or the likes. If this was a fundamental issue in not being able to setup the provider from settings only know after applying resources, they would be just as broken. |
My company has a policy to never do multi-apply root configs. And I agree with that. |
Terraform Version, Provider Version and Kubernetes Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Debug log contains lots of private information. I'd prefer to not to post it.
Steps to Reproduce
terraform apply
Expected Behavior
Plan is presented, after apply CRD is created successfully
Actual Behavior
Error:
Important Factoids
Community Note
The text was updated successfully, but these errors were encountered: