title: kustomize how to target replacement in every array
body: <p>As per the examples <a href="https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/replacements/" rel="nofollow noreferrer">https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/replacements/</a></p>
  <p>one can target specific array items like such <code>spec.template.spec.containers.[name=hello].env.[name=SECRET_TOKEN].value</code></p>
  <p>But how do we target every array item ?</p>
  <p>Tried <code>-</code> as below but it is replacing only the last occurrence.</p>
  <pre><code>fieldPaths:
       - spec.http.-.route.0.destination.host
  </code></pre>
  <p>Here is my kustomization.yaml</p>
  <pre><code>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
  
  </code></pre>
  <p>Here is my target yaml service-entries.yaml - I am expect that the HOST gets replaced in both places.</p>
  <pre><code>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
  
  </code></pre>
  <p>But as you can see below the results has only the last value:-</p>
  <pre><code>kustomize build .
  </code></pre>
  <p>produces this. As you can see example.com appears correctly in the last entry only - PLACEHOLDE1 is unaffected:-</p>
  <pre><code>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
  
  </code></pre>
  <p>So question is how do we replace <em>every</em> array element ? What is the syntax for fieldPath.</p>
  <p>kustomize version is 4.2.0</p>