kubernetes keeps on pulling old image, even with imagePullPolicy set to Always

I have an image on docker hub that I using in a kubernetes deployment. I'm try to debug the application but whenever I make a change to the image, even with a change in the tag, when I deploy the app it still uses the old image? It does update occasionally but without any rhyme or reason. This is with the imagePullPolicy set to Always.

Here is the deployment file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: frontend
  template:
    metadata:
      labels:
        app: frontend
    spec:
      containers:
        - name: frontend
          image: myid/myapp:0.2.5
          imagePullPolicy: Always
          resources:
            requests:
              memory: "2Gi"
              cpu: 1
              ephemeral-storage: "2Gi"
            limits:
              memory: "2Gi"
              cpu: 1
              ephemeral-storage: "2Gi"
          ports:
            - containerPort: 3838
              name: shiny-port
            - containerPort: 8080
              name: web-port
      imagePullSecrets:
        - name: myregistrykey

I deploy it using the command

kubectl create -f deployment.yaml

Thanks


Solution 1:

This is a community wiki answer posted for better visibility. Feel free to expand it.

As mentioned in comments:

  • you need to check which tag is used - he same or different than in the previous version of the image;
  • update your Deployment with actual image;
  • check, if your image available in Docker hub, otherwise you will get ErrImagePull status during pod checking.

In case you just want to update an image, it is better to use kubectl apply -f deployment.yaml instead of kubectl create -f deployment.yaml.