Skip to content
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

Feature/plan pvc support #480

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

itamar-marom
Copy link
Contributor

@itamar-marom itamar-marom commented Dec 14, 2022

#336

With this PR, we can store terraform plans in Kubernetes PersistentVolumeClaim.
The given PVC should exist already and is not part of the controller's responsibility.

  • Also supports all current options of storeReadablePlan

The runner will mount into a subPath that points to its own directory. The path looks like this:
/mnt/plan/terraform_controller/TERRAFORM_OBJECT_NAMESPACE/TERRAFORM_OBJECT_NAME/
This gives the security of a runner to mount only into its own object and also takes care the backend storage is organized and can serve other stuff then the terraform controller.

Example:

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: plan-config-claim-pv
  labels:
    type: local
spec:
  storageClassName: standard
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/tmp/plan-test"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: plan-config-claim-pvc
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: infra.contrib.fluxcd.io/v1alpha1
kind: Terraform
metadata:
  name: helloworld-plan-config-claim
spec:
  interval: 10s
  approvePlan: "auto"
  storeReadablePlan: "human"
  path: ./
  planConfig:
    storage:
      claimName: "plan-config-claim-pvc"
  sourceRef:
    kind: GitRepository
    name: helloworld

@itamar-marom itamar-marom changed the title Feature/plan pvc support [WIP] Feature/plan pvc support Dec 19, 2022
@itamar-marom itamar-marom changed the title [WIP] Feature/plan pvc support Feature/plan pvc support Dec 19, 2022
@itamar-marom
Copy link
Contributor Author

Hi @yitsushi
Are you into reviewing this also? If so I will fix the conflicts.
Link to issues: #336 #536

@yitsushi
Copy link
Collaborator

You can, but I can't promise I'll have time to review in the near future as it requires changes we have to consider if we even want/can do.

  1. It'll conflict with main when Feature/add tfvarspaths spec2 #1185 is merged, so you would have to resolve again.
  2. It adds an extra resource to manage and we are already working on a solution to reduce that dependency or at least be able to reconcile is those resources are not available.

One of the main goals of the Workspace BLOB cache initiative is to prevent stuck resources when Source gets deleted before the Terraform resource. With this addition we would have to think about that extra dependency too, cache somewhere, manage what happens if it can't mount the resource yet still don't get stuck on a reconcile loop unable to even delete the resource without patching the finalizer and hacking the system hoping everything works out.

Any ideas, suggestions, opinions @chanwit ?

@tyriis
Copy link

tyriis commented Jul 21, 2024

👋 hi there, I am currently running in the issue, that my plan is to big. Just out of curiosity, what is wrong with the PR apart from the merge conflict?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants