Home > Back-end >  kubernetes k8 unable to pull latest image
kubernetes k8 unable to pull latest image

Time:01-20

Hi I am working in kubernetes. Below is my k8 for deployment.

apiVersion: apps/v1
kind: Deployment 
metadata: #Dictionary
  name: webapp
spec: # Dictionary
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      # maxUnavailable will set up how many pods we can add at a time
      maxUnavailable: 50%
      # maxSurge define how many pods can be unavailable during the rolling update
      maxSurge: 1
  selector:
    matchLabels:
      app: webapp
      instance: app
  template:  
    metadata: # Dictionary
      name: webapplication
      labels: # Dictionary
        app: webapp  # Key value paids
        instance: app
      annotations:
        vault.security.banzaicloud.io/vault-role: al-dev
    spec:
      serviceAccountName: default
      terminationGracePeriodSeconds: 30
      containers: # List
        - name: al-webapp-container
          image: ghcr.io/my-org/al.web:latest
          imagePullPolicy: Always
          ports: 
            - containerPort: 3000
          resources:
            requests:
              memory: "1Gi"
              cpu: "900m"     
            limits:
              memory: "1Gi"
              cpu: "1000m"
      imagePullSecrets:
        - name: githubpackagesecret    

whenever I deploy this into kubernetes, Its not picking the latest image from the github packages. What should I do in order to pull the latest image and update the current running pod with latest image? Can someone help me to fix this issue. Any help would be appreciated. Thank you

CodePudding user response:

Since you have imagePullPolicy: Always set it should always pull the image. Can you do kubectl describe to the pod while its starting so we can seed the logs ?

CodePudding user response:

There could be chances if you are doing deployment with the same latest tag deployment might not be getting the updated as same imageTag.

Pod restart is required so it will download the new image each time, if still it's the same there is an issue with building of the cache image.

What you can do as of now to try the

kubectl rollout restart deploy <deployment-name> -n <namespace>

this will restart the pods and it will fetch the new image for all PODs and check if latest code running.

  • Related