kustomize-controller
kustomize-controller copied to clipboard
Discrepancy when handling "images" field
There is a discrepancy with standalone Kustomize when "images" transformer is used.
For example, assume I have a Deployment with image: docker.io/stefanprodan/podinfo:6.0.0
in base manifest, and the following kustomization.yaml:
resources:
- deployment.yaml
images:
- name: docker.io/stefanprodan/podinfo
newName: ghcr.io/stefanprodan/podinfo
- name: docker.io/stefanprodan/podinfo
newName: quay.io/stefanprodan/podinfo
If I build this locally, I will get ghcr.io/stefanprodan/podinfo:6.0.0
image in the final manifest. Second list element will be ignored because it won't be able to find target image, since it was already changed in first element. Both standalone kustomize v5 executable and kustomize built into kubectl behave that way, and kustomize-controller will also apply it like that as long as "images" are specified inside kustomization.yaml.
The problem is that, if we remove "images" from kustomization.yaml, and instead specify it inside Kustomization resouce manifest, the behaiour changes.
Assume kustomization.yaml doesn't have "images" anymore, and my Kustomization resource contains the following:
spec:
images:
- name: docker.io/stefanprodan/podinfo
newName: ghcr.io/stefanprodan/podinfo
- name: docker.io/stefanprodan/podinfo
newName: quay.io/stefanprodan/podinfo
Only the last list element will be applied, and I will get quay.io/stefanprodan/podinfo:6.0.0
image. AFAIK this is the only field that behaves differently when specified as part of Kustomization.
Tested with kustomize-controller v1.0.1 (flux 2.1.1).