terraform-cloud-operator
by HashiCorp
Official Helm chart for HCP Terraform Operator for Kubernetes.
About this chart
Warning In upcoming releases, we shall proceed with renaming this project to HCP Terraform Operator for Kubernetes or simply HCP Terraform Operator. This measure is necessary in response to the recent announcement of The Infrastructure Cloud.
The most noticeable change you can expect in version 2.6.0 is the renaming of this repository and related resources, such as the Helm chart and Docker Hub names.
Please follow the changelogs for updates.
Installation
Use the option --version VERSION with helm install and helm upgrade commands to specify the version you want to install.
Steps
-
Add the Helm repository
$ helm repo add hashicorp https://helm.releases.hashicorp.com -
Update your local Helm chart repository cache
$ helm repo update -
Install
$ helm install demo hashicorp/terraform-cloud-operator \ --version 2.5.0 \ --namespace tfc-operator-system \ --create-namespace
Below are examples of the Operator installation/upgrade Helm chart with options.
Install with options
$ helm install demo hashicorp/terraform-cloud-operator \
--version 2.5.0 \
--namespace tfc-operator-system \
--create-namespace \
--set operator.syncPeriod=10m \
--set 'operator.watchedNamespaces={white,blue,red}' \
--set controllers.agentPool.workers=5 \
--set controllers.module.workers=5 \
--set controllers.project.workers=5 \
--set controllers.workspace.workers=5
In the above example, the Operator will watch 3 namespaces in the Kubernetes cluster: white, blue, and red.
Install to work with Terraform Enterprise
If targeting a Terraform Enterprise instance rather than HCP Terraform, set the API endpoint URL using the operator.tfeAddress value:
$ helm install demo hashicorp/terraform-cloud-operator \
--version 2.5.0 \
--set operator.tfeAddress="https://tfe-api.my-company.com"
If you encounter a TLS-related issue using the Operator with Terraform Enterprise, you may need to configure your own CA certificates using the customCAcertificates value, or by skipping TLS verification using the operator.skipTLSVerify value.
For more information, please refer to the FAQ.
Upgrade with options
$ helm upgrade demo hashicorp/terraform-cloud-operator \
--version 2.5.0 \
--namespace tfc-operator-system \
--set operator.syncPeriod=5m \
--set controllers.agentPool.workers=5 \
--set controllers.module.workers=10 \
--set controllers.project.workers=2 \
--set controllers.workspace.workers=20
In the above example, the Operator will watch all namespaces in the Kubernetes cluster.
In some cases, such as when a new version of the Operator adds a new controller and, consequently, a new CRD, or when it changes an existing CRD schema, manual steps will be required to update the CRD. This is necessary because Helm does not upgrade CRDs during the upgrade operation. In both cases, manual steps involving kubectl apply or kubectl replace must be performed to add a new CRD or upgrade the existing one.
For a more detailed explanation, please refer to the FAQ.
Upgrade recommendations
-
2.3.0to2.4.0-
The
WorkspaceCRD has been changed:$ kubectl replace -f https://raw.githubusercontent.com/hashicorp/terraform-cloud-operator/v2.4.0/charts/terraform-cloud-operator/crds/app.terraform.io_workspaces.yaml
-
-
2.2.0to2.3.0-
The
WorkspaceCRD has been changed:$ kubectl replace -f https://raw.githubusercontent.com/hashicorp/terraform-cloud-operator/v2.3.0/charts/terraform-cloud-operator/crds/app.terraform.io_workspaces.yaml
-
-
2.1.0to2.2.0-
A new controller
Projecthas been added:$ kubectl apply -f https://raw.githubusercontent.com/hashicorp/terraform-cloud-operator/v2.2.0/charts/terraform-cloud-operator/crds/app.terraform.io_projects.yaml
-
-
2.0.0to2.1.0-
The
WorkspaceCRD has been changed:$ kubectl replace -f https://raw.githubusercontent.com/hashicorp/terraform-cloud-operator/v2.1.0/charts/terraform-cloud-operator/crds/app.terraform.io_workspaces.yaml
-
-
2.0.0-betaXto2.0.0-
The
AgentPoolCRD has been changed:$ kubectl replace -f https://raw.githubusercontent.com/hashicorp/terraform-cloud-operator/v2.0.0/charts/terraform-cloud-operator/crds/app.terraform.io_agentpools.yaml
-
Values
| Key | Type | Default | Description |
|---|---|---|---|
| controllers.agentPool.syncPeriod | string | "30s" | The minimum frequency at which watched Agent Pool resources are reconciled. Format: 5s, 1m, etc. |
| controllers.agentPool.workers | int | 1 | The number of the Agent Pool controller workers. |
| controllers.module.workers | int | 1 | The number of the Module controller workers. |
| controllers.project.workers | int | 1 | The number of the Project controller workers. |
| controllers.workspace.syncPeriod | string | "5m" | The minimum frequency at which watched Workspace resources are reconciled. Format: 5s, 1m, etc. |
| controllers.workspace.workers | int | 1 | The number of the Workspace controller workers. |
| customCAcertificates | string | "" | Custom Certificate Authority bundle to validate API TLS certificates. Expects a path to a CRT file containing concatenated certificates. |
| imagePullSecrets | list | [] | Reference to one or more secrets essential for pulling container images. |
| kubeRbacProxy.image.pullPolicy | string | "IfNotPresent" | Image pull policy. |
| kubeRbacProxy.image.repository | string | "quay.io/brancz/kube-rbac-proxy" | Image repository. |
| kubeRbacProxy.image.tag | string | "v0.18.0" | Image tag. |
| kubeRbacProxy.resources.limits.cpu | string | "500m" | Limits as a maximum amount of CPU to be used by a container. |
| kubeRbacProxy.resources.limits.memory | string | "128Mi" | Limits as a maximum amount of memory to be used by a container. |
| kubeRbacProxy.resources.requests.cpu | string | "50m" | Guaranteed minimum amount of CPU to be used by a container. |
| kubeRbacProxy.resources.requests.memory | string | "64Mi" | Guaranteed minimum amount of memory to be used by a container. |
| kubeRbacProxy.securityContext | object | {"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"seccompProfile":{"type":"RuntimeDefault"}} | Container security context. More information in Kubernetes documentation. |
| operator.image.pullPolicy | string | "IfNotPresent" | Image pull policy. |
| operator.image.repository | string | "hashicorp/terraform-cloud-operator" | Image repository. |
| operator.image.tag | string | "" | Image tag. Defaults to .Chart.AppVersion. |
| operator.resources.limits.cpu | string | "500m" | Limits as a maximum amount of CPU to be used by a container. |
| operator.resources.limits.memory | string | "128Mi" | Limits as a maximum amount of memory to be used by a container. |
| operator.resources.requests.cpu | string | "50m" | Guaranteed minimum amount of CPU to be used by a container. |
| operator.resources.requests.memory | string | "64Mi" | Guaranteed minimum amount of memory to be used by a container. |
| operator.securityContext | object | {"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"seccompProfile":{"type":"RuntimeDefault"}} | Container security context. More information in Kubernetes documentation. |
| operator.skipTLSVerify | bool | false | Whether or not to ignore TLS certification warnings. |
| operator.syncPeriod | string | "5m" | The minimum frequency at which watched resources are reconciled. Format: 5s, 1m, etc. |
| operator.tfeAddress | string | "" | The API URL of a Terraform Enterprise instance. |
| operator.watchedNamespaces | list | [] | List of namespaces the controllers should watch. |
| replicaCount | int | 2 | The number of Operator replicas. |
| securityContext | object | {"runAsNonRoot":true} | Deployment pod security context. More information in Kubernetes documentation. |
Deploy terraform-cloud-operator with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has terraform-cloud-operator on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartterraform-cloud-operator is pinned at v2.5.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply