K8s Pod Lifecycle Hooks

1/4/2019

I'd like to receive a notification whenever there are any changes to the kubernetes cluster. Pods are created/deleted, etc. This can be a in a form of a webhook, or a message in a pub/sub, etc anything that can be used in autonomous manner.

Running the kubernetes cluster in gcp.

-- rubenhak
hook
kubernetes

1 Answer

1/4/2019

You can get such events with creating hooks in linux compatible languages (such as go,python etc.) to relevant k8s object's watch endpoint. i.e./apis/apps/v1/watch/namespaces/{namespace}/deployments/{name} is the watch endpoint of Deployment object. You may find the watch endpoint of the object you desire from the API reference of k8s-api-server. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.13/

-- rfum
Source: StackOverflow