-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.Indicates an issue or PR lacks a `triage/foo` label and requires one.
Description
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)?
#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: /#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: /#base/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources:
- httproute.yaml
- ingress.yaml#test/service.yaml
apiVersion: v1
kind: Service
metadata:
name: service#test/kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: prefix-
resources:
- service.yaml
components:
- ../baseAdding this code in each kustomization.yaml will produce different results
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.typeExpected output
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-serviceAll 4 occurrences of the service are correctly prefixed.
Actual output
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: serviceWhen 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.Indicates an issue or PR lacks a `triage/foo` label and requires one.