Skip to content

Best practice: don't override imagePullPolicy #8567

@bgehman

Description

@bgehman

It is a Kubernetes Best Practice to not override defaults, including imagePullPolicy. Using helm create ... to create a sample chart, the generated sample is explicitly setting the imagePullPolicy, making it appear as if it is a Best Practice to do such a thing.

I would like to note that imagePullPolicy has a dynamic default in Kubernetes -- the default is different depending on the docker image tag being used (tag omitted, or set to :latest the default is Always, otherwise it defaults to IfNotPresent).

The sample chart (from "helm create ...") should not explicitly override the imagePullPolicy, but it should allow someone to override the default Kubernetes behavior.

I would suggest the values.yaml to have something like this (see where I commented out the pullPolicy):

image:
  repository: nginx
  # pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: ""

and the deployment.yaml to have:

{{ if .Values.image.pullPolicy }}
          imagePullPolicy: {{ .Values.image.pullPolicy }}
{{ end }}

With these changes, the default/sample helm chart is more closely aligned with Kubernetes' inbuilt defaults and best practices:

Don't specify default values unnecessarily: simple, minimal configuration will make errors less likely.


Output of helm version: same behavior in helm2 and helm3

Output of kubectl version: na

Cloud Provider/Platform (AKS, GKE, Minikube etc.): na

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions