<p>I am writing a custom Kubernetes controller and resource to keep track of the number of times a service object is called. The idea behind this is to add a "hitcount" field to the resource and update it every time a service is invoked. (Meaning update the count every time a request is made to the pod that is part of the service)</p>

<p>Is this possible? Does the kubernetes API have an option to do this?</p>

<p>it sounds like you're in fact trying to implement a metric inside kubernetes api. It's hardly a controller though. In a nutshell, controller is piece of software that continuously realizes an intent stated in kubernetes API in a real world. </p>

<p>Semantics aside, status object in kubernetes API is defined in it's type. For Pod, at the moment of writing of this answer it's <a href="https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/api/core/v1/types.go#L2978" rel="nofollow noreferrer">here</a> and it's not an extensible one. So you can't really put your metric into the Pod object.</p>

<p>The question that this naturally poses is why not use something that is expected for metrics collection and visualization like prometheus/grafana ?</p>

<p>All of that aside, you also have an issue of how will you expose/collect that metric. Istio could help here, or the software in pod it self could expose it's metrics (which, if possible, is the best route to take imo)</p>
