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

kubectl kustomize errored: error: specify one path to kustomization.yaml #8

Closed
prestonvanloon opened this issue Jul 5, 2022 · 6 comments

Comments

@prestonvanloon
Copy link

name: kustomization
on: push
    
env:
  DATREE_TOKEN: ${{ secrets.DATREE_TOKEN }} 

jobs:
  kustomize_check:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Run Datree Policy Check on Kustomize
        uses: datreeio/action-datree@69aaff54675fdbda959740657d0fc81be9afd4fc
        with:
          path: 'cluster/default/**'
          isKustomization: true
          cliArguments: '--policy Github --ignore-missing-schemas --output simple'

kubectl kustomize errored: error: specify one path to kustomization.yaml

It passes when using commit 460c784

@hadar-co
Copy link
Contributor

hadar-co commented Jul 6, 2022

Hi @prestonvanloon :)
We recently fixed an issue regarding globs (**), where they did not work recursively.
So now when you specify a path like 'cluster/default/**' all subdirectories will also be parsed. I am guessing that there is another "kustomization.yaml" somewhere inside your folder hierarchy, which is causing this error.

Is there a reason you're using a glob for this? When using Datree to run a policy check against a Kustomization, all you need to provide is the path to the dir containing the "kustomization.yaml" file. In your case - if, for example, that file is in the dir 'cluster/default/' then that is what you should pass to the path, without the '**'.

Let me know if that helps:)

@hadar-co
Copy link
Contributor

Hi @prestonvanloon, Have you had a chance to see if this resolves your issue?:)

@Taranpreet26311
Copy link

Taranpreet26311 commented Jul 11, 2022

Hey @hadar-co, the issue seems to be we have nested kustomized directories. We are using Gitops with Kustomized, the structure consists of the a root kustomized directory and component's kuztomized. We specify each parent directory in parent kustomized.yaml and the files for particular component in component's root kustomized.yaml. This is an example of our repository structure https://github.com/fluxcd/flux2-kustomize-helm-example/tree/main/infrastructure

@hadar-co
Copy link
Contributor

Hi @Taranpreet26311, this is the structure that the CLI expects, so in order to test the example you wrote here, you would set the path to "./infrastructure". Under the hood, Datree runs "kustomize build" on this directory and runs a pollicy check against the generated YAMLs.
However, from @prestonvanloon's comment, I understand that you added "**" to the path, which will cause the OS to recursively list all of the subdirectories as well, which I suspect is the cause of the error you're getting.
Can you try setting your parent kustomization folder as the path of the action (without "**") so we can test this theory?:)

@Taranpreet26311
Copy link

Hey @hadar-co this seems to have fixed the issue. Thanks for the assistance!

@hadar-co
Copy link
Contributor

Glad to hear, No problem:)

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

No branches or pull requests

3 participants