Home > Software engineering >  Memory effective way to monitor change of Kubernetes objects in a namespace
Memory effective way to monitor change of Kubernetes objects in a namespace

Time:11-27

I am working with kubernetes and kubectl commands, and am able to get a list of namespaces, and then can get the resources inside those namespaces. Question is, is there an effective way to monitor all resources (CRDs especially) in a certain namespace for changes? I know I could do this:

kubectl get myobjecttype -n <user-account-1>

and then check timestamps with a separate command, but that seems resource-taxing.

CodePudding user response:

You might be looking for the Kubernetes Watch API.

In fact, you make a List request (see API reference for e.g. Pods) and add the watch=1 query parameter to get a continuous stream of changes to the specified resources.

kubectl also supports watches with the -w/--watch flag:

kubectl get myobjecttype -n <user-account-1> -w
  • Related