Terraform Kubernetes provider 3.4.0, published to the Terraform Registry on October 19, 2026, and 3.3.0 from October 1 add two breaking changes that can make terraform plan fail on code that worked yesterday. A null value inside metadata.labels or metadata.annotations is now rejected for kubernetes_namespace_v1 (3.3.0) and kubernetes_role_v1 (3.4.0), and a Role can no longer set both name and generate_name. The fix is to filter nulls out of your label maps, remove the extra name field, then upgrade in a branch and read the plan before you apply.
This guide shows how to find the affected code, three ways to fix it, a safe upgrade sequence, and how to read the one-time in-place updates you may see after the upgrade. Everything below is based on the provider's official changelog, GitHub release notes and the Terraform Registry, checked on October 23, 2026.
What changed in Terraform Kubernetes provider 3.3 and 3.4
Both releases continue moving resources from the old SDKv2 code base to the Terraform Plugin Framework. The Plugin Framework treats null and empty values more strictly, which is where the new plan errors come from.
| Version (date) | Resource | Breaking change | What to do |
|---|---|---|---|
| 3.3.0 (Oct 1) | kubernetes_namespace_v1 | null entries in metadata.labels / metadata.annotations rejected at plan | Remove the key or give it a string |
| 3.4.0 (Oct 16 changelog, Oct 19 registry) | kubernetes_role_v1 | Same null rule for labels and annotations | Remove the key or give it a string |
| 3.4.0 | kubernetes_role_v1 | name and generate_name together rejected, even generate_name = "" | Keep only one of them |
| 3.4.0 | kubernetes_role_v1 | Import ID needs a non-empty namespace and name | Use namespace/name |
Earlier versions silently dropped a null entry. So the cluster state you have today does not contain those keys anyway. Removing them from your code does not change what is running.
Setting the whole map to null, or leaving it out, is still allowed. Only a null value inside the map fails.
Other changes worth knowing
- Security fixes: 3.4.0 bumps
google.golang.org/grpcto v1.83.2 andgithub.com/moby/spdystreamto v0.5.1 for GO-2026-6348, GO-2026-6443 and CVE-2026-35469. 3.3.0 also bumped gRPC andgolang.org/x/crypto. This is the main reason not to stay pinned on 3.2.x forever. - StatefulSet fix (3.3.0):
kubernetes_stateful_set_v1no longer fails with "Missing Resource Identity After Update" whenwait_for_rollout = trueand the StatefulSet is updated in place. - Data sources (3.3.0):
kubernetes_namespace_v1andkubernetes_all_namespacesdata sources moved to the Plugin Framework. A missingmetadata.namein the namespace data source is now reported at validation time.
Check which provider version you run
Start with what is locked today. Run these in each Terraform root module:
terraform version
terraform providers
grep -A3 'hashicorp/kubernetes' .terraform.lock.hclterraform version lists the provider versions installed for this directory. The lock file shows the exact version the next init will use. Then look at the constraint in your required_providers block:
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 3.0"
}
}
}A constraint like ~> 3.0 or >= 2.0 lets terraform init -upgrade pull 3.4.0. If a teammate or a CI job runs init -upgrade, the plan errors can show up without anyone changing the Kubernetes code.
Find null labels and annotations in your code
The changelog does not list every way a null can end up in a map. In practice it usually comes from a variable with no value or a conditional expression. These are the patterns to look for:
// 1. Variable that defaults to null
labels = {
team = var.team // var.team = null
owner = "platform"
}
// 2. Conditional that returns null
annotations = {
"example.com/ticket" = var.ticket != "" ? var.ticket : null
}
// 3. merge() with a map that contains null values
labels = merge(local.common_labels, var.extra_labels)A quick search narrows down the files. It will not catch every case, because the value may only be null for some workspaces or .tfvars files:
grep -rnE 'null' --include='*.tf' . | grep -v '^./.terraform/'
grep -rnE 'kubernetes_(namespace|role)_v1' --include='*.tf' .Focus on kubernetes_namespace_v1 and kubernetes_role_v1 resources. Those are the two resources the changelog names for this rule as of 3.4.0. Other resources may follow as they move to the Plugin Framework, so writing null-free label maps everywhere is the safer habit.
The most reliable check is the plan itself. Run it against every workspace and variable file you use, as shown in the upgrade steps below.
Fix null values in labels and annotations
You have three options. Pick the one that matches how the map is built.
Option A: Filter nulls with a for expression
This is the most general fix. It keeps optional labels optional:
locals {
namespace_labels = {
for k, v in merge(local.common_labels, {
team = var.team
owner = "platform"
}) : k => v if v != null
}
}
resource "kubernetes_namespace_v1" "app" {
metadata {
name = "app"
labels = local.namespace_labels
}
}The if v != null clause drops any key whose value is null. The provider sees only string values.
Option B: Give the variable a string default
If the label should always exist, make the variable non-null:
variable "team" {
type = string
default = "unassigned"
nullable = false
}With nullable = false, passing team = null uses the default instead. Note that this adds a label that was not on the cluster before, so the next plan will show an in-place update.
Option C: Remove the key
If nobody sets the value, delete the line. Since older provider versions dropped null entries, the result on the cluster is the same.
Fix kubernetes_role_v1 name and generate_name
The second 3.4.0 change only affects Roles. A block like this now fails at plan time:
resource "kubernetes_role_v1" "reader" {
metadata {
name = "pod-reader"
generate_name = "" # now rejected
namespace = "app"
}
# rules ...
}Choose one field:
| Your code | Fix | Effect on the Role |
|---|---|---|
name + generate_name = "" | Delete the empty generate_name line | Changelog's first suggested fix; confirm in plan |
name + non-empty generate_name | Keep name, delete generate_name | Check the plan for a replacement |
| You want generated names | Delete name, keep generate_name | The Role is replaced with a new name |
The changelog says either change replaces the Role if it alters it. Read the plan for must be replaced before you apply. A RoleBinding points to a Role by name, so a Role with a new generated name also needs its bindings updated. Schedule that change.
If you import Roles, the import ID now needs both parts:
terraform import kubernetes_role_v1.reader app/pod-readerUpgrade the Terraform Kubernetes provider step by step
Do the upgrade in a branch, one root module at a time.
View PlantUML source
@startuml
skinparam shadowing false
skinparam defaultFontSize 15
left to right direction
rectangle "Check\nlock file" as A
rectangle "Filter nulls\nfix Role names" as B
rectangle "~> 3.4\ninit -upgrade" as C
rectangle "plan every\nworkspace" as D
rectangle "Review updates\nreplacements" as E
rectangle "apply" as F
A --> B
B --> C
C --> D
D --> E
E --> F
D ..> B : errors
@enduml1. Fix the code on your current version
Apply the null-label and Role fixes first while still on 3.2.x. Run terraform plan. It should report no changes, because older versions dropped the null entries anyway. This proves your fix does not change the cluster.
2. Raise the version constraint
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 3.4"
}Then update the lock file:
terraform init -upgradeIf your team runs Terraform on more than one OS, record hashes for each platform so CI does not fail on a checksum mismatch:
terraform providers lock \
-platform=linux_amd64 \
-platform=darwin_arm64 \
-platform=windows_amd64Commit .terraform.lock.hcl together with the constraint change.
3. Plan every workspace and variable file
terraform workspace list
terraform workspace select staging
terraform plan -var-file=staging.tfvars -out=staging.tfplanRepeat for each workspace. A null that only appears in one .tfvars file will only fail in that workspace.
4. Read the plan before apply
Expect up to three kinds of output:
| Plan output | Cause (per changelog) | Action |
|---|---|---|
| Error on a namespace or Role | null label/annotation, or name + generate_name | Fix the code and plan again |
One-time update in-place on a namespace or Role | Migration to the Plugin Framework, for example an explicitly empty map such as labels = {} | Safe to apply after you confirm no real field changes |
must be replaced on a Role | name / generate_name change | Schedule, or revert to the old field |
For the namespace migration, the pull request says the goal is no HCL changes and no unexpected replacement. If you see a namespace replacement, stop and look at what changed. Deleting a namespace deletes everything inside it.
5. Apply and pin
terraform apply staging.tfplanKeep the ~> 3.4 constraint so you get 3.4.x patch releases but not 3.5 without a review. The same idea, locking dependencies and reviewing upgrades in a pull request, applies to CI as well. See how to lock workflow dependencies with the GitHub Actions lockfile.
Move from kubernetes_namespace and kubernetes_role to _v1
Provider 3.0.0 deprecated many non-versioned resources in favor of their _v1 versions. The 3.3.0 and 3.4.0 releases support moved blocks from the old types, so you can switch without recreating anything:
moved {
from = kubernetes_namespace.app
to = kubernetes_namespace_v1.app
}
moved {
from = kubernetes_role.reader
to = kubernetes_role_v1.reader
}Rename the resource block type to the _v1 version, add the moved block, and run terraform plan. The plan should show the move and no replacement. The 3.4.0 changelog notes that moving from kubernetes_role needs Terraform 1.8 or later. Check with terraform version first.
Apply the null-label rule while you migrate. The _v1 resources are the ones that reject null values.
If you cannot upgrade yet
You can hold the old version while you fix code:
version = "~> 3.2.1"This allows 3.2.x patch releases only. Treat it as temporary. 3.3.0 and 3.4.0 include dependency bumps for security advisories, and new fixes will land on 3.4.x and later. Set a date to remove the pin, the same way you would plan an OS or runtime upgrade such as moving to Ubuntu 26.10.
FAQ
Does removing a null label change anything on my cluster? No. According to the changelog, earlier provider versions silently dropped null entries in labels and annotations. They were never sent to Kubernetes, so removing them from the code keeps the cluster object the same.
Can I set labels = null on the whole map? Yes. The 3.3.0 changelog says the entire map can still be omitted or set to null. Only individual null values inside the map are rejected.
Why does my plan show an in-place update after the upgrade with no code changes? The 3.3.0 and 3.4.0 changelogs say the move to the Plugin Framework can cause a one-time in-place update, for example when a metadata map is explicitly empty. Check the diff, apply once, and the next plan should be clean.
Do other Kubernetes resources reject null labels too? As of October 23, 2026, the changelog names only kubernetes_namespace_v1 (3.3.0) and kubernetes_role_v1 (3.4.0). More resources are moving to the Plugin Framework, so filtering nulls in a shared locals block is a good habit for all of them.
Is 3.4.0 the latest version? On October 23, 2026, the Terraform Registry lists 3.4.0 as the latest hashicorp/kubernetes release. Check the registry before you pin, because patch releases can follow quickly.
Summary
Filter null values out of namespace and Role label maps, keep only one of name or generate_name on Roles, and confirm with a clean plan on your current version. Then raise the constraint to ~> 3.4, run terraform init -upgrade, plan every workspace, and review in-place updates and replacements before you apply. After that, use the same session to move any remaining kubernetes_namespace and kubernetes_role resources to _v1 with moved blocks.
Written October 23, 2026. Facts checked against the hashicorp/terraform-provider-kubernetes changelog, GitHub releases and the Terraform Registry on October 23, 2026. Commands follow the official documentation and were not run against a live cluster for this article.
References
- terraform-provider-kubernetes CHANGELOG (3.3.0, 3.4.0) (checked Oct 23, 2026)
- terraform-provider-kubernetes GitHub releases (checked Oct 23, 2026)
- Pull request #2979: migrate kubernetes_namespace_v1 to the Plugin Framework (checked Oct 23, 2026)
- Terraform Registry: hashicorp/kubernetes provider (checked Oct 23, 2026)
- Terraform docs: moved block reference (checked Oct 23, 2026)
- Terraform docs: Refactoring with moved blocks (checked Oct 23, 2026)
