Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retry image pull in a kubernetes Pods?

I am new to kubernetes. I have an issue in the pods. When I run the command

 kubectl get pods

Result:

NAME                   READY     STATUS             RESTARTS   AGE
mysql-apim-db-1viwg    1/1       Running            1          20h
mysql-govdb-qioee      1/1       Running            1          20h
mysql-userdb-l8q8c     1/1       Running            0          20h
wso2am-default-813fy   0/1       ImagePullBackOff   0          20h

Due to an issue of "wso2am-default-813fy" node, I need to restart it. Any suggestion?

like image 700
Dilshani Subasinghe Avatar asked Oct 26 '16 09:10

Dilshani Subasinghe


People also ask

How do I resolve ImagePullBackOff error in Kubernetes?

To resolve it, double check the pod specification and ensure that the repository and image are specified correctly. If this still doesn't work, there may be a network issue preventing access to the container registry. Look in the describe pod text file to obtain the hostname of the Kubernetes node.

Is waiting to start trying and failing to pull image Kubernetes?

What Does `Failed to Pull Image` Mean? You'll get a `Failed to pull image` error when Kubernetes tries to create a new pod but can't pull the container image it needs in order to do so. You'll usually see this straight after you try to apply a new resource to your cluster using a command like `kubectl apply`.


4 Answers

In case of not having the yaml file:

kubectl get pod PODNAME -n NAMESPACE -o yaml | kubectl replace --force -f -

like image 178
Maciek Sawicki Avatar answered Oct 23 '22 09:10

Maciek Sawicki


Usually in case of "ImagePullBackOff" it's retried after few seconds/minutes. In case you want to try again manually you can delete the old pod and recreate the pod. The one line command to delete and recreate the pod would be:

kubectl replace --force -f <yml_file_describing_pod>
like image 33
Ayon Nahiyan Avatar answered Oct 23 '22 08:10

Ayon Nahiyan


$ kubectl replace --force -f <resource-file>

if all goes well, you should see something like:

<resource-type> <resource-name> deleted
<resource-type> <resource-name> replaced

details of this can be found in the Kubernetes documentation, "manage-deployment" and kubectl-cheatsheet pages at the time of writing.

like image 41
eversMcc Avatar answered Oct 23 '22 08:10

eversMcc


If the Pod is part of a Deployment or Service, deleting it will restart the Pod and, potentially, place it onto another node:

$ kubectl delete po $POD_NAME

replace it if it's an individual Pod:

$ kubectl get po -n $namespace $POD_NAME -o yaml | kubectl replace -f -

like image 37
Carlos Nunez Avatar answered Oct 23 '22 07:10

Carlos Nunez