kubernetes: `kubectl get pod` is very slow, it takes about 15 seconds,is there any way to improve it?
Our kubernetes cluster have 1000 nodes and 7100 pods,I don’t think the cluster is large,but using kubectl is very slow,is there any way to improve it?
# etcdctl --version
etcdctl version: 3.3.1
API version: 2
What happened:
$ time kubectl get pod -o wide | wc -l
7100
real 0m14.045s
user 0m13.070s
sys 0m0.885s
$ kubectl get node | wc -l
1001
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version
): v1.8.1 - Cloud provider or hardware configuration:
- OS (e.g. from /etc/os-release): CentOS Linux release 7.2.1511 (Core)
- Kernel (e.g.
uname -a
): 3.10.0-514.16.1.el7.x86_64 - Install tools:
- Others:
/sig CLI
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 35 (9 by maintainers)
The issue should be reopened as I can’t find any solution too!
We sloved this problem,kubelctl cache the result from apiserver but it’s really slow because it fsync everytime ! So we link .kube/cache and http_cache dir to /dev/shm .After that everything works really good!
I am not sure why but this is something I am facing with k3s running on openSUSE Leap 15.2. Reinstalling didn’t work till now
@rogperez What worked for me was to clean up the host nodes and reinstalling kubernetes (but i was using rke). Here were the steps you must do for all your nodes:
Like i said i was using Rancher - RKE for my setup and this worked. So everytime I have installed k8s on a fresh VM (or bare-metal) I have always had this issue of kubectl being slow and fortunately the only solution was to clean up and reinstall on the same machines.
version 1.27
[#] time kubectl get pod -o wide | wc -l 3
real 0m0.044s user 0m0.042s sys 0m0.023s
[#] time kubectl get pod -n prod -o wide | wc -l 3073
real 0m3.452s user 0m3.615s sys 0m0.308s
Just to provide some details, it seems to me that is cause by the difference in the kubectl version and the k8s cluster. Observed the same issue with
v1.16.13-eks-2ba888
. It’s also notable that the slowdown is mostly visible when executingget all
andget pods
commands, but it’s missing when executeget nodes
.Here are the results from the experiments that I did:
Here is the same test using
get nodes