HashiCorp-maintained Terraform plugin for creating, updating, and deleting Kubernetes resources across core and extension APIs.
Overview
The Kubernetes provider for Terraform is a plugin that manages the full lifecycle of Kubernetes objects. It supports deployments, services, custom resources and CRDs, policies, quotas, and resources across admission, apps, batch, networking, RBAC, storage, and related API groups.
The provider must be configured with cluster credentials before use. Common setups point at a kubeconfig file, explicit host and certificates, in-cluster configuration when running inside a cluster, or exec-based token refresh for clouds such as EKS. It requires Terraform v1.0.0 or newer.
When Terraform also provisions managed clusters from cloud providers, credentials from those resources can be passed into the Kubernetes provider. Documentation warns against creating cluster and Kubernetes resources in the same module in one apply, and recommends separate stages linked by data sources.
Optional provider-level ignore annotations and labels settings let Terraform skip external metadata changes. Guides cover stacking with AKS, EKS, and GKE workflows.
Key features
- Lifecycle management for K8s resources
- Kubeconfig and in-cluster auth
- Exec plugins for short-lived tokens
- CRD and manifest support
- Ignore annotations and labels globally
- Works with EKS, AKS, and GKE guides
- Multiple API group resources
- Separate apply patterns for new clusters
Use cases
- GitOps-style cluster configuration
- Namespaces and RBAC as code
- Deploying apps after cluster creation
- Managing networking and storage objects
- Custom resource definitions in Terraform