Flux sync git state with cluster state but If I want to delete a resource from Kubernetes in a scenerio where all resources are managed through git, what is the best way to delete a resource (deplyment, service, ingress etc) with flux ?
Flux has an experimental (but quite mature) garbage collection feature that can be enabled by setting the --sync-garbage-collection
flag as an argument on the Flux daemon deployment (or by setting syncGarbageCollection.enabled
to true
in your values.yaml
in case you are deploying Flux using the Helm chart).
With the garbage collection feature enabled, Flux will remove resources from Kubernetes when they are removed from git.
You can find in depth information about the garbage collection feature in the documentation.