4.0.0-beta1 (Dec 03, 2026)
BREAKING CHANGES:
- Back up state before upgrading to 4.0. All 14 managed resources listed in the v4 upgrade guide write a newer state schema, including Services, PersistentVolumes, and PersistentVolumeClaims. Once 4.0 saves any of those instances, rolling back to 3.x requires restoring the pre-upgrade state backup; pinning 3.x alone is not enough. [GH-3017]
resource/kubernetes_deployment_v1,resource/kubernetes_daemon_set_v1,resource/kubernetes_stateful_set_v1,resource/kubernetes_pod_v1,resource/kubernetes_job_v1,resource/kubernetes_cron_job_v1: Migrate to the Terraform Plugin Framework. Container and init containerresources, Deployment and DaemonSetstrategyand itsrolling_update, StatefulSetpersistent_volume_claim_retention_policyand Job and CronJobselectorchange from blocks to object arguments, for exampleresources = { ... }, so references andignore_changespaths drop their[0]. Pod specimage_pull_secretsandreadiness_gateand Job and CronJobselector.match_expressionsbecome lists of objects. See the v4 upgrade guide. [GH-3017]resource/kubernetes_horizontal_pod_autoscaler_v2: An omittedbehavioris no longer sent as an empty object, and an omittedstabilization_window_secondsis no longer sent as0, so Kubernetes applies its own defaults. New autoscalers withoutstabilization_window_secondsuse a 300 second scale-down window instead of 0. Existing autoscalers keep their current values. [GH-3050]resource/kubernetes_horizontal_pod_autoscaler_v2:spec.metricandspec.behaviorchange from blocks to arguments, for examplemetric = [{ ... }]andbehavior = { ... }. Inside them, the metric sources,target,described_object, the metric identifier,selector,scale_upandscale_downbecome objects;policyandmatch_expressionsbecome lists of objects. Drop[0]from references andignore_changespaths only where a block became a single object. [GH-3050]resource/kubernetes_horizontal_pod_autoscaler_v2beta2: Removed. Usekubernetes_horizontal_pod_autoscaler_v2and update anymetricandbehaviorblocks to the v4 argument syntax. With Terraform 1.8 or later, include amovedblock from the removed type to keep the existing autoscaler. [GH-3042]resource/kubernetes_ingress_v1,resource/kubernetes_ingress_class_v1,resource/kubernetes_network_policy_v1: Selected singleton backends, HTTP rules, parameters, selectors, and IP blocks now use object arguments (field = { ... }) instead of blocks. Ingress HTTP paths and selector match expressions remain repeated values and now use list-of-object arguments. Update only the converted object indexes in references and lifecycle paths. Metadata/spec and other repeated blocks retain their syntax. IngressClass state containing multiple historical parameters blocks is rejected; consolidate to the one active parameters object and refresh with the previous provider before upgrading. Follow each resource's migration guide and preserve absent versus empty selectors. [GH-2994]resource/kubernetes_persistent_volume_v1,resource/kubernetes_persistent_volume_claim_v1: Null entries inmetadata.labelsormetadata.annotationsare now rejected. Remove those entries or supply a string value. [GH-3061]resource/kubernetes_persistent_volume_v1:spec.claim_refchanges from a block to an object argument,claim_ref = { ... }, so references andignore_changespaths drop its[0].specaccepts exactly one block. See the resource's upgrade section. [GH-3061]resource/kubernetes_pod_disruption_budget_v1: Changespec.selectorto a required object (selector = { ... }) andmatch_expressionsto a list of objects. Remove the selector's[0]from references and lifecycle paths. See the resource upgrade guide for module, conditional and Terraform JSON examples. [GH-2995]resource/kubernetes_pod_v1,resource/kubernetes_job_v1: Review replacement plans before applying. Changing a Pod spec replaces the Pod, except when setting or loweringactive_deadline_seconds, which updates it in place. Changing a Job's Pod template orpod_failure_policyreplaces the Job. [GH-3017]resource/kubernetes_service_v1:session_affinity_configand its nestedclient_ipnow use object assignment syntax instead of blocks. Remove the two affinity[0]indexes from references and lifecycle paths. API-allocation markers (node_port = 0when allocation is enabled, empty/zerotarget_port, and emptycluster_ips/ip_familiesfor non-ExternalName Services) are rejected; omit these arguments or usenullinstead. [GH-2992]
FEATURES:
- New action:
kubernetes_job_run. Runs a Job once, from the job template of a CronJob or from a manifest, and waits for it to complete. [GH-3064] - New action:
kubernetes_manifest_create. Creates one object of any kind from its manifest, such as the request object an operator acts on, and can wait for the outcome the object reports. [GH-3064] - New action:
kubernetes_rollout_restart. Restarts the pods of a Deployment, StatefulSet or DaemonSet askubectl rollout restartdoes and waits for the rollout, for example when a ConfigMap or Secret they read changes. Actions need Terraform 1.14 or later. [GH-3064] - New actions:
kubernetes_node_cordon,kubernetes_node_drainandkubernetes_node_uncordon, for one node or the nodes a label selector matches. Cordon makes the nodes unschedulable, drain also evicts their pods askubectl draindoes, and uncordon makes them schedulable again. [GH-3064] - New ephemeral resource:
kubernetes_secret_v1. Reads a Secret without storing its values in the Terraform plan or state. [GH-3054] - New function:
manifest_decode_map. Decodes multi-document YAML into a map keyed byKind[.group]/[namespace/]name, a stablefor_eachkey for one resource instance per object. [GH-3054] - New resource:
kubernetes_manifest_patch. Applies fields of an object that something else creates and manages, such as a cluster add-on or an operator, with server-side apply under its own field manager, and keeps them set. It never creates or deletes the object: destroying it gives up the fields, or removes them withdestroy_behavior = "remove_fields". [GH-3058] - New resource:
kubernetes_manifest_v2, the successor ofkubernetes_manifest. It uses server-side apply for HCL or YAML manifests. Planning a new object does not require its kind to exist: a CustomResourceDefinition and its custom resources can be created in one apply when the custom resources depend on the definition. Terraform 1.8+ supportsmovedblocks fromkubernetes_manifestor from another provider'skubectl_manifest. [GH-3054] kubernetes_gateway_class_v1: Add a new data source for reading a Gateway API v1 GatewayClass. [GH-3051]kubernetes_gateway_v1: Add a new data source for reading a Gateway API v1 Gateway. [GH-3065]kubernetes_http_route_v1: Add a new data source for reading a Gateway API v1 HTTPRoute. [GH-3065]kubernetes_reference_grant_v1: Add a new data source for reading a Gateway API v1 ReferenceGrant. [GH-3066]kubernetes_gateway_class_v1: Add a new resource for managing a Gateway API v1 GatewayClass. [GH-3051]kubernetes_gateway_v1: Add a new resource for managing a Gateway API v1 Gateway. [GH-3065]kubernetes_http_route_v1: Add a new resource for managing a Gateway API v1 HTTPRoute. [GH-3065]kubernetes_reference_grant_v1: Add a new resource for managing a Gateway API v1 ReferenceGrant. [GH-3066]
ENHANCEMENTS:
- Workload Pod specs: Add Linux user namespaces (
host_users),proc_mount, AppArmor profiles, Windows security options, and supplemental group and SELinux policies.proc_mount = "Unmasked"requireshost_users = falseand a cluster that supports it. [GH-3017] - Workload Pod specs: Add Pod-level
resources, Dynamic Resource Allocation claims (resource_claimsand containerresources.claims), containerresize_policy,restart_policy_rules, andOnFailureandNeverrestart policies on supported clusters. [GH-3017] - Workload Pod specs: Add
set_hostname_as_fqdn,hostname_override, affinity label keys, probe termination grace periods, lifecycle sleep, TCP probe host, andenv.value_from.file_key_ref. See the Pod feature guide for Kubernetes version requirements. [GH-3017] - Workload Pod specs: Mount OCI images with
volume.image, projectcluster_trust_bundleandpod_certificatesources, and set recursive read-only mounts orvolume_attributes_class_namein ephemeral volume claim templates. Availability depends on cluster and node support. [GH-3017] resource/kubernetes_ingress_v1,resource/kubernetes_ingress_class_v1,resource/kubernetes_network_policy_v1: Existing versioned resources upgrade at the same address without re-import. Terraform 1.8+ also supportsmovedblocks fromkubernetes_ingress_classandkubernetes_network_policyto their_v1types. The v1beta1kubernetes_ingresstype cannot move tokubernetes_ingress_v1this way. [GH-2994]resource/kubernetes_job_v1,resource/kubernetes_cron_job_v1: Add Jobsuspend,success_policy,pod_replacement_policy, andmanaged_by. A suspended standalone Job skips waiting for completion. [GH-3017]resource/kubernetes_persistent_volume_v1,resource/kubernetes_persistent_volume_claim_v1: Migrate to the Terraform Plugin Framework. Resource type names, import IDs and existing state are kept, andkubernetes_persistent_volume_claim_v1keeps its configuration syntax. Explicitly empty values that 3.x stored as null, such aslabels = {}ormount_options = [], and anode_affinitythat is set in Kubernetes but not in the configuration, can show a one-time in-place update that changes only Terraform state. With Terraform 1.8 or later,movedblocks can move resources from the deprecatedkubernetes_persistent_volumeandkubernetes_persistent_volume_claimtypes. [GH-3061]resource/kubernetes_pod_disruption_budget_v1: Existing versioned PDBs upgrade at the same address without re-import. Spec changes still require replacement. Empty selector and metadata collections may need a one-time state update without changing the PDB. [GH-2995]resource/kubernetes_service_v1: Addspec.traffic_distributionattribute. [GH-3055]resource/kubernetes_service_v1: Existing Services upgrade in place without re-import. To change from the deprecatedkubernetes_servicetype, use amovedblock with Terraform 1.8 or later. [GH-2992]resource/kubernetes_stateful_set_v1: Set the starting Pod ordinal withordinals, limit unavailable Pods withupdate_strategy.rolling_update.max_unavailable, and select a volume attributes class withvolume_claim_template.spec.volume_attributes_class_nameon supported clusters. [GH-3017]
BUG FIXES:
resource/kubernetes_daemon_set_v1: Accept"0%"for rolling-update limits when the other limit permits progress. [GH-3017]resource/kubernetes_deployment_v1,resource/kubernetes_daemon_set_v1,resource/kubernetes_stateful_set_v1,resource/kubernetes_pod_v1,resource/kubernetes_job_v1,resource/kubernetes_cron_job_v1: A podsecurity_contextblock that sets only empty values, such assupplemental_groups = [], no longer plans a change on every run. [GH-3017]resource/kubernetes_deployment_v1,resource/kubernetes_daemon_set_v1,resource/kubernetes_stateful_set_v1,resource/kubernetes_pod_v1,resource/kubernetes_job_v1,resource/kubernetes_cron_job_v1: Accept SCTP container ports, downward API volume items that use onlyresource_field_ref, and huge page sizes beyond 2Mi and 1Gi inempty_dir.medium. [GH-3017]resource/kubernetes_deployment_v1,resource/kubernetes_daemon_set_v1,resource/kubernetes_stateful_set_v1,resource/kubernetes_pod_v1,resource/kubernetes_job_v1,resource/kubernetes_cron_job_v1: Accept a single dot, a trailing dot and underscores indns_config.searches, as Kubernetes does. [GH-3017]resource/kubernetes_deployment_v1,resource/kubernetes_daemon_set_v1,resource/kubernetes_stateful_set_v1,resource/kubernetes_pod_v1,resource/kubernetes_job_v1,resource/kubernetes_cron_job_v1: Keep the configured spelling of numeric strings, such asrun_as_user = "01000"orreplicas = "01", to avoid repeated planned changes or Pod and Job replacements for equivalent values. [GH-3017]resource/kubernetes_horizontal_pod_autoscaler_v2: A metricvalueoraverage_valuethat Kubernetes stores in a different but equal form, such as1000mstored as1, no longer plans a change. [GH-3050]resource/kubernetes_horizontal_pod_autoscaler_v2:select_policycan be omitted fromscale_upandscale_down. Previously the provider sent an empty value and Kubernetes rejected it withUnsupported value: "". [GH-3050]resource/kubernetes_job_v1,resource/kubernetes_cron_job_v1: Accept exit code zero with theNotInoperator in Pod failure policy rules. [GH-3017]resource/kubernetes_job_v1: Apply changes tottl_seconds_after_finishedandmax_failed_indexesto the Job. [GH-3017]resource/kubernetes_persistent_volume_v1,resource/kubernetes_persistent_volume_claim_v1: Planning rejects a known-invalid PVC storage request or a replacement whose destination name is confirmed occupied. These checks do not guarantee that Kubernetes will accept the replacement at apply. [GH-3061]resource/kubernetes_persistent_volume_v1: Addingclaim_reffor the claim that already holds the volume no longer makes Kubernetes mark the claimLost. A volume that does not become available within the create timeout is recorded in state as tainted instead of being left in Kubernetes without state. [GH-3061]resource/kubernetes_pod_v1: Keep a configured toleration of a built-in taint, such asnode.kubernetes.io/not-readywithtoleration_seconds, instead of replacing the Pod on every plan. A Pod whose state 3.x last wrote is replaced once more. [GH-3017]resource/kubernetes_pod_v1: Keep several projections in oneprojectedvolumesourcesblock without reporting a change on every plan. [GH-3017]resource/kubernetes_pod_v1: Record the priority class Kubernetes assigns to a Pod that leaves outpriority_class_name, such as aglobalDefaultPriorityClass, instead of replacing the Pod on every plan. [GH-3017]resource/kubernetes_stateful_set_v1: Updaterevision_history_limitin place and accept zero. [GH-3017]- provider: Interrupting Terraform (Ctrl-C) stops an operation that is waiting, such as
waitinkubernetes_manifestor the rollout wait ofkubernetes_deployment_v1. Before, the wait continued until its timeout. [GH-3054]
NOTES:
resource/kubernetes_deployment_v1,resource/kubernetes_daemon_set_v1,resource/kubernetes_stateful_set_v1,resource/kubernetes_cron_job_v1: Updates now use patches rather than rebuilding the whole spec or Pod template from the Terraform configuration. [GH-3017]resource/kubernetes_deployment_v1,resource/kubernetes_daemon_set_v1,resource/kubernetes_stateful_set_v1,resource/kubernetes_pod_v1,resource/kubernetes_job_v1,resource/kubernetes_cron_job_v1: After a create or update, state records the planned values, and only values the plan leaves unknown come from Kubernetes. Fields that admission webhooks or other clients add, such as an injected sidecar container, show as drift on the next refreshed plan instead of being recorded by the apply;lifecycle.ignore_changeshandles them as before. [GH-3017]resource/kubernetes_deployment_v1,resource/kubernetes_daemon_set_v1,resource/kubernetes_stateful_set_v1,resource/kubernetes_pod_v1,resource/kubernetes_job_v1,resource/kubernetes_cron_job_v1: Resource type names,namespace/nameimport IDs, import identities and existing state are kept, and an unchanged configuration normally plans no change. Values that earlier versions stored differently, such as explicitly emptylabels = {}, can show a one-time in-place update that changes only Terraform state. With Terraform 1.8 or later,movedblocks can move resources from the deprecatedkubernetes_deployment,kubernetes_daemonset,kubernetes_stateful_set,kubernetes_pod,kubernetes_jobandkubernetes_cron_jobtypes. [GH-3017]resource/kubernetes_deployment_v1,resource/kubernetes_daemon_set_v1,resource/kubernetes_stateful_set_v1,resource/kubernetes_pod_v1,resource/kubernetes_job_v1,resource/kubernetes_cron_job_v1: Setting bothnameandgenerate_nameinmetadatagives a warning, since Kubernetes ignoresgenerate_namewhennameis set. [GH-3017]resource/kubernetes_deployment_v1: Settingrolling_updatewith theRecreatestrategy is reported during planning. Kubernetes rejects the combination. [GH-3017]resource/kubernetes_horizontal_pod_autoscaler_v2: Existing resources keep their address andnamespace/nameimport ID. Terraform 1.8+ also supports moving from the unversionedkubernetes_horizontal_pod_autoscalerwhen its state hasmetricorbehavior.target_cpu_utilization_percentageis still accepted but is not part ofautoscaling/v2and is never sent. [GH-3050]resource/kubernetes_horizontal_pod_autoscaler: Now usesautoscaling/v2instead ofautoscaling/v2beta2whenmetricorbehavioris set. Configurations without those fields continue to useautoscaling/v1. Existing state does not need to be migrated. [GH-3042]resource/kubernetes_ingress_v1,resource/kubernetes_ingress_class_v1,resource/kubernetes_network_policy_v1: Explicitly empty selector label maps and expression values can require a one-time state-only update from null to an empty collection. The update preserves the Kubernetes policy. After create or update, state retains known planned specification values; admission changes appear as drift on the next refresh. [GH-2994]resource/kubernetes_ingress_v1,resource/kubernetes_ingress_class_v1,resource/kubernetes_network_policy_v1: Updates patch configured fields while preserving unrelated fields managed by other clients. [GH-2994]resource/kubernetes_persistent_volume_v1,resource/kubernetes_persistent_volume_claim_v1: An unknown value alone does not trigger replacement. If it resolves to an immutable change during apply, Terraform fails the apply without changing the object. Addingnode_affinityto a volume that has none is an in-place update. [GH-3061]resource/kubernetes_pod_v1,resource/kubernetes_job_v1: A plan that changes a Pod spec or a Job pod template reads the object from Kubernetes, even with-refresh=false, to decide whether it must be replaced. Planning fails if that read fails or takes longer than 30 seconds. [GH-3017]resource/kubernetes_service_v1: Explicitly empty maps and sets may produce a one-time state update fromnullto an empty collection without changing the Service. [GH-2992]resource/kubernetes_stateful_set_v1: Warn during planning when changes to therequests, labels or annotations of avolume_claim_templatecannot be applied to the existing StatefulSet. Replace the StatefulSet to apply such a change. [GH-3017]- provider: Upgraded Kubernetes client libraries to v0.37.2 (
k8s.io/kubernetesv1.37.2). [GH-3042]