Kubernetes Dashboard Pagination Question


I’m fairly unfamiliar with Go/Angular so I haven’t been able to intuit my question from the Kubernetes/Dashboard source code.

How does the dashboard handle pagination of kubernetes resources? According to the K8 API, when you query for lists of resources (e.g., Pods) you get back a List object (e.g, PodList) and that list has a continue token for retrieving the next batch of results for the query. In the kubernetes dashboard, those lists of resources are presented as tables with fully featured pagination (you can go both forward and backwards over the pages). I’m trying to figure out how the dashboard takes the PodList results, which essentially allows only forward cursoring, and builds a multi-directional paged table? Does it load all of the results into memory in the back end? Is it reissuing the query or otherwise caching results when the user pages backwards? Is there some API to K8 that supports offsets/limits? Also, how does the dashboard know the total number of results for each query (necessary when it’s dividing up into pages)?

Thanks! If this is not the right place for this question, please let me know.


Heya @andrewshilliday

In the background, proxies and restructures requests between the UI and the K8s API server to give us things like pagination and totals. If you have a running version of the Dashboard, you can see an example of what it’s doing by visiting this URL: http://localhost:8080/api/v1/pod/kube-system?itemsPerPage=10&page=1&sortBy=d,creationTimestamp

If you force-refresh the page, it will query the API Server for a PodList again, but paginating through doesn’t cause another API request.

Hopefully that answers your question. I was a little fuzzy on the logic myself, so if you need more clarification or want some GitHub links, I’d be happy to provide them. :slight_smile:



Thanks for your response! This is very helpful. When you say that “paginating through doesn’t cause another API request”, do you mean that it doesn’t make a request to the api-server? Am I correct, then, that the dashboard’s backend will, when loading the page, hit the api-server and pull down the entire result set into memory but keep the results on the backend until they are requested by the front end (one page at a time)? Presumably that’s how it figures out the total results, etc., since the api-server doesn’t provide that directly, correct?

If I’m correct here, can you point me to the location in the dashboard code where the cache of the result list is kept?

Again, thanks!


Welp, I’m wrong.

When you prompted me for the caching code I went looking and couldn’t find it. But I then looked (more) at the code for when a PodList is pulled and it’s run for every pagination query. I spun up a cluster and threw 100 pods at it and paged around to confirm.

https://github.com/kubernetes/dashboard/blob/master/src/app/backend/resource/pod/list.go#L83 is called for every page load. I was getting tripped up because technically, the Metrics for each Pod do get cached (and I’ve been focused on that area lately)

Sorry for the confusion. :frowning: Let me know if I can dig up anything else for ya!


Thanks for the correction. It’s interesting to me that the dashboard makes the complete call every time, but I guess it makes sense. If something changed in the resources they would want the next page to reflect the change.

Thanks again.