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

Can't get a patch file to contain multiple patches? #4030

Closed
1 task done
belkevglaz opened this issue Jul 4, 2023 · 3 comments
Closed
1 task done

Can't get a patch file to contain multiple patches? #4030

belkevglaz opened this issue Jul 4, 2023 · 3 comments

Comments

@belkevglaz
Copy link

Describe the bug

Inline patches in kustomization.yaml allow to define multiple patches. At the same time, the same patches in a separate file will get errors.

Reconcile error

flux reconcile kustomization apps-base-gitrepository --with-source 
► annotating GitRepository flux-system in flux-system namespace
✔ GitRepository annotated
◎ waiting for GitRepository reconciliation
✔ fetched revision master@sha1:629fcf2c850c838d32eb114720b6750b9c863f88
► annotating Kustomization apps-base-gitrepository in flux-system namespace
✔ Kustomization annotated
◎ waiting for Kustomization reconciliation
✗ Kustomization reconciliation failed: kustomize build failed: trouble configuring builtin PatchTransformer with config: `
path: helmreleases-patch.yaml
`: unable to parse SM or JSON patch from [---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: app-one
  namespace: default
spec:
  values:
    app:
      replicaCount: 2
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: app-two
  namespace: default
spec:
  values:
    app:
      replicaCount: 2]

Steps to reproduce

kustomizaion.yaml with inline patches that workin well.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ../base/app-one
  - ../base/app-two
patches:
 - target:
     kind: HelmRelease
     name: app-one
   patch: |-
       apiVersion: helm.toolkit.fluxcd.io/v2beta1
       kind: HelmRelease
       metadata:
         name: app-one
       spec:
         values:
           app:
             replicaCount: 2
 - target:
     kind: HelmRelease
     name: app-two
   patch: |-
     apiVersion: helm.toolkit.fluxcd.io/v2beta1
     kind: HelmRelease
     metadata:
       name: app-two
     spec:
       values:
         app:
           replicaCount: 2

Second option wtih kustomization.yaml and patch.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ../base/app-one
  - ../base/app-two
patches:
  - path: patch.yaml

patch.yaml

---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
 name: app-one
 namespace: default
spec:
 values:
   app:
     replicaCount: 2
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
 name: app-two
 namespace: default
spec:
 values:
   app:
     replicaCount: 2

Expected behavior

To be able to configure multiple patches in a patch file.

Screenshots and recordings

No response

OS / Distro

Ubuntu 23.04

Flux version

flux: v2.0.0-rc.1

Flux check

► checking prerequisites
✔ Kubernetes 1.24.8 >=1.20.6-0
► checking controllers
✔ helm-controller: deployment ready
► ghcr.io/fluxcd/helm-controller:v0.32.1
✔ image-automation-controller: deployment ready
► ghcr.io/fluxcd/image-automation-controller:v0.32.0
✔ image-reflector-controller: deployment ready
► ghcr.io/fluxcd/image-reflector-controller:v0.27.0
✔ kustomize-controller: deployment ready
► ghcr.io/fluxcd/kustomize-controller:v1.0.0-rc.1
✔ notification-controller: deployment ready
► ghcr.io/fluxcd/notification-controller:v1.0.0-rc.1
✔ source-controller: deployment ready
► ghcr.io/fluxcd/source-controller:v1.0.0-rc.1
► checking crds
✔ alerts.notification.toolkit.fluxcd.io/v1beta2
✔ buckets.source.toolkit.fluxcd.io/v1beta2
✔ gitrepositories.source.toolkit.fluxcd.io/v1
✔ helmcharts.source.toolkit.fluxcd.io/v1beta2
✔ helmreleases.helm.toolkit.fluxcd.io/v2beta1
✔ helmrepositories.source.toolkit.fluxcd.io/v1beta2
✔ imagepolicies.image.toolkit.fluxcd.io/v1beta2
✔ imagerepositories.image.toolkit.fluxcd.io/v1beta2
✔ imageupdateautomations.image.toolkit.fluxcd.io/v1beta1
✔ kustomizations.kustomize.toolkit.fluxcd.io/v1
✔ ocirepositories.source.toolkit.fluxcd.io/v1beta2
✔ providers.notification.toolkit.fluxcd.io/v1beta2
✔ receivers.notification.toolkit.fluxcd.io/v1
✔ all checks passed

Git provider

GitLab

Container Registry provider

No response

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@stefanprodan
Copy link
Member

This is not supported by https://github.com/kubernetes-sigs/kustomize

@stefanprodan stefanprodan closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2023
@grrttedwards
Copy link

Just FYI kubernetes-sigs/kustomize#5049

So this feature is now possible on flux 1.2.0+ ?
https://github.com/fluxcd/kustomize-controller/blob/main/CHANGELOG.md#120

@stefanprodan
Copy link
Member

Yes it should if that PR is included in Kustomize v.5.3. If it works locally by running kustomize build then it will also work with Flux as we use the same code as the kustomize CLI.

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