I want to list the limited number of k8s jobs objects using API. In the documentation, there is the limit
parameter which could be used to set limit for responses to return for Kubernetes objects list call. However, for some reason this isn't working for jobs and the server just returns all jobs instead of the specified number.
In the documentation it is said, that Servers may choose not to support the limit argument and will return all of the available results
.
How can I configure k8s to accept the limit argument on list calls ?
Start a proxy to your control plane api:
kubectl proxy
Run the request in a separate shell (set namespace
and limit value as needed):
curl -s http://localhost:8001/apis/batch/v1/namespaces/{{namespace}}/jobs?limit=3 \
| jq '.items | length'
Using jq so you can easily count the number of jobs returned.