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

Recursively diff Kustomizations #4939

Merged
merged 1 commit into from
Sep 9, 2024
Merged

Conversation

bkreitch
Copy link
Contributor

This PR will add --recursive flag to recursively diff encountered Kustomizations similar to discussions #2466, #2434, #820. (Currently it doesn't expand HelmReleases, probably could be added later).

Sources of additional repositories can be provided as comma-separated list by --local-sources Kind/namespace/name=path (i.e. --local-sources GitRepository/flux-system/flux-gitops=$HOME/git/flux-gitops)

Couple of words on our use case and motivation. We have number of clusters of different kinds sharing common GitOps repository with Kustomizations and overrides. To avoid unexpected changes most clusters are locked to a specific SHA instead of main branch. So promoting to a new SHA requires comparing the changes in Git and figuring out how it will affect the specific cluster.

This feature will allow to run on all applicable to the cluster Kustomizations indicating only ones that have the actual change. Example of the output:

$ flux diff kustomization flux-system --path ~/git/flux-system/clusters/eks/dev/ie1 --recursive \
> --local-sources GitRepository/flux-system/flux-gitops=$HOME/git/flux-gitops
✓  Kustomization diffing...
► ConfigMap/flux-system/cluster-vars drifted

data.kube_cluster_env
  ± value change
    - dev
    + test

📁 Kustomization/flux-system/flux-gitops changed
📁 Kustomization/flux-system/ebs changed
► HelmRelease/kube-system/aws-ebs-csi-driver drifted

metadata.generation
  ± value change
    - 2
    + 3

spec.chart.spec.version
  ± value change
    - 2.29.0
    + 2.33.0

► Kustomization/flux-system/docker-registry deleted
► Namespace/test created
► Kustomization/flux-system/tigera-operator created
► Kustomization/flux-system/tigera-policies created
⚠️ identified at least one change, exiting with non-zero exit code

internal/build/build.go Dismissed Show dismissed Hide dismissed
@stefanprodan stefanprodan added the area/diff Diff related issues and pull requests label Aug 17, 2024
@stefanprodan stefanprodan self-requested a review August 17, 2024 13:30
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @bkreitch 🏅

@stefanprodan stefanprodan merged commit d13dec2 into fluxcd:main Sep 9, 2024
7 checks passed
@stefanprodan stefanprodan mentioned this pull request Sep 11, 2024
57 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/diff Diff related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants