github.com/koderover/helm@v2.17.0+incompatible/docs/chart_best_practices/pods.md (about)

     1  # Pods and PodTemplates
     2  
     3  This part of the Best Practices Guide discusses formatting the Pod and PodTemplate
     4  portions in chart manifests.
     5  
     6  The following (non-exhaustive) list of resources use PodTemplates:
     7  
     8  - Deployment
     9  - ReplicationController
    10  - ReplicaSet
    11  - DaemonSet
    12  - StatefulSet
    13  
    14  ## Images
    15  
    16  A container image should use a fixed tag or the SHA of the image. It should not use the tags `latest`, `head`, `canary`, or other tags that are designed to be "floating".
    17  
    18  
    19  Images _may_ be defined in the `values.yaml` file to make it easy to swap out images.
    20  
    21  ```
    22  image: {{ .Values.redisImage | quote }}
    23  ```
    24  
    25  An image and a tag _may_ be defined in `values.yaml` as two separate fields:
    26  
    27  ```
    28  image: "{{ .Values.redisImage }}:{{ .Values.redisTag }}"
    29  ```
    30  
    31  ## ImagePullPolicy
    32  
    33  `helm create` sets the `imagePullPolicy` to `IfNotPresent` by default by doing the following in your `deployment.yaml`:
    34  
    35  ```yaml
    36  imagePullPolicy: {{ .Values.image.pullPolicy }}
    37  ```
    38  
    39  And `values.yaml`:
    40  
    41  ```yaml
    42  pullPolicy: IfNotPresent
    43  ```
    44  
    45  Similarly, Kubernetes defaults the `imagePullPolicy` to `IfNotPresent` if it is not defined at all. If you want a value other than `IfNotPresent`, simply update the value in `values.yaml` to your desired value.
    46  
    47  
    48  ## PodTemplates Should Declare Selectors
    49  
    50  All PodTemplate sections should specify a selector. For example:
    51  
    52  ```yaml
    53  selector:
    54    matchLabels:
    55        app.kubernetes.io/name: MyName
    56  template:
    57    metadata:
    58      labels:
    59        app.kubernetes.io/name: MyName
    60  ```
    61  
    62  This is a good practice because it makes the relationship between the set and
    63  the pod.
    64  
    65  But this is even more important for sets like Deployment.
    66  Without this, the _entire_ set of labels is used to select matching pods, and
    67  this will break if you use labels that change, like version or release date.
    68  
    69