You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
resource"kubernetes_manifest""ec2-node-class-without-snapshot" {
count=var.snapshot_id==""?1:0computed_fields=["spec.blockDeviceMappings"]
field_manager {
force_conflicts=true
}
manifest={
"apiVersion"="karpenter.k8s.aws/v1""kind"="EC2NodeClass""metadata"= {
"name"= var.name
}
"spec"= {
# ... other fields ..."kubelet"= {
"clusterDNS"= ["XXX.XXX.X.X"] # Critical field that must maintain this value
}
}
}
}
Steps to Reproduce
Create EC2NodeClass CRD with kubelet.clusterDNS field set
Make any change to the EC2NodeClass (e.g., update AMI version)
Run terraform plan - shows expected changes
Run terraform apply
Apply fails with state inconsistency error
Expected Behavior
The provider should maintain the clusterDNS field value during apply operations, especially when:
No other controllers are modifying the field (verified via managedFields)
Field management is properly configured with force_conflicts = true
The field has a specific, required value that must be maintained
Actual Behavior
Provider fails with:
When applying changes to
module.eks-1.module.ec2-node-class-cpu[0].kubernetes_manifest.ec2-node-class-without-snapshot[0],
provider "registry.terraform.io/hashicorp/kubernetes" produced an unexpected
new value: .object.spec.kubelet.clusterDNS: was
cty.ListVal([]cty.Value{cty.StringVal("XXX.XXX.X.X")}), but now null.
Important Factoids
This started occurring after transition to Karpenter version 1.0.2
Issue occurs across different node groups referencing the same module
The field is managed correctly in some cases but fails inconsistently, i.e. in some node groups, you can see terraform successfully assigning this field value during apply, in other node group it is missing
managedFields output shows no other controllers attempting to modify this field at that time, therefore unlikely to happen due to a race condition
The clusterDNS field is crucial for proper node-local-dns operation
milieere
changed the title
Inconsistent state management of fields in EC2NodeClass CRD during apply
Inconsistent state management of fields in EC2NodeClass CRD during apply after Karpenter version update
Jan 20, 2025
Deleting the ec2nodeclass manually from the cluster and creating the again via terraform fixes the issue permanently (tested in infra-dev).
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to
│ module.eks-1.module.ec2-node-class-gpu-arm64[0].kubernetes_manifest.ec2-node-class-without-snapshot[0],
│ provider
│ "module.eks-1.provider[\"registry.terraform.io/hashicorp/kubernetes\"]"
│ produced an unexpected new value: .object.spec.kubelet.clusterDNS: was
│ cty.ListVal([]cty.Value{cty.StringVal("169.254.5.5")}), but now null.
│
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
OBSERVED BEHAVIOR
This error occurs again after transiently solving this with kubectl patch ( kubectl patch ec2nodeclass karpenter-gpu-arm64 --type=merge -p '{"spec":{"kubelet":{"clusterDNS":["169.254.5.5"]}}}’ ) - it exhibits two successful applies afterwards (1st apply without changes after kubectl-patch passes, second apply with changes to ec2nodeclass after kubectl-patchpasses, third apply with changes to ec2nodeclass fails with this error). Third apply with modifications causes removal of kubelet field from ec2nodeclass definition, even though in the code, it is defined:
"kubelet" = {
"clusterDNS" = ["169.254.5.5"]
}
What fixed the issue
Removing the ec2nodeclasses manually (deleting them from the cluster), and recreating again via terraform solved the issue. Unfortunately, this is not a viable option to do in our production env, only in test. Therefore we parked this issue and will deal with it during next Karpenter upgrade.
Terraform Version, Provider Version and Kubernetes Version
Affected Resource(s)
Terraform Configuration Files
Steps to Reproduce
Expected Behavior
The provider should maintain the clusterDNS field value during apply operations, especially when:
Actual Behavior
Provider fails with:
Important Factoids
References
#2185
Community Note
The text was updated successfully, but these errors were encountered: