How to cache Terraform/OpenTofu binaries in Kubernetes workers

Last updated: August 6, 2025

How to cache Terraform/OpenTofu binaries in Kubernetes workers

When running Terraform or OpenTofu workloads on Kubernetes workers, you can avoid downloading the binaries for each run by implementing binary caching. This reduces execution time and external dependencies.

Using binariesCacheVolume with Kubernetes Workers

To enable binary caching in your Kubernetes worker pool:

  1. Configure the binariesCacheVolume option in your WorkerPool configuration

  2. The binaries will be cached under /opt/spacelift/binaries

Note: This is different from the TF_PLUGIN_CACHE_DIR environment variable, which only caches Terraform/OpenTofu plugins, not the core binaries themselves.

For detailed configuration instructions, refer to our Kubernetes Workers documentation.