Allow pre-bootstrap customisation of Flux components #1300
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PRs changes the bootstrap logic to allow customising the Flux manifests before or after bootstrap.
Overview
This PR enables users to set annotations (IAM role bindings, safe-to-evict, etc), node affinity and tolerations, change the number of replicas, the resources requests and limits, the container group id and user id, etc before the controllers are deployed on the cluster. Besides patching the controllers, users can patch the sync manifests too, this would allow disabling pruning, enabling SOPS and other customisations not cover by bootstrap cmd args.
Customize Flux manifests
You can customize the Flux components before or after running bootstrap.
Assuming you want to customize the Flux controllers before they get deployed on the cluster,
first you'll need to create a Git repository and clone it locally.
Create the file structure required by bootstrap with:
Assuming you want to add custom annotations and labels to the Flux controllers,
edit
clusters/my-cluster/gotk-patches.yaml
and set the metadata for source-controller and kustomize-controller pods:Edit
clusters/my-cluster/kustomization.yaml
and set the resources and patches:Push the changes to main branch:
Now run the bootstrap for
clusters/my-cluster
:When the controllers are deployed for the first time on your cluster, they will contain all
the customizations from
gotk-patches.yaml
.You can make changes to the patches after bootstrap and Flux will apply them in-cluster on its own.
Issues
Fix: #1166
Fix: #1180
Refs: #829 fluxcd/terraform-provider-flux#120 fluxcd/terraform-provider-flux#130