GalleyBytes / terraform-operator

A Kubernetes CRD to handle terraform operations
http://tf.galleybytes.com
Apache License 2.0
364 stars 47 forks source link

Question about instance_name in run script #109

Closed ankitm123 closed 2 years ago

ankitm123 commented 2 years ago

In the run.sh file, I see INSTANCE_NAME being used https://github.com/isaaguilar/terraform-operator/blob/14f1a807e293d05b05c66b61dbe4478433ee074f/docker/terraform/run.sh#L3

Where is it being set (I described the resulting pod, and did not see any environment variable set for INSTANCE_NAME)? I searched the repository and did not see any references outside the run shell script. I am trying to use a custom terraform image for jenkins x bdd tests.

it seems like it's the name of the pod which runs the init/plan/apply workflows.

isaaguilar commented 2 years ago

$INSTANCE_NAME has been removed a bit ago. The last reference to it was https://github.com/isaaguilar/terraform-operator/blob/v0.3.10/pkg/controllers/terraform_controller.go#L1132-L1133. Since then the architecture of TFO has changed.

The ability to use custom images is still available but a bit involved now and not well documented. Furthermore, the spec has changed with lots of breaking changes. There's a changelog for what it's worth. https://github.com/isaaguilar/terraform-operator/releases?page=3

Example of new image selections in the spec:

kind: Terraform
metadata:
  name: deploy0
spec:
  #
  # runner images gets concatenated with the corresponding version `<image>:<version>`
  #
  terraformRunner: your-repo/image 
  terraformVersion: 0.13.7
  setupRunner: you-repo/setup-image  # Download/Setup the terraform module
  setupRunnerVersion: 
  scriptRunner: your-repo/script-image  # Image to run extra scripts defined elsewhere in the spec
  scriptRunnerVersion: 
  # ...

And the scripts that get used by default for these images: https://github.com/isaaguilar/terraform-operator/tree/master/terraform-runner

There is still lots of development to do on this project.

ankitm123 commented 2 years ago

Yes, I saw this yesterday night (thanks for the reply :) ). I was able to get it to work without using custom images, basically installing the packages as part of postApplyscript, it unblocks our release pipeline for now, so closing this issue.