Best infrastructure as code tools for Kubernetes

OpenTofu, HCP Terraform and Terraform compared on how each fits a Kubernetes cluster, what still needs a connection or vendor service, and the operating effort each one adds.

On this page

Which infrastructure as code tools for Kubernetes fit your cluster

Your platform team has to settle where Terraform-style state, runs and credentials live before it picks a tool for Kubernetes, because that choice decides how much of the control plane you operate yourself. HCP Terraform fits teams that want the Kubernetes operator and accept a HashiCorp-hosted control plane. OpenTofu fits teams that want an MPL-2.0 CLI, state stored as a Kubernetes secret and their own runner layout. Terraform is licensed under the Business Source License 1.1, which makes it source-available, and we could not confirm a Kubernetes fit for it, so ask HashiCorp to document its Kubernetes integration before you shortlist it.

With OpenTofu, the Kubernetes state backend stores state in a Kubernetes secret, uses a Lease resource for locking, and is limited to 1MB of state by Kubernetes, so measure your largest root module before you adopt it (OpenTofu kubernetes backend documentation). The OpenTofu repository names no Kubernetes operator or Helm chart, so runner design is your team's job: decide which cluster or virtual machines run plan and apply jobs, which service account they use, and how they authenticate to cloud APIs. Confirm that the runner's service account can read and write secrets and Lease objects in the state namespace, and test that a second apply waits on the lock. Run these checks before you build any runner.

HCP Terraform keeps the control plane with HashiCorp and gives you an operator for the agents that run inside your cluster. The HCP Terraform Operator installs from the official hashicorp/hcp-terraform-operator Helm chart and manages workspaces and agent pools as Kubernetes custom resources (HCP Terraform Operator setup). HashiCorp's validated designs recommend the operator for self-hosted agents when your team has Kubernetes skills, because it adds autoscaling, and the Free edition includes one self-hosted agent. Cost is per resource: the pricing page lists Essentials at $0.10 per resource per month, Standard at $0.47 and Premium at $0.99, so ask HashiCorp what counts as a resource and whether agent pools add to the count. Switching later means moving state out of HashiCorp's control plane, so confirm the export path before you commit.

Where each option runs, and what still needs a connection

This table shows where each option runs on Kubernetes and what still depends on an external connection or vendor service. Read the middle column for what the documented Kubernetes integration covers, and the last column for what you must confirm or provision before go-live. The main takeaway: OpenTofu's Kubernetes backend keeps state inside your cluster, while the HCP Terraform operator needs a live connection to HashiCorp's service.

OptionFit with Kubernetes as documentedWhat still needs a connection or vendor service
OpenTofuDocumented Kubernetes backend stores state in a Kubernetes Secret and uses a Lease resource for locking.State is capped at 1MB by Kubernetes. Confirm with the OpenTofu project whether an operator or Helm chart exists.
HCP Terraform operatorInstalls from the hashicorp/hcp-terraform-operator Helm chart and manages workspaces and agent pools through custom resources.Needs an HCP Terraform organization and a network path to it. Confirm the tier that includes the features you need.
HCP Terraform self-hosted agentsHashiCorp's validated designs recommend the Kubernetes operator for agents when teams have Kubernetes skills, because it adds autoscaling.Agents still need a connection to HCP Terraform. Confirm network rules with HashiCorp. The Free edition includes one self-hosted agent.
Terraform (open source CLI)No Kubernetes-native Terraform deployment is confirmed for this comparison.Confirm with HashiCorp how Terraform should run in a cluster and which backends and connections it needs.
Terraform Enterprise (self-managed)Pricing is custom and no Kubernetes deployment model is confirmed for this comparison.Request a written quote and deployment guidance from HashiCorp before sizing the cluster.

What Kubernetes fit means for infrastructure as code tools

Kubernetes fit has two separate parts, and teams often evaluate only the first. The first is where the tool runs: as a CLI inside a pipeline job or pod, as a self-hosted agent that polls a vendor service, or as an operator that reconciles custom resources. The second is where state, locks and provider credentials live: in the cluster, in an object store or in a vendor service. Those two choices decide who patches each component and which RBAC objects you must grant. OpenTofu's kubernetes backend stores state in a Kubernetes secret and uses a Lease resource for locking, so the runner's service account needs access to both, and Kubernetes limits that state to 1MB. Confirm the exact verbs and namespace scope in the backend docs before you write the Role.

HCP Terraform takes a different path. HashiCorp publishes the HCP Terraform Operator, installed from the official Helm chart hashicorp/hcp-terraform-operator, which manages workspaces and agent pools through custom resources. HashiCorp's validated designs recommend the operator for self-hosted agents when teams have Kubernetes skills, because it adds autoscaling, and the Free edition includes one self-hosted agent. The operator is one more component to upgrade. The cluster holds the agents and custom resources only, because workspace state still lives in the vendor service. Confirm in the setup docs where agent tokens are stored, how the custom resource definitions change between operator versions, and which Kubernetes versions each release supports before you schedule a cluster upgrade.

Provider credentials and cluster upgrades are where the ongoing work sits, whichever tool you choose. Give each runner or operator its own service account, scoped to the namespaces it manages, and keep cloud keys in a secrets store that the pod reads at runtime, out of image layers and plain pipeline variables. Treat each Kubernetes minor upgrade as a change to the tool as well as the cluster, because custom resource definitions, RBAC rules and the Lease and Secret permissions can all need updates. Pin chart and binary versions, read each release's notes, and run a plan against a copy of state in a staging cluster first. Confirm each of these behaviors in the vendor docs before you rely on it.

Three options, three different roles in a cluster

These options play different roles in a Kubernetes setup: OpenTofu is the open source engine you run yourself, HCP Terraform is a hosted control plane with an optional Kubernetes operator, and Terraform is the BSL-licensed original you may run internally. The cards cover license, status and the Kubernetes integration each one brings, so you can match the role to your license rules and team skills.

OpenTofu under Linux Foundation stewardship

OpenTofu is licensed under MPL-2.0 and is open source under the OSI definition, with the Linux Foundation as steward. It was accepted to the CNCF Sandbox on April 23, 2025. Its website calls it a drop-in replacement for Terraform that keeps existing workflows and configurations. For Kubernetes, the repository mentions no operator or Helm chart, so you run it from your own pipelines. Its kubernetes backend stores state in a Kubernetes secret with Lease locking, but Kubernetes caps that state at 1MB, so check your state size first.

OpenTofu website

HCP Terraform SaaS control plane

HCP Terraform is HashiCorp's commercial SaaS, so remote state, runs and variable storage sit in a hosted control plane. Its Free edition includes one self-hosted agent, so execution can stay in your network while the control plane stays hosted. Paid tiers are priced per resource per month: Essentials at $0.10, Standard at $0.47 and Premium at $0.99, according to the HashiCorp pricing page, with Terraform Enterprise and HCP Terraform Europe custom priced. Check data location and residency terms with HashiCorp before you assume a hosted state store fits your rules.

HCP Terraform overview

HCP Terraform Operator for Kubernetes

HashiCorp publishes the HCP Terraform Operator for Kubernetes, installed with the official hashicorp/hcp-terraform-operator Helm chart. It manages workspaces and agent pools through Kubernetes custom resources, so workspace definitions can live in Git next to your other manifests. HashiCorp's validated designs recommend it for self-hosted agents when teams have Kubernetes skills, because it adds autoscaling. Before adopting it, confirm who upgrades the operator, where agent credentials are stored and how the operator is tested against your cluster policies.

Operator setup guide

Terraform under the BSL

Terraform 1.6.0 and later are licensed under the Business Source License 1.1, with IBM as licensor, so the code is source-available and sits outside the OSI open source definition. Internal use within your organization is permitted under the license grant. The grant restricts offering Terraform to third parties on a hosted or embedded basis in a way that competes with IBM's paid versions. Have counsel review that test if you run Terraform as a service for customers. Each version converts to MPL 2.0 four years after publication.

How OpenTofu keeps state inside Kubernetes

The OpenTofu kubernetes backend stores state in a Kubernetes Secret and uses a Lease resource for locking, so a team that already runs a cluster can keep state there without another storage service. The limit is size. OpenTofu documents that Kubernetes caps state at 1MB, so any workspace that may grow past that should plan an S3 or azurerm backend from the start. The OpenTofu repository does not publish a Kubernetes operator or Helm chart, so the team writes the backend block and sets up the namespace and RBAC itself.

Start with access, because the Secret holds the full state file, and state often contains provider credentials and database passwords. Confirm which subjects can get or list Secrets in the chosen namespace, and restrict that role to the pipeline service account and a small platform group. Ask the cluster team whether etcd encryption at rest is enabled and how etcd snapshots are taken, since the OpenTofu docs do not describe backing up the Secret, and a restore test should cover it. For locking, confirm what happens when a pipeline dies while holding the Lease: whether the Lease expires on its own, after what interval, and which OpenTofu command clears a stuck lock. Test this with a killed job in staging before production depends on it.

Changing backend later means migrating state. Confirm the exact migration steps for your OpenTofu version in the backend documentation, including how existing state is copied and whether the old Secret and Lease are removed afterward. Freeze pipeline runs for the workspace, run the migration from one operator, and keep a copy of the current state in a separate store before starting. Then run a plan against the new backend and confirm it reports no changes before retiring the old Secret. If the team expects to outgrow 1MB, the S3 backend documentation is the next read.

How the HCP Terraform operator reaches the cluster and HashiCorp

The diagram starts in the team's Git repository or CI pipeline, which triggers the work that reaches the cluster. On the OpenTofu path, the runner pod reads and writes state in a Kubernetes secret, uses a Lease for locking, and calls cloud provider APIs directly. On the HCP Terraform path, the operator is installed through the pipeline and reaches HashiCorp's hosted control plane, while self-hosted agent pods connect to HCP Terraform for runs and then apply changes to the cloud. The operator-to-HashiCorp connection is the hand-off to confirm: check the outbound endpoints and connection direction with HashiCorp before you write egress rules.

The diagram shows a model of the flow, with no reference architecture implied.

Running each option in a cluster: install, update and monitor

OpenTofu runs as a CLI in your pipeline, so running it in a cluster mostly means deciding where state lives and which identity may lock it. Its kubernetes backend stores state in a Kubernetes Secret and uses a Lease resource for locking, so the identity that runs OpenTofu needs permissions on both object types in the target namespace. No operator or Helm chart is documented for OpenTofu, so installation, upgrades and monitoring are built from your own tooling.

  • Backend configuration: Set the kubernetes backend in your root module and point it at a dedicated namespace. Confirm the exact settings in the OpenTofu kubernetes backend documentation.
  • Lease permissions: Grant the runner's service account only the access it needs on Secrets and Lease objects in that namespace, and test the required verbs in a non-production cluster before rollout.
  • State size: Kubernetes limits the state stored in a Secret to 1MB, so large state files need another backend, such as the S3 or azurerm backends OpenTofu also documents.
  • License: OpenTofu is licensed under the Mozilla Public License 2.0. MPL-2.0 is file-level copyleft, so changes to OpenTofu's own source files carry obligations. Confirm with counsel whether your use modifies them.
  • Updates and monitoring: Track releases on the OpenTofu GitHub releases page. Because no operator is documented, monitor pipeline runs through your CI system and alert on failed plans and applies.

Write the Lease permissions, state location and pipeline alerts into the runbook before the first apply.

What each option costs to run, and what changes if you switch

Cost splits across three payees. HashiCorp is paid only if you buy HCP Terraform. The HashiCorp pricing page lists Essentials at $0.10 per resource per month ($0.00013 per hour), Standard at $0.47 per resource per month and Premium at $0.99 per resource per month. Terraform Enterprise (self-managed) and HCP Terraform Europe are custom-priced, so request a written quote for either. Essentials also limits test-integrated module publishing to 10 modules, so a platform team that publishes more modules should compare tiers before it signs. Your team pays for cluster compute that runs self-hosted agents or runners, which the pricing page does not cover, and for engineering time to run the operator, the state backend and RBAC. If you run OpenTofu or Terraform without HCP Terraform, the HashiCorp line item does not apply, but confirm with each vendor whether any commercial terms cover your use.

Most of the cost recurs. HCP Terraform bills per resource per month, so the bill grows with the number of resources your Kubernetes stacks manage. Count those resources now, and check whether agent autoscaling changes the node count you pay for. One-time costs are the initial build: the operator design, the state backend setup and the RBAC model. Recurring costs are runner and operator upgrades, backend maintenance and access reviews. In a quote, ask for the resource count the estimate assumes, the tier needed for your module count, whether runner compute is yours or included, whether Terraform Enterprise or HCP Terraform Europe applies to your data location, and who performs operator upgrades and state restores. Ask for each item in the written scope so the quote and the deliverables match.

Switching cost depends on license terms and where state lives. The Terraform LICENSE file names IBM as licensor and applies Business Source License 1.1 to version 1.6.0 and later. Each version converts to Mozilla Public License 2.0 four years after it is published, so older releases move to an open license on a schedule you can work out from each release date. The same file says internal use within an organization is not a competitive offering. OpenTofu's kubernetes backend stores state in a Kubernetes secret and is limited to 1MB of state by Kubernetes, so a large state file can force a move to another backend. Measure state size per stack now. A backend move later means a state migration and new locking, so rehearse it in a non-production cluster before you commit to a layout.

Questions buyers ask before hiring help with infrastructure as code

How much extra effort does the HCP Terraform Operator add compared with OpenTofu's in-cluster state?

The HCP Terraform Operator adds a control plane you must run. You install the hashicorp/hcp-terraform-operator Helm chart and manage workspaces and agent pools as Kubernetes custom resources, so your team also owns the custom resource definitions, RBAC and Helm upgrades. OpenTofu's kubernetes backend is lighter. It stores state in a Kubernetes secret and uses a Kubernetes Lease for locking, and OpenTofu has no equivalent operator or Helm chart. You still own the backend configuration, secret access, locking behavior and state backups. Effort therefore tracks your Kubernetes skills and the number of workspaces you run. Ask the implementer to list every component to install, every permission each one needs, and who upgrades each one. The setup guide lists the Operator steps.

Does the 1MB state limit matter for our infrastructure as code stack?

It matters when any single state file approaches the limit. OpenTofu's kubernetes backend stores state in a Kubernetes secret, and Kubernetes caps that at 1MB of state. State size grows with resource count, outputs and data sources, so the drivers are how many resources sit in one root module and how often that stack changes. Measure the current size of each state file in your pipeline, track growth after each change, and split large stacks into smaller root modules before they reach the limit. Confirm with HashiCorp whether HCP Terraform applies any state size limit to your plan, because that answer decides whether this constraint moves with you. Ask the implementer to list each stack, its current state size and its split plan in the written scope.

Does HCP Terraform work without outbound network connections?

This depends on which parts you run, so get the connection model in writing before you commit. HCP Terraform is delivered as a hosted service, while self-hosted agents run inside your network, and the Free edition includes one self-hosted agent. HashiCorp's validated design recommends the Kubernetes operator for those agents when teams have Kubernetes skills, because it adds autoscaling. Ask HashiCorp which outbound destinations and ports the agents, the Operator and the hosted service each need, where remote state and secure variables are stored, and which data location applies to your organization. Then ask your security team whether that traffic fits your egress policy. The HCP data location overview is a useful starting point for the data location question.

What recurring costs come with HCP Terraform on Kubernetes?

The main recurring cost for HCP Terraform is the subscription, which HashiCorp prices per resource per month. According to the HashiCorp pricing page, Essentials is $0.10 per resource per month, Standard is $0.47 and Premium is $0.99, while Terraform Enterprise and HCP Terraform Europe are custom quotes. Resource count therefore drives the bill more than cluster count does. Self-hosted agents add recurring staff time for node capacity, the Operator, upgrades and on-call cover. OpenTofu is MPL-2.0 licensed, so its recurring cost is the infrastructure, storage, secrets management and engineering time to upgrade it. DeployOpen's fees follow the written scope, and ongoing support, upgrades and continuous testing are available as retainers. In any quote, ask for each recurring item, its owner, its frequency and the resource count used.

Can an internal team run this on Kubernetes without outside help?

Yes, for a small and stable stack, if the team already runs Kubernetes well. Three drivers decide it:

  • Kubernetes skills: whether the team can manage custom resources, RBAC, secrets and Helm upgrades without outside help.
  • Number of resources: more workspaces and resources mean more plan review, more agents and a higher subscription bill on HCP Terraform.
  • State size: a stack near the 1MB limit on OpenTofu's kubernetes backend needs splitting before it reaches that limit.

Ask for a written scope that names who writes modules, who reviews plans, who owns each upgrade and what the handover includes. DeployOpen works on fixed-scope engagements, with scope, deliverables and timelines agreed in writing before work starts, and it documents what it implements.

Is Terraform's Business Source License a problem for internal use?

Internal use is the lower-risk case under the license text. The Business Source License 1.1 that applies to Terraform 1.6.0 or later allows production use and states that hosting or using Terraform for internal purposes within an organization is not a competitive offering. The exposure comes from offering Terraform to third parties on a paid basis, hosted or embedded, in a way that significantly overlaps with IBM's paid versions. That matters for a managed service provider or a platform team that charges other business units for access. Each version converts to MPL 2.0 four years after it is published. Ask counsel to compare your delivery model with the license's definition of a competitive offering, and ask the implementer to state in writing which Terraform version and license terms the work assumes.

What should a written scope cover before hiring infrastructure as code help?

A written scope should list every system the work touches and every deliverable, so the quote can be checked line by line. Include:

  • The clusters, namespaces and stacks in scope, with the current state size and resource count for each.
  • The tools in scope, such as OpenTofu, the HCP Terraform Operator, self-hosted agents and any CI pipeline that runs them.
  • Required connections, including outbound endpoints, identity, secrets and cloud accounts, and who approves each one.
  • Deliverables such as module structure, backend configuration, runbooks, the upgrade procedure and a handover session.
  • Acceptance criteria, the people who sign off, and how work outside the scope is handled. Fixed-scope agreements from DeployOpen follow the same pattern, and continuous support is offered separately as a retainer.

How DeployOpen helps with infrastructure as code tools for Kubernetes

DeployOpen plans, implements, integrates, hardens, backs up, documents and supports self-hosted open-source platforms inside your own infrastructure. For infrastructure as code on Kubernetes, that means deciding where state lives, how runs execute, and who can change what, then delivering the configuration and evidence your team needs. Most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.

How we scope

  • The written scope names the tool, Kubernetes clusters, state backend and repositories in scope.
  • Scope records the chosen tool option and the license terms that apply to it.
  • Engagements are fixed-scope, and ongoing support is available as a retainer after handover.

How we build

  • Configure the state backend and test locking, including the 1MB state limit of OpenTofu's Kubernetes backend.
  • Deploy the HCP Terraform Operator with the official Helm chart when your team wants Kubernetes custom resources.
  • Set up self-hosted agents, using the operator for autoscaling when your team has the Kubernetes skills.

How we hand over

  • Document the module layout, state backend, variables, pipeline steps and access model for your team.
  • Hand over runbooks for state recovery, lock troubleshooting, agent upgrades and provider version pinning.
  • Record the license terms and subscription terms for each tool in one handover file.

How we support

  • Retainers can cover upgrades, Kubernetes operator version changes and provider updates after handover.
  • Continuous testing of pipeline credentials and cluster permissions is available as part of a retainer.
  • Ask for the upgrade and support terms in writing before go-live, since they change the operating effort.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.