Skip to content

Conversation

foot
Copy link
Collaborator

@foot foot commented Nov 7, 2022

What changed?

  • Unify CAPITemplate / GitopsTemplate endpoints
    • POST /v1/tfcontroller now just calls /v1/clusters
    • /v1/clusters can now be called with templateKind=GitopsTemplate too
  • Right now CAPITemplates have some extra helpers during rendering
    • add-common-bases: includes a kustomization file that will apply all files in ./clusters/bases to the new cluster
    • inject-prune-annotation: proper cluster deletion of clusters with flux
    • CAPITemplates have both these transforms on by default
    • GitopsTemplates can enable with an annotation to help users transition to GitopsTemplate.

Behaviour changes

  • Preview now includes the common-bases if its been added
  • /v1/tfcontroller now includes the namespace in the path it writes out.
    • old: ./clusters/management/clusters/rds.yaml
    • new: ./clusters/management/clusters/default/rds.yaml

Closes #969
Closes #1062

Why was this change made?

  • So we have a single endpoint for rendering templates.
    • Render behaviour can be tweaked via annotations rather than using different endpoints.
    • We don't have to maintain two endpoints.
    • GitopsTemplates/CAPITemplates already use the same preview endpoint, now they use the same create-pr endpoint too.
  • We can remove the /v1/tfcontroller endpoint in the future.

How did you validate the change?

Unit tests

foot added 2 commits November 7, 2022 09:58
- Also fix bug where we're ignoring the default namespace of a values
  when calculatig paths
@foot foot added the exclude from release notes Use this label to exclude a PR from the release notes label Nov 7, 2022
@foot foot marked this pull request as ready for review November 8, 2022 09:29
Copy link
Contributor

@bigkevmcd bigkevmcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this.

I have concerns around the defaulting of the template kind, and around the annotation for pruning, it feels like an odd thing (why would you add it there, but not on the resources that follow?) but it's cheap to maintain and do, so I don't think this is a blocker.

@foot
Copy link
Collaborator Author

foot commented Nov 8, 2022

around the annotation for pruning, it feels like an odd thing (why would you add it there, but not on the resources that follow?)

Yeah, it gets added to everything except capi.Cluster / weave.GitopsCluster. So it will get applied to any other kustomizations/helmreleases you might add too which is no good, feels a bit broken. We could try and improve it so it gets applied to everything in apiVersion: /.*cluster.x-k8s.io.*/ thats not a Cluster.

It is a bit of a funky/"magic" feature, but its sort of nice UX too, lets the user write templates without having to understand the subtler issues around managing CAPI with flux. How does argo handle this.. 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude from release notes Use this label to exclude a PR from the release notes
Projects
None yet
2 participants