You can do a watch on the pods to be notified when they start and stop. This tutorial <http://solinea.com/blog/tapping-kubernetes-events> appears to show you how to do it (I skimmed it and it looks about right).
As an alternative, the Kubernetes quota <http://kubernetes.io/docs/admin/resourcequota/> mechanism tells you how much resources are in use (requested) so I guess you could set up a dummy quota for the namespace and then read the ResourceQuota status periodically which will tell you the total request. But you'd still need to layer a watch on top of that if you want to be notified whenever it changes. On Sun, Nov 27, 2016 at 6:07 PM, <[email protected]> wrote: > Thanks, so I need to call API periodically (for example, call API every > five minutes)? but what if the containers are started/shutdown during the > period(let's say, five minutes? in such condition, the usage won't be > calculated. > > I am wondering if there is any container usage events which could record > the start of the container and end of the container? > > thanks a lot. > > On Saturday, November 26, 2016 at 10:55:31 AM UTC+8, David Oppenheimer > wrote: > > You can use the API to get a list of pods and then add up the > containers' resource requests that are in the corresponding PodSpecs. > > > > > > > > > > On Thu, Nov 24, 2016 at 9:25 PM, <[email protected]> wrote: > > > > > > Hi, there > > > > > > > > I am a newbie to kubernetes, Anyone knows how to caclulate the resource > usage (request usage) for a particular namespace in a period of time? Is > there any api I could use? any suggestions? thanks a lot. > > > > > > > > -- > > > > You received this message because you are subscribed to the Google > Groups "Kubernetes user discussion and Q&A" group. > > > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > > > > To post to this group, send email to [email protected]. > > > > Visit this group at https://groups.google.com/group/kubernetes-users. > > > > > > > > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "Kubernetes user discussion and Q&A" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/kubernetes-users. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/kubernetes-users. For more options, visit https://groups.google.com/d/optout.
