Docker image not pulling the latest image from Docker Hub using tag "latest" using Helm Chart

7/2/2019

Currently I implemented a test CI/CD pipeline using Jenkins, Docker and Kubernetes. I am using Kubernetes Helm Chart for adding my Kubernetes resources and using Dockerhub as image repository. When I am checking the output of api that I deployed, it's not updated with modified change.

When I checked with the console output of Jenkins, it showing everything successfully. But the latest Docker image is not pulling by using the tag "latest". Still I am getting the older output.

In my Helm Chart values.yaml, I added like following:

imageCredentials:
  name: helmchartrepository
  registry: <my-registry-name>
  username: <my-username>
  password: <my-password>

image:
  repository: <my-repository>
  tag: latest
  pullPolicy: Always

And my deployment.yaml referring to these values like the following:

enter image description here

NB: Even if I am using the configuration for pulling latest image from repository by using "latest" , still I am not getting the modified image. And there is no error also. Only issue is pulling the latest docker image from Dockerhub image repository.

How can I resolve this error?

-- Jacob
docker
kubernetes

2 Answers

7/2/2019

Helm is not able to understand whether the image has been updated or not. Since you are using the fixed tag latest. You can add some labels like date or timestamp in the metadata to identify the change.

-- dassum
Source: StackOverflow

7/2/2019

Add date: "{{ .Release.Time.Seconds }}" in your deployment under template/metadata/labels and set imagePullPolicy: Always. Helm will detect the changes in the deployment object and will pull the latest image each time:

template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ .Values.app.frontendName }}
        app.kubernetes.io/instance: {{ .Release.Name }}
        date: "{{ .Release.Time.Seconds }}"

Run helm upgrade releaseName ./my-chart to upgrade your release

-- Rajesh Gupta
Source: StackOverflow