skip to Main Content

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

2

Answers


  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 🙂

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search