ITADN

Component replacements x parent resource name alteration inconsistent

#6079Opennicolas-boussuge-fintech 创建于 2026-02-16
kind/bugneeds-triage
### What happened? Using replacements on the final kustomization.yaml will correctly replace given occurrences. Using replacements on the component that expects a resource without having it will only replace specific occurrences. ### What did you expect to happen? I would expect replacements to work even when used from the "abstract" components. ### How can we reproduce it (as minimally and precisely as possible)? ```yaml #base/httproute.yaml apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: route spec: rules: - backendRefs: - name: to-be-kustomized matches: - path: type: PathPrefix value: / ``` ```yaml #base/ingress.yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: ingress spec: rules: - http: paths: - backend: service: name: to-be-kustomized pathType: Prefix path: / ``` ```yaml #base/kustomization.yaml apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component resources: - httproute.yaml - ingress.yaml ``` ```yaml #test/service.yaml apiVersion: v1 kind: Service metadata: name: service ``` ```yaml #test/kustomization.yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namePrefix: prefix- resources: - service.yaml components: - ../base ``` Adding this code in each `kustomization.yaml` will produce different results ```yaml replacements: - source: kind: Service fieldPath: metadata.name targets: - select: kind: Ingress fieldPaths: - spec.rules.0.http.paths.0.backend.service.name - select: kind: Ingress fieldPaths: - spec.rules.0.http.paths.0.pathType - select: kind: HTTPRoute fieldPaths: - spec.rules.0.backendRefs.0.name - select: kind: HTTPRoute fieldPaths: - spec.rules.0.matches.0.path.type ``` ### Expected output ```yaml apiVersion: v1 kind: Service metadata: name: prefix-service --- apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: prefix-route spec: rules: - backendRefs: - name: prefix-service matches: - path: type: prefix-service value: / --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: prefix-ingress spec: rules: - http: paths: - backend: service: name: prefix-service path: / pathType: prefix-service ``` All 4 occurrences of the service are correctly prefixed. ### Actual output ```yaml apiVersion: v1 kind: Service metadata: name: prefix-service --- apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: prefix-route spec: rules: - backendRefs: - name: service matches: - path: type: service value: / --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: prefix-ingress spec: rules: - http: paths: - backend: service: name: prefix-service path: / pathType: service ``` When the replacements section is placed inside the component file, only 1 occurence of the service is correctly prefixed. ### Kustomize version 5.8.1 ### Operating system Linux
1 条评论