Kubernetes CRD to handle terraform operations.
Below is a diagram of the basic idea of the project
The controller is responsible for fetching tfvars or other files, and then creates a Kubernetes Job to perform the actual terraform execution. By default, the Terraform-operator will save state in a Consul on the same cluster. Even though Consul is the default, other state backends can be configured.
- terraform-state
- credentials (eg cloud credentials)
- other-credentials (eg ssh key)
To get started, install the files in deploy
kubectl apply -f deploy/crds/tf.isaaguilar.com_terraforms_crd.yaml
kubectl apply -f deploy --namespace tf-system
Once the operator is installed, terraform resources are ready to be deployed.
Check out the examples directory to see the different options tf-operator handles. See complete-examples for realistic examples.
Apply your first terraform resource by running a hello_world example:
$ printf 'apiVersion: tf.isaaguilar.com/v1alpha1
kind: Terraform
metadata:
name: tf-operator-test
spec:
stack:
terraformVersion: 0.12.23
source:
address: https://github.com/cloudposse/terraform-aws-test-module.git
config:
customBackend: |-
terraform {
backend "local" {
path = "relative/path/to/terraform.tfstate"
}
}
applyOnCreate: true
applyOnUpdate: true
ignoreDelete: true
'|kubectl apply -f-
Check the kubectl pod logs:
$ kubectl logs -f job/tf-operator-test
Delete the resource:
$ kubectl delete terraform tf-operator-test
More examples coming soon!
Requires the following installed on your system:
- go v1.13.3
- operator-sdk v0.15.1