Helm template arithmetic division

3/7/2019

Anyone tried to make an arithmetic division in Helm?

According to sprig/Math Functions, the following should work:

{{ .Values.myvalue | div 2 }}

However, the result is wrong. e.g. 6/2 = 0, 4/2 = 0, 1/2 = 2.

Any hint ?

-- azalon
kubernetes
kubernetes-helm

1 Answer

3/7/2019

You use the function the wrong way: See function declaration.

Your template should be:

{{ div .Values.myvalue 2 }}
-- ozlevka
Source: StackOverflow