I am using kubernetes api to deploy deployment in node. I got 200 status when i update the image of deployment. But the image name is wrong so deployment update stopped with errImagePull error. Is there any error callback mechanism in kubernetes or i have to debug it manually?
For the most part you have to debug it manually, and things run asynchronously; but you have a couple of things you can watch.
A Deployment's status
field has data about how many pods it controls are in what state. The easy thing to check is that all of the replica counts match up, though this isn't 100%. The slightly trickier thing to check is the deployment status; some status combinations are listed in that documentation.
The other thing you can do is get the pod selector of the deployment, and then list (or, better for this case, watch) the pods that match that. In your particular case, if any pods are in ErrImagePull
state, that's a clear sign something is wrong.
The one vagueness here, and the thing that leads to an unclear solution, is CrashLoopBackOff
state. Say you're starting an application container and a database container. The application container tries to connect to the database on startup, and if it fails, immediately exits. Also say the database takes 60-120 seconds to start up. Kubernetes will start both at the same time. Since the database isn't ready, the application will exit; after retrying this a couple of times, the pod goes into CrashLoopBackOff
and this is normal. After the database starts up, the application will start successfully too.
I don't think there's a good way to distinguish the different CrashLoopBackOff
states of "a dependency isn't ready yet", "a dependency will never be ready because of a misconfiguration", and "the code is just buggy". When I've done this before I've used heuristics like a timeout to say, if nothing has made any forward progress in 5 minutes and the deployment isn't 100% ready yet, then it must have failed. That's a little unsatisfying, though.