-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tainting Resources #31
Comments
Tainting of which kind of resources? |
Any resource controlled by terraform |
Interesting. I have not personally used terraform taint before. Would you happen to have an example of how taint might fit into the terraform-operator/runner workflow? |
I'm fairly familiar with operators, written a couple myself, I've generally found using annotations as a decent way of handling ephemeral or single time tasks. Let's say you have a terraform project that deploys 30 resources and you need to rebuild 1 resource, maybe it's a server, maybe it's AWS keys. Once tainted on a new plan/apply it'll be rebuilt/replaced depending on the resource type. How I've handled this in the past is by using annotations, but there might be better ways.
The operator would see it, run a taint, remove the annotation, then run plan/apply or something to that affect. Happy to discuss further and talk options. Examples
|
I'm going to make it a point to play around with taint this week so we can talk about fitting it into terraform-operator. |
Hi @ekristen I was thinking about this for a little bit and it dawned on me that tainting a resource after running is a perfect use case for For example, if this were my manifest file, let's call it # taint-test.yaml
apiVersion: tf.isaaguilar.com/v1alpha1
kind: Terraform
metadata:
name: tainttest
spec:
terraformVersion: 0.13.4
terraformRunnerPullPolicy: IfNotPresent
terraformModule:
address: https://github.com/cloudposse/terraform-aws-test-module.git
customBackend: |-
terraform {
backend "kubernetes" {
secret_suffix = "tainttest"
in_cluster_config = true
}
}
applyOnCreate: true
applyOnUpdate: true
applyOnDelete: true
ignoreDelete: false # Make sure to clean up example and delete on `kubectl delete`
postrunScript: |-
#/bin/bash
#
# cd into the directory TerraformRunner executes terraform commands
#
cd /main_module
#
# Taint the resource from this run. (No need to run init since
# the TerraformRunner has already initialized earlier
#
terraform taint "random_integer.example[0]" Apply the manifest to create the resource. $ kubectl apply -f taint-test.yaml
terraform.tf.isaaguilar.com/tainttest created Check the logs to see that the $ kubectl logs -l job-name=tainttest
...
Resource instance random_integer.example[0] has been marked as tainted. Trigger terraform-operator to schedule a new run by deleting the $ kubectl delete job -l job-name=tainttest
job.batch "tainttest" deleted The terraform-operator creates a new job. By tailing the logs again you'll see the taint in effect $ kubectl logs -l job-name=tainttest
...
Terraform will perform the following actions:
# random_integer.example[0] is tainted, so must be replaced
... Cleanup as usual $ kubectl delete -f taint-test.yaml
terraform.tf.isaaguilar.com "tainttest" deleted |
Ah, speaking out loud here, the use case we're seeking might be more of tainting "on demand". The annotation method would be a viable solution. Some small tweaks would need to be made to the TerraformRunner's |
Have you considered how to support tainting of resources?
The text was updated successfully, but these errors were encountered: