mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-09 05:01:46 +00:00
Merge pull request #53768 from smarterclayton/chunking_cli
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Support api chunking in kubectl get This enables chunking in the resource builder to make it easy to retrieve resources in pages and visit partial result sets. This adds `--chunk-size` to `kubectl get` only so that users can get comfortable with the use of chunking in beta. Future changes will enable chunking for all CLI commands so that bulk actions can be performed more efficiently. ``` $ kubectl get pods --all-namespaces ... print batch of 500 pods ... ... print second batch of 500 pods ... ... ``` @kubernetes/sig-cli-pr-reviews @kubernetes/sig-api-machinery-pr-reviews ```release-note `kubectl get` will by default fetch large lists of resources in chunks of up to 500 items rather than requesting all resources up front from the server. This reduces the perceived latency of managing large clusters since the server returns the first set of results to the client much more quickly. A new flag `--chunk-size=SIZE` may be used to alter the number of items or disable this feature when `0` is passed. This is a beta feature. ```
This commit is contained in:
@@ -1374,7 +1374,7 @@ run_kubectl_get_tests() {
|
||||
fi
|
||||
|
||||
### Test kubectl get all
|
||||
output_message=$(kubectl --v=6 --namespace default get all 2>&1 "${kube_flags[@]}")
|
||||
output_message=$(kubectl --v=6 --namespace default get all --chunk-size=0 2>&1 "${kube_flags[@]}")
|
||||
# Post-condition: Check if we get 200 OK from all the url(s)
|
||||
kube::test::if_has_string "${output_message}" "/api/v1/namespaces/default/pods 200 OK"
|
||||
kube::test::if_has_string "${output_message}" "/api/v1/namespaces/default/replicationcontrollers 200 OK"
|
||||
@@ -1385,6 +1385,17 @@ run_kubectl_get_tests() {
|
||||
kube::test::if_has_string "${output_message}" "/apis/extensions/v1beta1/namespaces/default/deployments 200 OK"
|
||||
kube::test::if_has_string "${output_message}" "/apis/extensions/v1beta1/namespaces/default/replicasets 200 OK"
|
||||
|
||||
### Test kubectl get chunk size
|
||||
output_message=$(kubectl --v=6 get clusterrole --chunk-size=10 2>&1 "${kube_flags[@]}")
|
||||
# Post-condition: Check if we get a limit and continue
|
||||
kube::test::if_has_string "${output_message}" "/clusterroles?limit=10 200 OK"
|
||||
kube::test::if_has_string "${output_message}" "/v1/clusterroles?continue="
|
||||
|
||||
### Test kubectl get chunk size defaults to 500
|
||||
output_message=$(kubectl --v=6 get clusterrole 2>&1 "${kube_flags[@]}")
|
||||
# Post-condition: Check if we get a limit and continue
|
||||
kube::test::if_has_string "${output_message}" "/clusterroles?limit=500 200 OK"
|
||||
|
||||
### Test --allow-missing-template-keys
|
||||
# Pre-condition: no POD exists
|
||||
create_and_use_new_namespace
|
||||
|
Reference in New Issue
Block a user