3

I'd like to add a transformer to my kustomize setup, one that includes a dynamic value for the case where the local tag needs to override the production tag. If there's a simpler and better way to do this that would be great. I've looked through the list of transformers and generators to see if there was a way to provide this value at runtime (though I think specifically kustomize is designed to never use runtime values).

I can specify something like this:

images:
  - name: my-image
    newTag: my-sha1

The problem is to change the my-sha1 value after each new local build to then pick that image when I go to apply the local deployment.

How can I set newTag after I run a build locally to match a tag for the image I made locally? I can easily obtain the latest build tag and provide with to kubectl apply -f, but I'm not seeing a flag or environment variable, or something to do so.

lucidquiet
  • 6,124
  • 7
  • 51
  • 88
  • Well just found this and maybe it's the "best" way to do it: https://github.com/kubernetes/kubectl/blob/master/docs/book/pages/app_management/container_images.md#setting-a-tag-from-the-latest-commit-sha – lucidquiet Apr 07 '21 at 21:14
  • 1
    Well hell, running `kustomize edit` winds up removing my comments in the yaml file...ugh. – lucidquiet Apr 07 '21 at 21:27
  • Hello, I'd reckon the way you've described should be okay (apart from removing comment). Also, have you seen this docs by any chance: https://github.com/kubernetes-sigs/kustomize/tree/master/examples/transformerconfigs/images ? – Dawid Kruk Apr 08 '21 at 15:33
  • Does the above github reference answer the question? – Alex G Oct 07 '21 at 15:05

0 Answers0