kustomize
kustomize copied to clipboard
Replacements change all keys matches
What happened?
Difference behavior between v4.x and v5.x of Kustomize.
In V4.x, replacements
can choose the key preciously.
in V5.x, replacements
changes all keys which has similar key.
Check the following code
- v4.x changes only the
kind=clair
and notkind=clairX
- v5.x, changes
kind=clair
andkind=clairX
source:
kind: ConfigMap
name: environment-variables
fieldPath: data.HTTP_PROXY
targets:
- select:
kind: QuayRegistry
name: quay
fieldPaths:
- spec.components.[kind=clair].overrides.env.[name=HTTP_PROXY].value
- spec.components.[kind=clair].overrides.env.[name=HTTPS_PROXY].value
- spec.components.[kind=mirror].overrides.env.[name=HTTP_PROXY].value
- spec.components.[kind=mirror].overrides.env.[name=HTTPS_PROXY].value
options:
create: true
To fix that, I just need to change create
to false
instead of true
and add the keys in the target yaml without values and kustomize
will take care to inject the value
Am I doing something wrong?
What did you expect to happen?
I expect kustomize
changes only the mentioned key unless I use *
.
How can we reproduce it (as minimally and precisely as possible)?
kind: Kustomization
namespace: quay-dev
generatorOptions:
disableNameSuffixHash: true
resources:
- ../../../base
- kms-connect-quay.yaml
- vault-quay-external-secret.yaml
- quay-dev-route.yaml
configMapGenerator:
- behavior: create
name: environment-variables
envs:
- environment-variables.env
secretGenerator:
- name: kms-secret-id
files:
- secretID
- ca.crt
replacements:
- path: proxy-replacement.yaml
source:
kind: ConfigMap
name: environment-variables
fieldPath: data.HTTP_PROXY
targets:
- select:
kind: QuayRegistry
name: quay
fieldPaths:
- spec.components.[kind=clair].overrides.env.[name=HTTP_PROXY].value
- spec.components.[kind=clair].overrides.env.[name=HTTPS_PROXY].value
- spec.components.[kind=mirror].overrides.env.[name=HTTP_PROXY].value
- spec.components.[kind=mirror].overrides.env.[name=HTTPS_PROXY].value
options:
create: true
Expected output
apiVersion: [quay.redhat.com/v1](http://quay.redhat.com/v1)
kind: QuayRegistry
metadata:
name: quay
namespace: quay-dev
spec:
components:
- kind: clair
managed: true
overrides:
env:
- name: HTTP_PROXY
value: http://proxy.cloud.internal:8080/
- name: HTTPS_PROXY
value: http://proxy.cloud.internal:8080/
- name: DEBUGLOG
value: "true"
- kind: postgres
managed: true
- kind: quay
managed: true
- kind: objectstorage
managed: false
- kind: redis
managed: true
- kind: horizontalpodautoscaler
managed: true
- kind: route
managed: false
- kind: mirror
managed: true
overrides:
env:
- name: HTTP_PROXY
value: http://proxy.cloud.internal:8080/
- name: HTTPS_PROXY
value: http://proxy.cloud.internal:8080/
- kind: clairpostgres ##-> this is expected to not change
managed: true
configBundleSecret: quay-config-bundle
Actual output
apiVersion: [quay.redhat.com/v1](http://quay.redhat.com/v1)
kind: QuayRegistry
metadata:
name: quay
namespace: quay-dev
spec:
components:
- kind: clair
managed: true
overrides:
env:
- name: HTTP_PROXY
value: http://proxy.cloud.internal:8080/
- name: HTTPS_PROXY
value: http://proxy.cloud.internal:8080/
- name: DEBUGLOG
value: "true"
- kind: postgres
managed: true
- kind: quay
managed: true
- kind: objectstorage
managed: false
- kind: redis
managed: true
- kind: horizontalpodautoscaler
managed: true
- kind: route
managed: false
- kind: mirror
managed: true
overrides:
env:
- name: HTTP_PROXY
value: http://proxy.cloud.internal:8080/
- name: HTTPS_PROXY
value: http://proxy.cloud.internal:8080/
- kind: clairpostgres ##-> this has been changed
managed: true
overrides:
env:
- name: HTTP_PROXY
value: http://proxy.cloud.internal:8080/
- name: HTTPS_PROXY
value: http://proxy.cloud.internal:8080/
configBundleSecret: quay-config-bundle
Kustomize version
5.0.4
Operating system
Linux