Open christhegrand opened 1 month ago
Hi @christhegrand
As I understand your issue is that after creating the resource "google_container_cluster" "primary"
the next property wasn't applied:
node_config {
linux_node_config {
sysctls = {
"net.core.somaxconn" = "4096"
}
}
}
And the unique step to reproduce this issue is to run a terraform apply
to create this resource. Please confirm if that is right.
Finally please send us the complete LOG.DEBUG output and the terraform.tfstate result after the resource creation to confirm what is happening in your environment.
As I understand your issue is that after creating the resource "google_container_cluster" "primary" the next property wasn't applied:
node_config { linux_node_config { sysctls = { "net.core.somaxconn" = "4096" } } } And the unique step to reproduce this issue is to run a terraform apply to create this resource. Please confirm if that is right.
Yes, that is correct.
I added a Github gist with files that show the output of terraform apply with debug logging turned on, together with the Terraform state.
https://gist.github.com/christhegrand/8e1bf8de6e842298a762ca71c4ae1462
Possible bug in update, it looks like node_config
only has one updatable field, and linux_node_config
has not been implemented for updates.
Instead of using node_config
in resource google_container_cluster
:
resource "google_container_cluster" "primary" {
...
node_config {
linux_node_config {
sysctls = {
"net.core.somaxconn" = "4096"
}
}
}
...
}
You can try with node_config
in resource google_container_node_pool
to config linux node:
# Separately Managed Node Pool
resource "google_container_node_pool" "primary_nodes" {
...
node_config {
...
linux_node_config {
sysctls = {
"net.core.somaxconn" = "4096"
}
}
....
}
I tried apply these setting with terraform and it works.
Adde some reference for this.
In https://registry.terraform.io/providers/hashicorp/google/5.32.0/docs/resources/container_cluster#argument-reference
It mentions google_container_cluster.node_config
is not recommended with terraform
Recommended to create with a separately managed node pool (recommended)
Thanks. We are trying to add node config defaults to autoprovisioned node pools. Is it not possible to do that using Terraform?
Maybe you can try first enable node auto-provisioning on the cluster with Terraform , then specify which node pools are auto-provisioned:
As mentioned in https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/issues/15 the default nodepool causes trouble with managing the cluster. Personally I always delete the default nodepool and create additional nodepools and manage their lifecycle outside the lifecycle of the cluster resource.
@christhegrand can you update your cluster provisioning script to create additional nodepool resources and delete the default nodepool?
I did delete the default node pool:
# We can't create a cluster with no node pool defined, but we want to only use
# separately managed node pools. So we create the smallest possible default
# node pool and immediately delete it.
remove_default_node_pool = true
Maybe you can try first enable node auto-provisioning on the cluster with Terraform , then specify which node pools are auto-provisioned:
That's interesting. I didn't realize I could create a node pool and then enable auto-provisioning on it.
@christhegrand Are you able to make changes to the additional node pools (not using the cluster level node_config field)?
@christhegrand I have created a bug internally for GKE to deprecate the cluster level field node_config
.
Could we close this one if there are no other other issues ?
Sure. Thank you!
Community Note
Terraform Version & Provider Version(s)
Terraform v1.8.2 on darwin_arm64
Your version of Terraform is out of date! The latest version is 1.8.3. You can update by downloading from https://www.terraform.io/downloads.html
Affected Resource(s)
google_container_cluster
Terraform Configuration
Debug Output
Expected Behavior
When I run terraform apply with this change, Terraform reports that the change has been applied successfully. When I run terraform apply again, I should see that there are no more changes to apply.
Actual Behavior
When I run terraform apply with this change, Terraform reports that the change has been applied successfully. But when I run terraform apply again, I see the sysctl change show up as an unapplied change. Basically, Terraform thinks the change has been applied successfully, but it does not seem like it is actually persisting.
Steps to reproduce
terraform apply
Important Factoids
No response
References
No response
b/342657392
b/343052499