Silent failures are the worst kind of infrastructure bug, and they have a way of surviving for years. For the past several provider versions, a null label in a Kubernetes namespace was quietly dropped and nobody noticed. Starting with version 3.3.0 of the Terraform Kubernetes provider, that same null stops your plan cold.
It's a small change, and the fix is small too. But it will hit any shared module that builds labels from optional variables, so it's worth ten minutes of searching before you bump a version constraint. Here's the routine I'd follow.
What changed, from the changelog itself
The provider's changelog on GitHub lists the changes in two releases.
Version 3.3.0, dated October 1, 2026: for kubernetes_namespace_v1, entries in metadata.labels and metadata.annotations must now be non-null strings. "Previously accepted null entries are now rejected during planning; omit those entries or provide string values. Entire maps may still be omitted or set to null."
Version 3.4.0, dated October 16, 2026, has two breaking changes for kubernetes_role_v1:
- Null is no longer accepted as a value in metadata.labels or metadata.annotations. Earlier versions accepted it and silently dropped the entry.
- Setting both metadata.name and metadata.generate_name is now rejected during plan, including generate_name set to an empty string. The changelog explains that the Kubernetes API ignores generate_name whenever name is set.
Both resources also moved from the older SDKv2 framework to the Plugin Framework. The changelog says configuration syntax and resource identity are preserved. But it warns that you may see small one-time plan differences afterward.
Both releases bumped dependencies to resolve published security advisories, according to the changelog. For 3.4.0 that includes google.golang.org/grpc and github.com/moby/spdystream. That's a good reason to upgrade soon rather than eventually.
Prerequisites
You need access to the repositories and modules that declare kubernetes_namespace_v1 and kubernetes_role_v1, a way to run terraform plan against a non-production environment, and a state backup. If you plan to use moved blocks with kubernetes_role_v1, the changelog says they need Terraform 1.8 or later.
Step 1: find what will fail
Search every repository and module for the two resource types. Then look for three patterns: labels or annotations built from variables that can be null, locals that merge optional values, and Roles that set both name and generate_name.
Shared modules need special attention. A module author who bumps the provider constraint can break every consumer on its next plan, so treat that like a breaking API change and announce it.
Step 2: remove nulls on the old provider first
Here's the part I like. The old provider already dropped null entries, so you can clean them up before upgrading and see no change in the plan. That means the upgrade pull request contains only the version bump.
A common pattern is merging default labels with optional overrides. Filter out null values before the merge result reaches the resource:
hclCopy locals {
labels = {
for key, value in merge(var.default_labels, var.extra_labels) :
key => value if value != null
}
}
resource "kubernetes_namespace_v1" "app" {
metadata {
name = "app"
labels = local.labels
}
}
That's plain Terraform and works on any provider version. If a label really needs a value, give it a string instead of null.
Expand
Aisle of servers in a data center
Image: Intel Free Press via Wikimedia Commons, CC BY 2.0
Step 3: fix Roles that set both name and generate_name
This is the change most likely to cause real trouble, and the changelog gives two ways out.
If generate_name is empty, remove it and keep name. That keeps the existing Role and changes nothing in the cluster.
If you actually want generated names, remove name and keep generate_name. The changelog is explicit that this replaces the Role. A replaced Role can break anything bound to its old name, such as a RoleBinding, so review the dependent bindings and schedule the change for a quiet window if the Role guards a busy workload.
Image: Google, Inc. via Wikimedia Commons, CC BY 4.0
Step 4: pin, init and plan
With the cleanup merged, raise the constraint on a branch. A pessimistic constraint stops a later minor release from arriving unannounced:
hclCopy terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 3.4"
}
}
}
Then run the usual commands:
BashCopy terraform init -upgrade
terraform plan
Read the plan slowly. The changelog says some differences are expected and don't replace anything:
- Explicit empty metadata maps may show one in-place update.
- Roles imported with an earlier provider version may show a one-time in-place update that sets empty labels and annotations to null.
- Running plan with -refresh=false right after upgrading may show a one-time in-place update adding resource_names = [].
A destroy and create on a namespace or Role isn't on that list. If you see one, stop and investigate before you apply.
Step 5: keep the lock file honest
A provider upgrade that works on a laptop can fail in CI because the dependency lock file doesn't list the new version and its checksums for every platform your runners use. Terraform's providers lock command records them:
BashCopy terraform providers lock -platform=linux_amd64 -platform=linux_arm64
Adjust the platforms to the ones you actually run. Commit the updated lock file with the version bump.
Run the plan twice. The first can include the one-time in-place updates. The second should be clean. If the second still shows changes, something in your configuration is fighting the provider, and it's better to learn that in development.
Troubleshooting
You see an error about a null value in labels. That's the 3.3.0 or 3.4.0 validation. Find the variable or local that produced the null and filter it out, as in step 2.
You see an error about name and generate_name on a Role. Remove whichever the changelog tells you to, and read the replacement warning before you remove name.
Imports fail. The changelog notes that import IDs for Roles now require a non-empty namespace and name, and that identity imports default an omitted namespace to default. Update any disaster-recovery scripts that import Roles.
Moved blocks fail. The changelog says moved blocks from the deprecated kubernetes_role resource need Terraform 1.8 or later. If you pin an older Terraform, upgrade it first. For related notes on that side, our post on Terraform 1.17's minimal refresh and policy changes lists what else moved.
Rolling out
Apply to a development cluster first, then staging, then production, using the same provider version and state backend setup each time. The goal is for the one-time in-place updates to settle so the production run is a no-op.
Don't combine the provider bump with other changes. If a plan goes wrong, you want one variable to blame. Keep the old constraint in version control and take a state backup before the first production apply.
One caution on rollback. If a Role was replaced and a binding broke, restoring the old configuration won't undo the replacement. You'd need to recreate the binding. If your pipeline runs Terraform through a PR bot, our earlier Atlantis v0.49.0 upgrade checklist is worth reading too, since it changes how Terraform gets into the runner.
Should you care?
If you use the provider to manage namespaces or Roles, yes, this week. It's a cheap upgrade that removes a class of hidden bugs, and the security dependency bumps are a bonus. If you only manage Deployments and Services, the breaking changes don't touch you, but you'll get the other fixes on your next bump.
I'd also take a wider lesson. Silent coercion in infrastructure code is a debt. The sooner a provider turns it into an error, the cheaper the fix.
We haven't run these upgrades ourselves. This post is based on the provider's changelog on GitHub, with extra context from Backtrace's upgrade guide.
Frequently Asked Questions
Why does Terraform reject null labels on my namespace now?
Since provider 3.3.0, kubernetes_namespace_v1 requires every entry in labels and annotations to be a non-null string. Older versions silently dropped nulls.
What changed for Roles in 3.4.0?
kubernetes_role_v1 rejects null label and annotation entries, and rejects setting both metadata.name and metadata.generate_name, even when generate_name is empty.
Will switching a Role to generate_name replace it?
Yes. The changelog says removing name and keeping generate_name replaces the Role, so check any RoleBindings first.
Which Terraform version do I need for moved blocks?
The changelog says moved blocks from the deprecated kubernetes_role resource need Terraform 1.8 or later.
Originally published on Mango Developer.


