0

I have minikube running on Ubuntu 22.04. When I update a docker image, push it to dockerhub, delete the previous deployment, and apply the deployment the result in the log is from code that is several hours old.

I see the service is gone after doing kubectl delete -f deploy.yml and exists after doing an apply, but the logs show output from old code.

When I do a docker run ... on the local docker image that was pushed to dockerhub the output shows the new code. I've verified that docker push ... has uploaded the new code.

Is this a bug in minikube? Here's my deployment script.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: metadata
spec:
  replicas: 2
  selector:
    matchLabels:
      app: metadata
  template:
    metadata:
      labels:
        app: metadata
    spec:
      containers:
      - name: metadata
        image: dwschulze/metadata:1.0.0
        imagePullPolicy: IfNotPresent
        ports:
          - containerPort: 8081
---
apiVersion: v1
kind: Service
metadata:
  name: metadata
spec:
  type: NodePort
  ports:
  - name: http
    port: 80
    targetPort: 8081
  selector:
    app: metadata
David Maze
  • 130,717
  • 29
  • 175
  • 215
Dean Schulze
  • 9,633
  • 24
  • 100
  • 165
  • If the cluster already has an image named `dwschulze/metadata:1.0.0` then it will use it without checking to see if you've pushed a new version of that same image somewhere. The easiest approach (especially using a layer like Helm or Kustomize where this is relatively easy to change) is to use a different tag on every build. Also see [Kubernetes how to make Deployment to update image](https://stackoverflow.com/questions/40366192/kubernetes-how-to-make-deployment-to-update-image). – David Maze May 31 '23 at 10:36
  • David - your comment is the correct answer. If you post it as an answer I'll accept it. – Dean Schulze Jun 03 '23 at 14:16

2 Answers2

1

in your deployment script have:

imagePullPolicy: IfNotPresent

you need to change to:

imagePullPolicy: Always

The "Always" value allows you to pull an image every time you deploy

I hope I helped :)

0

Below troubleshooting steps will help you to resolve your issue:

  1. Can you cross check that the deployment is using the dwschulze/metadata:1.0.0 image with the kubectl describe command.

  2. If you find another image, delete deployment using kubectl delete.Cross verify that deleted deployment is not created again, add imagePullPolicy: Never and redeploy. You can also refer to the suggestions given by member ‘svenwltr’ in the post.

  3. If your issue is still persisting, try another method to push images like cache. Before using this method check if you have any previously cached images and try to remove them.

  4. Check the logs of the deployment to see if there are any errors or issues preventing the updated Docker image from being loaded.

Sai Chandra Gadde
  • 2,242
  • 1
  • 3
  • 15