how to run an action on a kubernetes node (not inside container) whenever a pod is scheduled or unscheduled on it?

5/22/2019

I need to run a script on a node shell level (not inside the container) whenever a pod is scheduled or unscheduled on it. I've searched documentation, but found only ways to add hooks running inside containers (https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/, https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes). Does kubernetes have an API I could use to achieve this somehow? Thanks!

-- morgwai
kubernetes

1 Answer

5/22/2019

This is what you should do

  1. use event exporter to capture those events
  2. Deploy a webhook service
  3. invoke the webhook when shedule or unshedule event happens
  4. via webhook you should be able to trigger a script
-- P Ekambaram
Source: StackOverflow