/terraform-operator

A Kubernetes CRD to handle terraform operations

Primary LanguageGoApache License 2.0Apache-2.0

Terraform Operator

A Kubernetes CRD and Controller to handle Terraform operations by generating k8s jobs catered to perform Terraform workflows

What is terraform-operator?

This project is:

  • A way to run Terraform in Kubernetes by defining Terraform deployments as Kubernetes manifests
  • A controller that configures and starts Kubernetes Jobs when it sees changes to the Kubernetes manifest
  • A Terraform runner which runs Terraform plan/apply, and can also perform pre and post scripts

This project is not:

  • An HCL to YAML converter or vice versa
  • A Terraform module definition

Quick Start

Install the operator with helm:

helm repo add isaaguilar https://isaaguilar.github.io/helm-charts 
helm repo update
helm install terraform-operator isaaguilar/terraform-operator

Then start running workloads. For example from this repo, run:

kubectl apply -f examples/complete-examples/simple-template.yaml

A terraform runner pod should appear shortly. The runner executes the terraform module configured in spec.terraformModule.address. In the example, the module configured is https://github.com/cloudposse/terraform-example-module.git?ref=master which simply generates a random number.

Development

Requires the following installed on your system:

  • go >= v1.15.0

Run make install to install or update the crd in your current-context cluster.

Finally, run make run to start the controller to operate in your current-context cluster.

Docs

Installation

Configurations

Advanced Topics

Architecture

Contributing

Issues and Pull Requests are welcomed.