Dnlhoust
Dnlhoust

Reputation: 118

Watching K8s container resource usage

I am using client-go to read K8s container resource usage using the Get method of the core client-go client, but re-fetching the K8s object on an interval seems like the wrong approach. What is the better approach for periodically fetching status changes to a K8s container?

Upvotes: 0

Views: 149

Answers (1)

coderanger
coderanger

Reputation: 54221

You would use an Informer which runs an API watch that receives push updates from kube-apiserver. Though that said, you might find it easier to use one of the operator support frameworks like Kubebuilder, or at least directly use the underlying controller-runtime library as raw client-go can be a little gnarly to configure stable informers. Doable either way though.

Upvotes: 2

Related Questions