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

Source path must contain a kustomization.yaml when using kustomize.patches #16352

Open
3 tasks done
morey-tech opened this issue Nov 15, 2023 · 9 comments
Open
3 tasks done
Labels
component:config-management Tools specific issues (helm, kustomize etc) component:core Syncing, diffing, cluster state cache component:docs enhancement New feature or request

Comments

@morey-tech
Copy link
Contributor

morey-tech commented Nov 15, 2023

Checklist:

  • I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • I've included steps to reproduce the bug.
  • I've pasted the output of argocd version.

Describe the bug
The docs (add in crenshaw-dev#20) state that:

Patches are a way to kustomize resources using inline configurations in Argo CD applications. This allows for kustomizing without [a] kustomization file.

However, when using the kustomize.patches field, the Application expects the path to contain a kustomization.yaml file. Without one, the sync will fail with the error open <path to cached source>/<path>/kustomization.yaml: no such file or directory.

Failed to load target state: failed to generate manifest for source 1 of 1: rpc error: code = Unknown desc = Manifest generation error (cached): failed to load kustomization.yaml: open <path to cached source>/guestbook/kustomization.yaml: no such file or directory

To Reproduce
Deploy the Application from the example in the docs:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: kustomize-inline-guestbook
spec:
  destination:
    namespace: default
    name: in-cluster
  project: default
  source:
    path: guestbook
    repoURL: https://github.com/argoproj/argocd-example-apps.git
    targetRevision: HEAD

## In-line Kustomize on plain Kubernetes manifests.
    kustomize:
      patches:
        - target:
            kind: Deployment
            name: guestbook-ui
          patch: |-
            - op: replace
              path: /spec/template/spec/containers/0/ports/0/containerPort
              value: 443

Expected behavior

The Application should ignore a missing kustomization.yaml file in the path when kustomize.patches is used. Or some equivalent (e.g. a toggle to allow missing).

Screenshots

Xnapper-2023-11-15-14 19 54

Version

Paste the output from `argocd version` here.

Logs

Paste any relevant application logs here.
@morey-tech morey-tech added bug Something isn't working component:config-management Tools specific issues (helm, kustomize etc) labels Nov 15, 2023
@crenshaw-dev
Copy link
Member

I think this is actually an enhancement request, i.e. automatically create kustomization.yaml for the user if spec.source.kustomize is populated and the file doesn't already exist.

@morey-tech
Copy link
Contributor Author

Good point. The bug is the wording and example in the docs. The feature request is the expected behaviour. I'll put in a PR for the former.

@morey-tech morey-tech added enhancement New feature or request and removed bug Something isn't working labels Nov 15, 2023
morey-tech added a commit to morey-tech/argo-cd that referenced this issue Nov 15, 2023
Related to: argoproj#16352 Also, add an ApplicationSet example. 

Signed-off-by: Nicholas Morey <nicholas@morey.tech>
@alexmt
Copy link
Collaborator

alexmt commented Nov 15, 2023

@morey-tech as I understand the use case is to allow users to apply last mile customization to any application (plain yaml, helm, plugin etc), correct? In this case Argo CD cannot just auto-create kustomization.yaml. E.g. app is helm-based then auto-creating kustomization.yaml would switch app to kustomize rendering and just break manifest generation. I think it is an entirely different feature. Argo CD would need to generate manifests first, then store result in e.g. all.yaml and leverage kustomize to apply patches on top. This would require a new field in the application spec:

spec:
...
## The field definitely should not be kustomize, because kustomize holds "inputs" for kustomize based apps.
    overrides:
      patches:
        - target:
            kind: Deployment
            name: guestbook-ui
          patch: |-
            - op: replace
              path: /spec/template/spec/containers/0/ports/0/containerPort
              value: 443

alexmt pushed a commit that referenced this issue Nov 15, 2023
* docs: fix kustomize patches example

Related to: #16352 Also, add an ApplicationSet example. 

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

* fix: spelling

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

---------

Signed-off-by: Nicholas Morey <nicholas@morey.tech>
GilUpstream pushed a commit to GilUpstream/argo-cd that referenced this issue Nov 15, 2023
* docs: fix kustomize patches example

Related to: argoproj#16352 Also, add an ApplicationSet example.

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

* fix: spelling

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

---------

Signed-off-by: Nicholas Morey <nicholas@morey.tech>
Signed-off-by: Gilad Salmon <gilad.salmon@gmail.com>
vladfr pushed a commit to vladfr/argo-cd that referenced this issue Dec 13, 2023
* docs: fix kustomize patches example

Related to: argoproj#16352 Also, add an ApplicationSet example. 

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

* fix: spelling

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

---------

Signed-off-by: Nicholas Morey <nicholas@morey.tech>
@acelinkio
Copy link

acelinkio commented Dec 15, 2023

@alexmt My thought when contributing to the docs was the inline kustomization feature was to avoid needing any kustomize.yaml

Definitely would appreciate a built in way to do last mile modifications to resources.

Until then I created a quick plugin for doing kustomizations inline.

echo "$ARGOCD_ENV_KUSTOMIZATION_YAML" > kustomization.yaml;
kustomize build

And able to consume do everything inline

https://github.com/acelinkio/argocd-homelab/blob/main/manifest/knative-serving.yaml

I'll try to create an equivalent one for doing last mile modification to helm charts. (Definitely do not want to leverage kustomize to use the helm binanry and do a helm release)

tesla59 pushed a commit to tesla59/argo-cd that referenced this issue Dec 16, 2023
* docs: fix kustomize patches example

Related to: argoproj#16352 Also, add an ApplicationSet example. 

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

* fix: spelling

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

---------

Signed-off-by: Nicholas Morey <nicholas@morey.tech>
lyda pushed a commit to lyda/argo-cd that referenced this issue Mar 28, 2024
* docs: fix kustomize patches example

Related to: argoproj#16352 Also, add an ApplicationSet example.

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

* fix: spelling

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

---------

Signed-off-by: Nicholas Morey <nicholas@morey.tech>
Signed-off-by: Kevin Lyda <kevin@lyda.ie>
Hariharasuthan99 pushed a commit to AmadeusITGroup/argo-cd that referenced this issue Jun 16, 2024
* docs: fix kustomize patches example

Related to: argoproj#16352 Also, add an ApplicationSet example. 

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

* fix: spelling

Signed-off-by: Nicholas Morey <nicholas@morey.tech>

---------

Signed-off-by: Nicholas Morey <nicholas@morey.tech>
@SaschaJohn
Copy link

@morey-tech is there any possibility to get this roadmaped? Thanks in advance

@alexmt alexmt added bug Something isn't working component:core Syncing, diffing, cluster state cache component:docs type:bug labels Jul 19, 2024
@andrii-korotkov-verkada andrii-korotkov-verkada removed bug Something isn't working type:bug labels Nov 11, 2024
@mattrasband
Copy link

mattrasband commented Feb 19, 2025

I am not sure if this is expected or fully related, but we have a kustomization.yml that is working - when we use the patches it fails with the same error above about not finding kustomization.yaml. Notably without patches being included the .yml one is fine and argo doesn't mind the difference. Is there a bug where this is specifically looking for the .yaml extension?

Edit: yes, it appears that this specific code path only wants a .yaml instead of checking the other allowed extensions.

@crenshaw-dev
Copy link
Member

@mattrasband would you open a separate issue for that bug? And a PR if you're feeling generous. :-)

@mattrasband
Copy link

@mattrasband would you open a separate issue for that bug? And a PR if you're feeling generous. :-)

Will do!

@mattrasband
Copy link

I will try to get to this in the next day or so. #21914

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:config-management Tools specific issues (helm, kustomize etc) component:core Syncing, diffing, cluster state cache component:docs enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants