Being notified for changes in namespace of a pod

4/16/2020

I have an application running on gcp. I want to set up a mechanism to be notified if there's any change in the namespace. There is an option to use kubernetes Watch to monitor any changes in namespace. But I'm looking for something to create an event or get notification to java application for such a change in namespace. I searched but could not find anything relevant, are there any options to be notified on such namespace changes?

-- Nikita Kotak
google-cloud-platform
kubernetes

3 Answers

4/16/2020

I would use watches, depends on your specific use case, you can start here: https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes https://engineering.bitnami.com/articles/kubernetes-async-watches.html

Let me know if this doesn't solve your use case, I can suggest other solutions.

-- omricoco
Source: StackOverflow

4/16/2020

In order to do it, what I would do is deploying an application that checks if there are changes. To do it, you can use kubernetes api. You just need to install curl, instead of kubectl and the rest is restful.

curl http://localhost:8080/api/v1/namespaces/default/pods

Depending on your configuration you may need to use ssl or provide client certificate.

You should do a script with kubernetes api calls in order to check if there are changes.

-- pcampana
Source: StackOverflow

4/16/2020

If you are looking for forwarding to use third party app you can use plugin : botkube

If you want to create application in java you can check for respetvice client library of it in official document

https://kubernetes.io/docs/reference/using-api/client-libraries/

Java official client library for Kubernetes : https://github.com/kubernetes-client/java

This is some good example or it you can also use default Kubernetes API and write custom code and run that contained in same Kubernetes cluster to monitor any changes in namespace.

-- Harsh Manvar
Source: StackOverflow