Append release timestamp to helm template name

8/22/2018

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.

-- Adverbly
kubernetes
kubernetes-helm

1 Answer

8/23/2018

to format timestamp you can use date FORMAT TIME from sprig doc:

{{ date "20060102150405" .Release.Time }}

refer the format options here http://golang.org/src/pkg/time/format.go

But having timestamp in the name is not good idea because of upgrades.

-- abinet
Source: StackOverflow