kubernetes-sigs / kustomize

Customization of kubernetes YAML configurations
Apache License 2.0
11k stars 2.25k forks source link

kustomize-3.8.5: an overlay patch can interfere with images: transformer in base #3091

Closed icy closed 4 years ago

icy commented 4 years ago

Description

In kustomize-3.8.5 an overlay patch can interfere with images: transformer in base and generate completely wrong output.

In our test (https://github.com/icy/kustomize-misc/tree/master/002), base/kustomization.yaml specifies a transformer

images:
- name: bflux
  newName: devops
  newTag: bflux-v1.8.128

and in overlay/kustomization.yaml there is to modify the same deployment

resources:
- ../base/
patches:
- patches.yaml

Expected output

Image transformer result from base is reflected in the overlay. kustomize-3.8.2 works as expected. The env: section in the base manifest is kept, and the following diff command generates no-diff:

$ colordiff <(kust382 build overlay/) <(kust385 build overlay/)

Actual output

The output generated by kustomize-3.8.5 doesn't include any result from images: transformer. The env: section in base manifest is gone:

$ colordiff <(kust382 build overlay/) <(kust385 build overlay/)
22,23d21
<         - name: FOO
<           value: BAR
26,27d23
<         image: devops:bflux-v1.8.128
<         imagePullPolicy: Always

References

icy commented 4 years ago

Actually it isn't a problem of the images: transformer. When I remove the transformer from base/ I can see the same diff

$ colordiff <(kust382 build overlay/) <(kust385 build overlay/)
22,23d21
<         - name: FOO
<           value: BAR
26,27d23
<         image: bflux
<         imagePullPolicy: Always

I suspect that the behavior of patches has changed quite a lot, and that doesn't merge: it replaces things from base/

Shell32-Natsu commented 4 years ago

The difference is introduced in 3.8.3. We updated the API definition for k8s resources in 3.8.3 (#2978) and then the Deployment in extensions/v1beta1 api version is not found in the new schema. So that it works in this way.

/close

k8s-ci-robot commented 4 years ago

@Shell32-Natsu: Closing this issue.

In response to [this](https://github.com/kubernetes-sigs/kustomize/issues/3091#issuecomment-708598855): >The difference is introduced in 3.8.3. We updated the API definition for k8s resources in 3.8.3 (#2978) and then the `Deployment` in `extensions/v1beta1` api version is not found in the new schema. So that it works in this [way](https://github.com/kubernetes-sigs/kustomize/issues/3047#issuecomment-701014534). > >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
Shell32-Natsu commented 4 years ago

Change to apps/v1 will make it work.

icy commented 4 years ago

Change to apps/v1 will make it work.

Thanks a lot, @Shell32-Natsu .

Our k8s upgrade process is quite slow. I expected to use new version that addresses this issue https://github.com/kubernetes-sigs/kustomize/issues/2995, but I think now I have to a few more issues :dango: