Entering this information will route you directly to the right team and expedite traction.
Question, Bug, or Feature?
Type: Feature
Enter Task Name: KubernetesManifest@0
Kustomize bake action should allow image replacement like the Helm bake action allows overrides.
I want to be able to use Kustomize's image substitution to update image tags without having to use a deploy action. Notation can be just like the deploy action, aka:
containers: |
nginx: 1.7.9
my-repo/image: some-new-tag
@strikeout We allow image substitution with Helm because it provides a --set flag that enables overriding values. However, there's no such flag with kustomize.
It would be a cleaner solution if the tool itself provided such an option. It makes sense to have artifact substitution in deploy action but I'm not sure if that feature should be ported here as well.
@azooinmyluggage @ds-ms What are your thoughts about this?
After discussing with @ds-ms and @azooinmyluggage, it looks like a better way of variable substitution for very specific use cases like these would be using a script in the pipeline, instead of adding the artifact substitution logic for every case.
@strikeout You can use a script to replace image name in your pipeline.
It would be a cleaner solution if the tool itself provided such an option. It makes sense to have artifact substitution in deploy action but I'm not sure if that feature should be ported here as well.
Kustomize does infact support the mentioned option via kustomize edit set image!
Quoting the manual (Kustomize v3.5.4):
Usage:
kustomize edit set image [flags]
Examples:
The command
set image postgres=eu.gcr.io/my-project/postgres:latest my-app=my-registry/my-app@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
will add
images:
- name: postgres
newName: eu.gcr.io/my-project/postgres
newTag: latest
- digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
name: my-app
newName: my-registry/my-app
to the kustomization file if it doesn't exist,
and overwrite the previous ones if the image name exists.
The command
set image node:8.15.0 mysql=mariadb alpine@sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
will add
images:
- name: node
newTag: 8.15.0
- name: mysql
newName: mariadb
- digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
name: alpine
to the kustomization file if it doesn't exist,
and overwrite the previous ones if the image name exists.
@strikeout kustomize edit set image is a way to edit the kustomization file. It's purpose is not to override values the way --set does in helm, but to update the kustomization file with given values. This could be used a workaround though.
@ds-ms What do you think? One more problem with this approach is that we are using kubectl kustomize in our task which does not support this command. We'll need to modify the code so that kustomize is downloaded first and then this command is executed.
@strikeout Had a discussion with the team on this. It seems better to use a common solution of image substitution for all the methods of bake action, instead of using tool specific ways. So, we'll port the image substitution logic for this use case.