hcp-terraform-operator

by HashiCorp

Helm chartv2.12.1App 2.12.1Verified publisherOfficial

Official Helm chart for HCP Terraform Operator for Kubernetes.

About this chart

Installation

Use the option --version VERSION with helm install and helm upgrade commands to specify the version you want to install.

Steps

  1. Add the Helm repository

    $ helm repo add hashicorp https://helm.releases.hashicorp.com
    
  2. Update your local Helm chart repository cache

    $ helm repo update
    
  3. Install

    $ helm install demo hashicorp/hcp-terraform-operator \
      --version 2.12.1 \
      --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/hcp-terraform-operator \
  --version 2.12.1 \
  --namespace tfc-operator-system \
  --create-namespace \
  --set operator.syncPeriod=10m \
  --set 'operator.watchedNamespaces={white,blue,red}' \
  --set controllers.agentPool.workers=5 \
  --set controllers.agentToken.workers=5 \
  --set controllers.module.workers=5 \
  --set controllers.project.workers=5 \
  --set controllers.runsCollector.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/hcp-terraform-operator \
  --version 2.12.1 \
  --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/hcp-terraform-operator \
  --version 2.12.1 \
  --namespace hcp-terraform-operator-system \
  --set operator.syncPeriod=5m \
  --set controllers.agentPool.workers=5 \
  --set controllers.agentToken.workers=5 \
  --set controllers.module.workers=10 \
  --set controllers.project.workers=2 \
  --set controllers.runsCollector.workers=7 \
  --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.8.0 to 2.9.0

    • The AgentPool CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.9.0/charts/hcp-terraform-operator/crds/app.terraform.io_agentpools.yaml
      
    • The Module CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.9.0/charts/hcp-terraform-operator/crds/app.terraform.io_modules.yaml
      
    • The Project CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.9.0/charts/hcp-terraform-operator/crds/app.terraform.io_projects.yaml
      
    • The Workspace CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.9.0/charts/hcp-terraform-operator/crds/app.terraform.io_workspaces.yaml
      
  • 2.7.0 to 2.8.0

    • The Workspace CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.8.0/charts/hcp-terraform-operator/crds/app.terraform.io_workspaces.yaml
      
  • 2.6.0 to 2.7.0

    • The Workspace CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.7.0/charts/hcp-terraform-operator/crds/app.terraform.io_workspaces.yaml
      
    • The AgentPool CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.7.0/charts/hcp-terraform-operator/crds/app.terraform.io_agentpools.yaml
      
  • 2.5.0 to 2.6.0

    • The AgentPool CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.6.0/charts/hcp-terraform-operator/crds/app.terraform.io_agentpools.yaml
      
  • 2.3.0 to 2.4.0

    • The Workspace CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.4.0/charts/terraform-cloud-operator/crds/app.terraform.io_workspaces.yaml
      
  • 2.2.0 to 2.3.0

    • The Workspace CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.3.0/charts/terraform-cloud-operator/crds/app.terraform.io_workspaces.yaml
      
  • 2.1.0 to 2.2.0

    • A new controller Project has been added:

      $ kubectl apply -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.2.0/charts/terraform-cloud-operator/crds/app.terraform.io_projects.yaml
      
  • 2.0.0 to 2.1.0

    • The Workspace CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.1.0/charts/terraform-cloud-operator/crds/app.terraform.io_workspaces.yaml
      
  • 2.0.0-betaX to 2.0.0

    • The AgentPool CRD has been changed:

      $ kubectl replace -f https://raw.githubusercontent.com/hashicorp/hcp-terraform-operator/v2.0.0/charts/terraform-cloud-operator/crds/app.terraform.io_agentpools.yaml
      

Values

KeyTypeDefaultDescription
controllers.agentPool.syncPeriodstring"30s"The minimum frequency at which watched Agent Pool resources are reconciled. Format: 5s, 1m, etc.
controllers.agentPool.workersint1The number of the Agent Pool controller workers.
controllers.agentToken.syncPeriodstring"15m"The minimum frequency at which watched Agent Token resources are reconciled. Format: 5s, 1m, etc.
controllers.agentToken.workersint1The number of the Agent Token controller workers.
controllers.module.syncPeriodstring"5m"The minimum frequency at which watched Module resources are reconciled. Format: 5s, 1m, etc.
controllers.module.workersint1The number of the Module controller workers.
controllers.project.syncPeriodstring"5m"The minimum frequency at which watched Project resources are reconciled. Format: 5s, 1m, etc.
controllers.project.workersint1The number of the Project controller workers.
controllers.runsCollector.syncPeriodstring"15s"The minimum frequency at which watched Runs Collector resources are reconciled. Format: 5s, 1m, etc.
controllers.runsCollector.workersint1The number of the Runs Collector controller workers.
controllers.workspace.syncPeriodstring"5m"The minimum frequency at which watched Workspace resources are reconciled. Format: 5s, 1m, etc.
controllers.workspace.workersint1The number of the Workspace controller workers.
customCAcertificatesstring""The base64 encoded custom Certificate Authority bundle used to validate API TLS certificates.
imagePullSecretslist[]Reference to one or more secrets essential for pulling container images.
kubeRbacProxy.image.pullPolicystring"IfNotPresent"Image pull policy.
kubeRbacProxy.image.repositorystring"quay.io/brancz/kube-rbac-proxy"Image repository.
kubeRbacProxy.image.tagstring"v0.20.1"Image tag.
kubeRbacProxy.resources.limits.cpustring"500m"Limits as a maximum amount of CPU to be used by a container.
kubeRbacProxy.resources.limits.memorystring"128Mi"Limits as a maximum amount of memory to be used by a container.
kubeRbacProxy.resources.requests.cpustring"50m"Guaranteed minimum amount of CPU to be used by a container.
kubeRbacProxy.resources.requests.memorystring"64Mi"Guaranteed minimum amount of memory to be used by a container.
kubeRbacProxy.securityContextobject{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"seccompProfile":{"type":"RuntimeDefault"}}Container security context. More information in Kubernetes documentation.
operator.affinityobject{}Kubernetes Affinity. More information: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity
operator.envobject{}Environment variables.
operator.image.pullPolicystring"IfNotPresent"Image pull policy.
operator.image.repositorystring"hashicorp/hcp-terraform-operator"Image repository.
operator.image.tagstring""Image tag. Defaults to .Chart.AppVersion.
operator.resources.limits.cpustring"500m"Limits as a maximum amount of CPU to be used by a container.
operator.resources.limits.memorystring"128Mi"Limits as a maximum amount of memory to be used by a container.
operator.resources.requests.cpustring"50m"Guaranteed minimum amount of CPU to be used by a container.
operator.resources.requests.memorystring"64Mi"Guaranteed minimum amount of memory to be used by a container.
operator.securityContextobject{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"seccompProfile":{"type":"RuntimeDefault"}}Container security context. More information in Kubernetes documentation.
operator.skipTLSVerifyboolfalseWhether or not to ignore TLS certification warnings.
operator.syncPeriodstring"1h"The minimum frequency at which watched resources are reconciled. Format: 5s, 1m, etc.
operator.tfeAddressstring""The API URL of a Terraform Enterprise instance.
operator.tolerationslist[]Kubernetes Tolerations. More information: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
operator.watchedNamespaceslist[]List of namespaces the controllers should watch.
podLabelsobject{}Additional labels to add to the Operator pods.
priorityClassNamestring""Deployment priorityClassName. More information in Kubernetes documentation.
rbac.createbooltrueSpecifies whether a Role-Based Access Control (RBAC) resources should be created.
replicaCountint2The number of Operator replicas.
securityContextobject{"runAsNonRoot":true}Deployment pod security context. More information in Kubernetes documentation.
serviceAccount.annotationsobject{}Additional annotations for the ServiceAccount.
serviceAccount.createbooltrueSpecifies whether a ServiceAccount should be created.
serviceAccount.namestring""The name of the service account to use. If not set and create is true, a name is generated using the fullname template.

Deploy hcp-terraform-operator with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has hcp-terraform-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.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charthcp-terraform-operator is pinned at v2.12.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. 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