-
Notifications
You must be signed in to change notification settings - Fork 614
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
Preview local changes with flux diff kustomization
#2142
Comments
@souleb I think that for a PoC of this feature, we could copy the code from kustomize-controller in
|
At the moment I'm using filter-encrypted-secrets.js#!/usr/bin/env node
function readStdin() {
process.stdin.setEncoding('utf8')
return new Promise((resolve, reject) => {
let string = ''
process.stdin.on('data', (chunk) => { string += chunk })
process.stdin.on('end', () => resolve(string))
})
}
if (!process.stdin.isTTY) {
(async function exec () {
const yaml = await readStdin()
const docs = yaml.split(/^---+/m)
for (let i = 0; i < docs.length; i++) {
if (docs[i].match(/^sops:$/m)) continue
process.stdout.write(docs[i].startsWith('\n') ? `---${docs[i]}` : `---\n${docs[i]}`)
}
})()
} else {
process.stderr.write('Please pipe into this command\n')
process.exit(1)
} I also tried to decrypt the secrets using sops instead of filtering them out, but sadly |
@marcbachmann thanks for the example. For now, Any thoughts on how you would decrypt with a local setup? |
I guess a clean solution would be to wrap filesys and override the
Doesn't the sops module already properly handle the key lookup using env variables and default locations? It's definitely good to first implement the support without encrypted secret support, as this is the most common case. Most likely not all developers working in a flux setup have set up the keys. Thanks for working on that 👏 |
@stefanprodan How would the output of One example: I tried to implement a diff based on a feature branch workflow where a CI pipeline job runs on pull / merge requests and reports the changes that would be applied to the cluster, as soon as the code changes are merged. I chose dyff for this job by using the |
@jrauschenbusch |
@stefanprodan So if i get you right, then this added metadata / annotation shouldn't be reflected in the diff output, right? |
There will be no diff to show since the labels added by the controller will be the same with the ones added by the CLI. |
Followup of: fluxcd/kustomize-controller#426
To allow users to preview changes to their Kustomize overlays without committing changes to upstream, Flux CLI could offer two commands:
flux build kustomization my-app -f ./path/to/local/manifests
flux diff kustomization my-app -f ./path/to/local/manifests
The
build
command queries the Kubernetes API and fetches the specified Flux Kustomization, then it uses the specified local path-f
to build the overlay (using the same logic as kustomize-controller) to write the resulting multi-doc YAML to stdout.The
diff
command does the same thing asbuild
but instead of outputting the manifest, it uses them to perform a server-side dry-run and write the YAML diff to stdout. An example of how the output could look can be found here: https://github.com/stefanprodan/kustomizer.Given that SOPS encrypted secrets can't be decrypted outside the cluster (due to IRSA, Azure AD, etc) the
build
anddiff
commands should detect the SOPS secrets and skip them from the output.We need to extract the kustomize patch overrides, kustomize build and post build variable substitution logic from kustomize-controller into
fluxcd/pkg
then use these helpers in both the controller and Flux CLI.The text was updated successfully, but these errors were encountered: