kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

Annotation `kustomize.config.k8s.io/needs-hash` not working on static resources

Open LittleChimera opened this issue 3 years ago • 6 comments
trafficstars

Describe the bug

Setting annotation kustomize.config.k8s.io/needs-hash: "true" on static resources doesn't add hash suffix to the name. Setting the annotation internal.config.kubernetes.io/needsHashSuffix: "enabled" instead gets the expected result.

Files that can reproduce the issue

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- resources.yaml

resources.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: foo
  annotations:
    kustomize.config.k8s.io/needs-hash: "true"
data:
  foo: bar

Expected output

apiVersion: v1
data:
  foo: bar
kind: ConfigMap
metadata:
  name: foo-798k5k7g9f

Actual output

apiVersion: v1
data:
  foo: bar
kind: ConfigMap
metadata:
  annotations:
    kustomize.config.k8s.io/needs-hash: "true"
  name: foo

Kustomize version

4.5.7

LittleChimera avatar Oct 14 '22 12:10 LittleChimera

@LittleChimera: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Oct 14 '22 12:10 k8s-ci-robot

Reproduced. (note to self: this is documented at https://kubectl.docs.kubernetes.io/guides/extending_kustomize/#generator-options) /triage accepted

FWIW I noticed this summer that the use of this annotation with external transformers isn't well tested, and potentially also broken. I had a WIP branch started that might be a useful reference if someone wants to look into this.

KnVerey avatar Dec 07 '22 23:12 KnVerey

I figured out why hash suffixing stops working with merge/replace behaviour set by kustomize.config.k8s.io/behavior? So I'd like to make a PR about it.

/assign

yutaroyamanaka avatar Apr 08 '23 07:04 yutaroyamanaka

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

k8s-triage-robot avatar Apr 07 '24 08:04 k8s-triage-robot

Action Item: We would need to revisit and verify the functionality of both the annotations.

@yutaroyamanaka Thanks for figuring out the cause. Does this also occur in the latest (v5.0.0+) versions of kustomize? If so, could you elaborate on what the fix is. Thank you!

varshaprasad96 avatar Apr 10 '24 16:04 varshaprasad96

@varshaprasad96 I am able to reproduce it with v5.4.2

tcurdt avatar Jun 03 '24 23:06 tcurdt

/triage accepted /lifecycle frozen

stormqueen1990 avatar Jun 05 '24 03:06 stormqueen1990

@varshaprasad96 I am able to reproduce it with v5.4.2 too

tanguyantoine avatar Jul 08 '24 08:07 tanguyantoine