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

Kustomization creation fails when dir contains non-k8 yaml files #175

Closed
kowalczykp opened this issue Nov 17, 2020 · 3 comments · Fixed by #176
Closed

Kustomization creation fails when dir contains non-k8 yaml files #175

kowalczykp opened this issue Nov 17, 2020 · 3 comments · Fixed by #176

Comments

@kowalczykp
Copy link
Contributor

First of all, thanks for the amazing work on flux v2!

When testing migration from v1, I've noticed an issue with kustomization generation: Given a directory, which does not contain kustomization.yaml, but containing other yaml files not related to kubernetes objects kustomization creation fails with:

kustomize create failed: failed to decode Kubernetes YAML from /tmp/flux-system630708581/.sops.yaml: error unmarshaling JSON: while decoding JSON: Object 'Kind' is missing in '{"creation_rules":[{"XXX":"projects/XXX/locations/global/keyRings/XXX/cryptoKeys/XXX","path_regex":"\\.secret\\.yaml$"}]}'

This can be triggered by having YAML files like .sops.yaml or ci workflows definitions e.g. .gitlab-ci.yml in root directory and not having kustomization.yaml

Flux v1 ignored non-k8 yaml files thanks to this func , whereas v2 and the kustomization flow requires all of yaml files to be k8 by using SliceForBytes for validation.

Possible workaround: simply adding kustomization.yaml in the affected directories, but this requires action and makes migration a bit more demanding for new users.

I'd be happy to contribute a fix or to document the workaround in case this gets considered as working as intended.

@stefanprodan
Copy link
Member

stefanprodan commented Nov 18, 2020

You can exclude files in the GitRepository:

apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
spec:
  ignore: |
    .git/
    .sops.yaml
    .gitlab-ci.yml

docs: https://toolkit.fluxcd.io/components/source/gitrepositories/#excluding-files

@stefanprodan
Copy link
Member

@kowalczykp I think we could add in this docs section a GitRepository exclusion example. Can you please open a PR for that?

@kowalczykp
Copy link
Contributor Author

thanks @stefanprodan! Exclusion via source ignore works like a charm and resolved the issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants