Image PullBackOff Error in pod recreation

We use GitLab CI/CD to build and deploy applications on a Kubernetes Cluster. The gitlab-ci.yaml is an adaptation of GitLab Auto-DevOps. Specially in the deploy stage, we made very few modifications.
We reallized that if the depolyed pod migrates to another host (not that one where it was first deployed), or if that pod is killed, the Image PullBackOff error appers every time when Kubernetes needs to recreate the pod.
To verify if the error occurs every time the pod is killed, we modified the gitlab-ci.yaml, changing the image’s pullPolicy attribute to ‘Always’ in .gitlab/auto-deploy-values.yaml file.

Every time (after the initial deploy) that Kubernetes needs to recreate the pod, the following message is showed:

ImagePullBackOff (Back-off pulling image “gitlab.mycompany.com:5151/group/project/branch-app:6e6f8f126e9ebf4f02ca5c20482c7fff1e25ea61”)

and,

ErrImagePull (rpc error: code = Unknown desc = failed to pull and unpack image “gitlab.mycompany.com:5151/group/project/branch-app:6e6f8f126e9ebf4f02ca5c20482c7fff1e25ea61”: failed to resolve reference “gitlab.mycompany.com:5151/group/project/branch-app:6e6f8f126e9ebf4f02ca5c20482c7fff1e25ea61”: failed to authorize: failed to fetch oauth token: unexpected status: 401 Unauthorized)

If we redeploy de application (redeploy de deployment in kubernetes) the image is download and everything works.

Can someone help me?

1 Like