hashicorp / terraform-provider-kubernetes

Terraform Kubernetes provider
https://www.terraform.io/docs/providers/kubernetes/
Mozilla Public License 2.0
1.58k stars 967 forks source link

Provider converts 1000 CPU to 1k causing inconsistency #2508

Closed amitkyadav2203 closed 4 months ago

amitkyadav2203 commented 4 months ago

Terraform Version, Provider Version and Kubernetes Version

Terraform version: v1.7.5 
Kubernetes provider version: v2.30.0.
Kubernetes version: 1.29

Description:

When applying changes to kubernetes_manifest.karpenter_provisioner, the provider "provider["registry.terraform.io/hashicorp/kubernetes"]" produces an unexpected new value: .object.spec.limits.resources["cpu"]: was cty.StringVal("1000"), but now cty.StringVal("1k").

This leads to inconsistent results, preventing the proper application of the manifest.

Steps to Reproduce:

Use the following configuration in Terraform:

hcl Copy code resource "kubernetes_manifest" "karpenter_provisioner" { manifest = { apiVersion = "karpenter.sh/v1alpha5" kind = "Provisioner" metadata = { name = "default" } spec = { ttlSecondsAfterEmpty = 60 ttlSecondsUntilExpired = 604800 limits = { resources = { cpu = "1000" # Specified as a string memory = "2000Gi" } } constraints = { instanceTypes = [ "m5.large", "m5.xlarge", "m5.2xlarge", "c5.large", "c5.xlarge" ] } } } } Apply the configuration using terraform apply.

Expected Behavior: The CPU value should remain 1000 without conversion to 1k.

Actual Behavior: The CPU value is converted from 1000 to 1k, causing an inconsistency.

sheneska commented 4 months ago

Hi @amitkyadav2203! This is happening because the Kubernetes API is adjusting it to an appropriate compatibility format based on what's given. I would recommend taking a look at the computer fields documentation here for more information. Thanks!