Open m-trojanowski opened 1 year ago
I'm facing very similar issues in my projects. If behavior will not be recovered then I will have to rewrite a lot of Kustomize specs I'm using now :(
Similar, but different, with 4.x to 5.x I'm seeing,
Error: unable to find field "spec.template.metadata.labels.[app.kubernetes.io/version]" in replacement target
for a replacement
template like
source:
kind: Rollout
name: XXX
fieldPath: spec.template.spec.containers.0.image
options:
delimiter: ':'
index: 1
targets:
- select:
kind: Namespace
fieldPaths:
- metadata.labels.[app.kubernetes.io/version]
- select:
namespace: XXX
fieldPaths:
- metadata.labels.[app.kubernetes.io/version]
- spec.template.metadata.labels.[app.kubernetes.io/version]
- spec.template.metadata.labels.[tags.datadoghq.com/version]
/assign
I am also experiencing this issue with replacements.
The previous behavior on create: false
was to ignore if missing. Now, create: false
fails if missing.
This is the the config that I am using.
source:
kind: ConfigMap
name: my-config-map
fieldPath: data.my-field
targets:
- select:
apiVersion: storage.k8s.io
kind: StorageClass
fieldPaths:
- parameters.network
options:
create: false
IF the following exists, then the replacement works.
apiVersion: storage.k8s.io/v1
kind: StorageClase
metadata:
name: my-storage-class
parameters:
network: <REPLACE_ME>
But if the resource does not contain parameters.network
, then kustomize fails with this error:
Error: unable to render the source configs in /path/to/directory: failed to run kustomize build in /path/to/directory, stdout: : Error: accumulating components: accumulateDirectory: "recursed accumulation of path '/path/to/directory/components': unable to find field \"parameters.network\" in replacement target
The regex issue is interesting and I will try to find time to think about it.
But -
The previous behavior on create: false was to ignore if missing. Now, create: false fails if missing.
That was an intentional change that we announced in the release notes. Because it was intentional and released with a major bump, I don't think we would consider that an issue or a regression.
@natasha41575 any thoughts about what I ran across, which wasn't using a regex, but had the same error as originally reported?
I'm having the same issue as @m-trojanowski with replacements no longer working after 4.5.7
@natasha41575
It would be really great to have such feature. Before 5.0.0
I was able to cycle trough all my manifests and alter only ones that I wanted to, but now I'm quite limited because of this. Maybe there is a chance to introduce some extra flag to alter this behavior?
I can offer my time as well to help to implement it if needed.
Cheers!
I'm having problems also trying to use replacements
on targets with wildcards:
replacements:
- source:
kind: GitRepository
fieldPath: metadata.name
targets:
- select:
kind: HelmRelease
fieldPaths:
- spec.valuesFrom.*.name
Hi @natasha41575. I am facing the same issues with the new create: false
behavior, which now fails when the resource is missing. This completely breaks my current workflow of using multiple overlays to create preview environments, so I have to stick with v4.
It would be great to have an option/flag to allow using the previous behavior for specific replacements.
Hi @natasha41575, Do you know if there is any plan to address this issue? My current specs are not rendering properly because of change reported here and because of that I can't migrate to Kustomize v5 :(
I'm experiencing this regex issue with kustomize 5.1.0. Would love to see it fixed.
Hey any update on this @natasha41575?
May there should be an additional option continueOnFailure: true or skip: true which covers the case that there are possible replacement targets which don't have and don't need the value. I'm heavily using the labelSelector to not manage all resource by name. Unfortunatly I'm now forced to manage the restrict list with the resource which are failiing currently
Hi @natasha41575 , I've added #5280 draft so we can continue discussion on how to approach this issue and whether it's even possible. Cheers!
May there should be an additional option continueOnFailure: true or skip: true which covers the case that there are possible replacement targets which don't have and don't need the value. I'm heavily using the labelSelector to not manage all resource by name. Unfortunatly I'm now forced to manage the restrict list with the resource which are failiing currently
I second this. As currently the 5.x versions rendered my whole project useless. I use kustomize together with ArgoCD and have set up a project consisting of 10+ Openshift namespaces being provided with 100+ components (dc, svc, rt, you name it) each with the Openshift templates being generated by kustomize.
Components may share certain parameters, or a parameter may be used by only one component. The parameters are provided by a key-value-template and are being replaced with replacements blocks. This mechanism is now completely broken and I will have to rewrite the whole thing and use rejects like crazy or split up the project into hundreds of small files which will result in a complete mess.
@m-trojanowski thanks for your proposal I hope it will be taken into consideration I can live with an additional option in the replacements block, but would rather propose a commandline option to omit the behaviour to error out on not found targets.
@KlausMandola as I have very similar issue in my projects right now I'm planning to migrate Kustomize to Jsonnet. It should be not very complicated as yaml can be easily transformed to json and the simplest use of Jsonnet is about to use just json files.
We are also badly affected by this change (see my other comment on the PR)
I have opened a formal feature request for allowing users to opt for the pre-5.0.0 behavior with a flag : https://github.com/kubernetes-sigs/kustomize/issues/5440
@renaudguerin please take a look also on this PR https://github.com/kubernetes-sigs/kustomize/pull/5280 which should also resolve this issue but for some reason nobody is willing to review it :(
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/remove-lifecycle stale
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/remove-lifecycle stale
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/remove-lifecycle stale
Hi, is there any update on this issue?
i am in kustomize version v5.4.3 and still hitting this issue
Error: unable to find field "spec.xx.xxx" in replacement target
What happened?
Hello, Up to kustomize version 4.5.7 I was able to use
ReplacementTransformer
to actually find kinds based on regexes insidefieldPaths
field like so:Here I'm searching for all StatefulSet and Deployment containers with name that starts with
myservice-*
and replace it's image tag with data from "myservice-config"ConfigMap
. To do so I'm splitting imagefieldPath
result using delimeter:
and picking tag part of string usingindex: 1
option. This is no longer possible since version 5.0.0 and I believe I found code that is responsible for this change: https://github.com/kubernetes-sigs/kustomize/blob/master/api/filters/replacement/replacement.go#L196This prevents any kind of searches using regexes.
What did you expect to happen?
I expected to actually render kubernetes manifests. Instead all I get is the following error:
How can we reproduce it (as minimally and precisely as possible)?
components/myservice-version/kustomization.yaml
:environments/dev/kustomization.yaml
:environments/dev/overlay/kustomization.yaml
:environments/dev/overlay/config.properties
:myserviceap/kustomization.yaml
:myserviceap/resources.yaml
:Expected output
kustomize version {Version:kustomize/v4.5.7 GitCommit:56d82a8378dfc8dc3b3b1085e5a6e67b82966bd7 BuildDate:2022-08-02T16:35:54Z GoOs:linux GoArch:amd64}
kustomize build --enable-helm environments/dev
Actual output
kustomize version v5.0.1
kustomize build --enable-helm environments/dev
Kustomize version
v5.0.1
Operating system
None