Skip to content

Unable to gracefully handle deprecated APIs with Kubernetes manifest #2761

@iamasmith

Description

@iamasmith

Terraform Version, Provider Version and Kubernetes Version

Terraform version: 1.12.2
Kubernetes provider version: 2.38.0
Kubernetes version: 1.32.4

Affected Resource(s)

kubernetes_manifest

Terraform Configuration Files

resource "kubernetes_manifest" "example" {
  manifest = {
    "apiVersion" = "flowcontrol.apiserver.k8s.io/v1beta3"
    "kind" = "PriorityLevelConfiguration"
    "metadata" = {
      "name" = "example"
    }
    "spec" = {
      "type" = "Limited"
      "limited" = {
        "nominalConcurrencyShares" = 10
        "lendablePercent" = 50
        "limitResponse" = {
          "type" = "Queue"
          "queuing" = {
            "handSize" = 6
            "queueLengthLimit" = 50
            "queues" = 1024
          }
        }
      }
    }
  }
}

Debug Output

Panic Output

│ The plugin returned an unexpected error from
│ plugin.(*GRPCProvider).UpgradeResourceState: rpc error: code = Unknown desc
│ = failed to determine resource GVK: cannot select exact GV from REST mapper

Steps to Reproduce

  1. Create a cluster with Kubernetes earlier than 1.32 say 1.28 to be sure that the v1 API is not already present.
  2. Apply the resourrce using the v1beta3 API version.
  3. Upgrade the cluster to 1.32 without reapplying the TF in between - this version removes this API.
  4. Try terraform plan now.

Note now that a Terraform plan of this resource will now fail because the API endpoint is removed.

Changing the API version to v1 from v1beta3 also results in an apply attempting to remove the resource using the old API version and add it back using the new version.

Expected Behavior

What should have happened?

This is debatable and may require a feature to migrate API versions for this kind of resource so that small sections of the state for the resource can be updated to reflect new API versions.

Actual Behavior

What actually happened?

Forced to remove the resource from the cluster, remove the state entry, update the API and reapply.

Important Factoids

https://kubernetes.io/docs/reference/using-api/deprecation-guide/

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions