How to force a redeploy with HELM
Asked Answered
S

2

5

I would like to use HELM to force a deployment to redeploy on Openshift.

I am using "image@latest" for the deployment as I want to have the latest image whenever I deploy, but I don't want to have a image change trigger because I don't have control on how often the image changes and I may need to change some things in the chart (config-maps, for instance) prior to deploying for a new version of the image. Hence why I don't want for to have an image trigger for the deployment.

Basically, I want it to redeploy when I want it to and not automatically, and I would prefer to do it with helm, and I tried with helm upgrade.

Currently I have a Config Change Trigger so in the case I change the chart (which contains the configs), the deployment redeploys. But if nothing changes in the chart, I am not finding any way to force a redeploy through Helm.

Is there any way it is possible to do?

Semi answered 22/12, 2020 at 17:26 Comment(0)
S
14

I managed to find a solution. I added on spec-template-metadata-annotations the following:

timestamp: {{ now | quote }}

This basically makes the chart always change which will trigger a redeploy every time I run helm upgrade.

Semi answered 22/12, 2020 at 18:14 Comment(4)
This will work.. but it's better to work with relevant tags instead of latest. Do you have any CI\CD for the tagging?Not
No, we want to have the latest image at all times.Semi
how is this timestamp releated to latest tag???Barbabra
it isn't, we just want to redeploy with whatever image is with the latest tag, but for helm to do that it needs to detect a change in the chart, and that is why we need to have the timestamp there, to force something to change...as the value of "now" is always different.Semi
A
4

You can use this annotation in your Deploy manifest to force deploy on ConfigMap changes.

kind: Deployment
spec:
  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
...

Here is the source

Avner answered 6/9, 2022 at 4:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.