k8s-node-termination-handler icon indicating copy to clipboard operation
k8s-node-termination-handler copied to clipboard

What is the API that it uses to know that the node will be down after 30 seconds?

Open ankit-arora-369 opened this issue 4 years ago • 2 comments

What is the API that it uses to know that the node will be down after 30 seconds?

Can you please share the URL of the API so that we can also create a script own our own?

ankit-arora-369 avatar Sep 20 '19 13:09 ankit-arora-369

@ankit-arora-369 I think this provides what you're after (Official Docs). Note that I have found this to work both from within a GKE node as well as within pod on a node.

curl "http://metadata.google.internal/computeMetadata/v1/instance/preempted" -H "Metadata-Flavor: Google"

Or polling request that returns only when there's a change to the value:

curl "http://metadata.google.internal/computeMetadata/v1/instance/preempted?wait_for_change=true" -H "Metadata-Flavor: Google"

egalpin avatar Oct 15 '19 19:10 egalpin

This doesn't work because it turns TRUE only when G3 signal is returned.

ankit-arora-369 avatar Oct 23 '19 11:10 ankit-arora-369