As per the examples https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/replacements/
one can target specific array items like such spec.template.spec.containers.[name=hello].env.[name=SECRET_TOKEN].value
But how do we target every array item ?
Tried -
as below but it is replacing only the last occurrence.
fieldPaths:
- spec.http.-.route.0.destination.host
Here is my kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: ef
images:
- name: gateway-image
resources:
- configmap.yaml
- virtual-services.yaml
replacements:
- source:
kind: ConfigMap
fieldPath: data.HOST
targets:
- select:
kind: VirtualService
fieldPaths:
- spec.http.-.route.0.destination.host
options:
create: true
Here is my target yaml service-entries.yaml - I am expect that the HOST gets replaced in both places.
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: v-rules-1
spec:
hosts:
- EXTERNAL-HOST
gateways:
- istio-system/default-gateway
- mesh
http: # note these are ordered - first rule matching wins
- match:
- uri:
prefix: /foo
route:
- destination:
host: PLACEHOLDER1
- match:
- uri:
prefix: /bar
route:
- destination:
host: PLACEHOLDER2
But as you can see below the results has only the last value:-
kustomize build .
produces this. As you can see example.com appears correctly in the last entry only - PLACEHOLDE1 is unaffected:-
apiVersion: v1
data:
HOST: example.com
kind: ConfigMap
metadata:
name: gateway-configmap
namespace: ef
---
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: v-rules-1
namespace: ef
spec:
gateways:
- istio-system/default-gateway
- mesh
hosts:
- EXTERNAL-HOST
http:
- match:
- uri:
prefix: /foo
route:
- destination:
host: PLACEHOLDER1
- match:
- uri:
prefix: /bar
route:
- destination:
host: example.com
So question is how do we replace every array element ? What is the syntax for fieldPath.
kustomize version is 4.2.0