Set up the HCP Terraform Operator for Kubernetes
The HCP Terraform Operator for Kubernetes' CustomResourceDefinitions (CRD) allow you to dynamically create HCP Terraform workspaces with Terraform modules, populate workspace variables, and provision infrastructure with Terraform runs.
You can install the operator with the official HashiCorp Helm chart.
Prerequisites
All HCP Terraform users can use the HCP Terraform Operator for Kubernetes. You can use the operator to manage the supported features that your organization's pricing tier enables.
Networking requirements
The HCP Terraform Operator for Kubernetes makes outbound requests over HTTPS (TCP port 443) to the HCP Terraform application APIs. This may require perimeter networking as well as container host networking changes, depending on your environment. Refer to HCP Terraform IP Ranges for more information about IP ranges. Below, we list the services that run on specific IP ranges.
Hostname | Port/Protocol | Directionality | Purpose |
---|---|---|---|
app.terraform.io | tcp/443, HTTPS | Outbound | Dynamically managing HCP Terraform workspaces and returning the output to Kubernetes with the HCP Terraform API |
Compatibility
The HCP Terraform Operator for Kubernetes supports the following versions:
- Helm 3.0.1 and above
- Kubernetes 1.15 and above
Install and configure
Generate an organization token within HCP Terraform and save it to a file. These instructions assume you are using a file named
credentials
.Set the
NAMESPACE
environment variable. This will be the namespace that you will install the Helm chart to.Create the namespace.
Create a Kubernetes Secret with the HCP Terraform API credentials.
Add sensitive variables, such as your cloud provider credentials, to the namespace.
Install the HCP Terraform Operator for Kubernetes with Helm.
To create a Terraform workspace, you can create a separate Helm chart to deploy the custom resource or refer to these examples.
Upgrade
When a new version of the HCP Terraform Operator for Kubernetes Helm Chart is available from the HashiCorp Helm repository, you can upgrade with the following command.