Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append release timestamp to helm template name

I'm struggling with finding a way to include the Release.Time builtin as part of a helm name.

If I just include it as: name: {{ template "myapp.name" . }}-{{ .Release.Time }}

Dry run shows this: name: myapp-seconds:1534946206 nanos:143228281

It seems like this is a *timestamp.Timestamp object or something because {{ .Release.Time | trimPrefix "seconds:" | trunc 10 }} outputs wrong type for value; expected string; got *timestamp.Timestamp

I can hack the string parsing by doing: {{ .Release.Time | toString | trimPrefix "seconds:" | trunc 10 }}, but it seems like I should be able to call something on the Timestamp object to get the seconds. Is anyone aware of where the docs are for this? I can't find any reference to it at https://godoc.org/github.com/Masterminds/sprig.

like image 439
Adverbly Avatar asked Aug 22 '18 14:08

Adverbly


People also ask

How do I change my Helm release name?

The first option was to modify the datastore (ie. ConfigMap in Helm v2 and Secrets in Helm v3) that stores the resource manifest by replacing the existing (incorrect) release name string with the desired (correct) value. Helm v3 stores the resource manifest in a zipped, double base64 encoded secret in the namespace.

What does {{- mean in Helm?

{{- (with the dash and space added) indicates that whitespace should be chomped left, while -}} means whitespace to the right should be consumed. Be careful!

What is trunc 63 in Helm?

trunc 63 truncates it to 63 characters in length.


1 Answers

In my case, by adding the following annotation I was able to achieve this, I am also using helmfile as the wrapper of my helm templates.

annotations:
   deploymentTime: {{ now | date "2006-01-02T15:04:05" }}
like image 198
Andres Zepeda Avatar answered Sep 21 '22 20:09

Andres Zepeda