companyinfo / helm-charts

Company.info Helm charts repository
https://companyinfo.github.io/helm-charts
Apache License 2.0
68 stars 22 forks source link

image.pullPolicy defaults to Always #27

Closed zevisert closed 11 months ago

zevisert commented 11 months ago

The imagePullPolicy defaults to Always, despite the comment in values.yaml: https://github.com/companyinfo/helm-charts/blob/6bda028afdc3c4c15b225084e7104b17714e77d9/charts/helmet/values.yaml#L76-L80

Additionally, the values.yaml field for image.pullPolicy is not subject to further rendering by common.tplvalues.render, so the default value (or the end user) cannot do anything like {{ eq .Values.image.tag "latest" | ternary "Always" "IfNotPresent" }} in their values.yaml.

Another option would be to replace the template at https://github.com/companyinfo/helm-charts/blob/6bda028afdc3c4c15b225084e7104b17714e77d9/charts/helmet/templates/_deployment.yaml#L58

with

  imagePullPolicy: {{ default (eq .Values.image.tag "latest" | ternary "Always" "IfNotPresent") .Values.image.pullPolicy }}
atkrad commented 11 months ago

Hi @zevisert, Thanks for your contribution.

Based on your changes, the .Values.image.pullPolicy won't be reached at all. If the image tag is set to "latest", the imagePullPolicy will be set to Always. If it's not set to latest, then the imagePullPolicy will be set to IfNotPresent. The question is, how can I set the imagePullPolicy to Always only when the image tag is not latest?

Regardless, we prefer not to change this part because Kubernetes handles the image pulling behavior in a specific way. Please review this section of the Kubernetes documentation: Default image pull policy

zevisert commented 11 months ago

Perhaps you didn't scroll to the right far enough in my suggestion? I'm suggesting to change helmet's exported default value to '' or null, then when rendering, if there is a value for .Values.image.pullPolicy, then use that. Otherwise, use whichever policy makes sense for the given tag. If you want to force a given policy, this suggestion will still let you do that.

This does need changing if you prefer to leverage Kubernetes' handling of the image pulling behavior since that behaviour only applies if "if you omit the imagePullPolicy field", and helmet provides no way for the user to omit this field.