在 CentOS 上进行 Kubernetes 性能测试

一、目标与范围
二、环境与工具准备
三、快速验证流程(功能与基线)
kubectl get nodes 均为 Ready。kubectl get pods -n kube-system 运行正常。kubectl create deployment nginx --image=nginx --replicas=3kubectl expose deployment nginx --type=NodePort --port=80curl http://<任一节点IP>:<NodePort> 返回 Nginx 欢迎页。kubectl scale deployment nginx --replicas=5kubectl top nodes、kubectl top podskubectl describe pod <pod>,kubectl logs <pod>以上步骤可快速验证集群可用性与基本伸缩/自愈能力,为后续压测建立基线。四、控制面与调度性能测试(clusterloader2)
# 1) 编译git clone https://github.com/kubernetes/perf-testscd perf-tests/clusterloader2 && go build -o clusterloader ./cmd/# 2) 环境变量(示例)export KUBE_CONFIG=$HOME/.kube/configexport PROVIDER=localexport TEST_CONFIG=configs/examples/density/config.yamlexport REPORT_DIR=./reportsexport LOG_FILE=logs/run.log# 3) 执行./clusterloader --kubeconfig=$KUBE_CONFIG --provider=$PROVIDER --testconfig=$TEST_CONFIG --report-dir=$REPORT_DIR --alsologtostderr 2>&1 | tee $LOG_FILE五、大规模模拟与弹性场景(kubemark + HPA)
kubectl taint nodes <node> role=real:NoSchedulekubectl label nodes <node> role=realapiVersion: autoscaling/v2kind: HorizontalPodAutoscalermetadata:name: nginx-hpaspec:scaleTargetRef:apiVersion: apps/v1kind: Deploymentname: nginxminReplicas: 3maxReplicas: 10metrics:- type: Resourceresource:name: cputarget:type: UtilizationaverageUtilization: 50k6 run script.js 或 wrk -t12 -c400 -d60s http://<svc>/,观察 HPA 扩缩容、Pod 启动延迟与成功率。