一、性能测试简介
1、性能指标
说到K8S的性能指标,我们直观想到的有:K8S集群最多支持多少个节点、Pod,最多能创建多少个Namespace、Service等对象。
在K8S网站上,有如下一段描述:
Kubernetes v1.23支持高达5000节点。更准备地说,在使用Kubernetes时,应当遵循以下所有准则:每个节点不要超过110个Pod,集群不要超过5000节点,集群不要超过150000个Pod,不要超过300000个Container。
基本上可以理解为K8S的节点规模这个性能指标为5000。
但是如果判断K8S支持5000个节点?是在集群中能注册成功5000个节点就算支持?还是什么条件?
针对判断条件,K8S社区给出了一系列的SLI/SLO。即在一个集群下,当这些SLI的SLO满足时,那么我们就说K8S支持某个性能指标。
[github.com/kubernetes/community/blob/master/sig-scalability/slos/slos.md]
根据上述Kubernetes社区的介绍,目前正式(Official)的SLI有如下三个:
前两个都是API调用延时,第三个是Pod启动延时。上面的SLI是Service Level Indicator的缩写,翻译过来是“服务等级指标”(有些也译为“服务水平指标”),即对该指标的描述;SLO是Service Level Objective,翻译过来是“服务等级目标”(有些也译为“服务水平目标”),即该SLI怎么样才算达到。
我们可以简单理解为:节点规模、容器规模、Service规模就是K8S的性能指标,而上面的SLO就是这些性能指标是否满足的“判断条件”。
2、测试方法
上面我们有了“性能指标”,以及这些性能指标的“判断条件”。那么怎么测试?
Kubernetes开源了Clusterloader2性能测试框架,帮助我们完成上面的测试过程,并且统计测试结果。
Clusterloader2主要提供了两个测试用例:
(1)密度测试:该测试用例主要用来测试节点规模和容器规模的性能指标。它的大致思路是:在一个有N个节点的集群中,连续创建30*N个Pod,然后再删除这些Pod,然后跟踪这个过程中,上面的三个SLO是否满足。
(2)负载测试:该测试用例的主要思路是,向K8S进行大量的各种类型的资源创建、删除、LIST以及其他操作,然后跟踪这个过程中,上面的三个SLO是否满足。
3、Kubemark集群
另外,由于在大多数场景中,无法真实创建5000个节点,Kubernetes开源了一个kubemark项目,用来模拟真实节点。
二、制作kubemark镜像
1、构建kubemark二进制
[root@k8s8 kubernetes-1.23.3]# ./hack/build-go.sh cmd/kubemark/
NOTE: ./hack/build-go.sh has been replaced by 'make' or 'make all'
The equivalent of this invocation is:
make WHAT='cmd/kubemark/'
Detected go version: go version go1.16.15 linux/amd64.
Kubernetes requires go1.17.0 or greater.
Please install go1.17.0 or later.
!!! [0519 17:58:40] Call tree:
!!! [0519 17:58:40] 1: hack/run-in-gopath.sh:31 kube::golang::setup_env(...)
Detected go version: go version go1.16.15 linux/amd64.
Kubernetes requires go1.17.0 or greater.
Please install go1.17.0 or later.
!!! [0519 17:58:40] Call tree:
!!! [0519 17:58:40] 1: /root/kubernetes-1.23.3/hack/lib/golang.sh:794 kube::golang::setup_env(...)
!!! [0519 17:58:40] 2: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [0519 17:58:40] Call tree:
!!! [0519 17:58:40] 1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make[1]: *** [_output/bin/prerelease-lifecycle-gen] Error 1
make: *** [generated_files] Error 2
2、构建kubemark镜像
根据 kubemark的指引,把上面构建好的kubemark二进制文件拷贝到 kubernetes-1.23.3/cluster/images/kubemark/目录下,并在上面的目录中,执行make build命令
[root@k8s8 kubemark]# pwd
/root/kubernetes-1.23.3/cluster/images/kubemark
[root@k8s8 kubemark]# make build
docker build --pull -t staging-k8s.gcr.io/kubemark:latest .
Sending build context to Docker daemon 121.6MB
Step 1/2 : FROM k8s.gcr.io/build-image/go-runner:v2.3.1-go1.17.2-bullseye.0
v2.3.1-go1.17.2-bullseye.0: Pulling from build-image/go-runner
ec52731e9273: Pull complete
a5732a474047: Pull complete
Digest: sha256:7b035982301e211bf9cad67f3d1ccf97d7778f88cc18c8ac286e619bb970d5ba
Status: Downloaded newer image for k8s.gcr.io/build-image/go-runner:v2.3.1-go1.17.2-bullseye.0
---> dc2689354f85
Step 2/2 : COPY kubemark /kubemark
---> 58ad9aa08afa
Successfully built 58ad9aa08afa
Successfully tagged staging-k8s.gcr.io/kubemark:latest
kubemark镜像的构建非常简单,就是把kubemark二进制拷贝到基础镜像中,然后得到staging-k8s.gcr.io/kubemark:latest镜像。可以参考该目录下的Dockerfile文件。
我们把这个镜像重命名一下:
$ docker tag staging-k8s.gcr.io/kubemark:latest kubemark:v1.23.3
三、使用clusterloader2进行性能测试
步骤一、编译clusterloader2二进制文件
1、编译cluterloader2
clone源码,由于我们测试的K8S版本为1.23,所以clone该版本的代码
$ git clone -b release-1.23 github.com/kubernetes/perf-tests.git
然后对源码做一些修改,具体修改参考 附录一:Clusterloader2源码修改)。
然后,编译二进制,这里我们编译 amd64 + linux 的二进制文件
$ go env -w GOARCH=amd64
$ go env -w GOOS=linux
$ cd perf-tests/clusterloader2/cmd
$ go build -o clusterloader2
附录一:Clusterloader2源码修改
1、prometheus-apiserver-scrape-port
clusterloader2的该启动参数,指定当prometheus抓取apiserver指标时所使用的端口,默认为443。但是我们发现设置这个参数为6443并没有效果。
这里我们更改源码文件pkg/prometheus/prometheus.go,找到如下一行内容,从443改成6443
flags.IntEnvVar(&p.APIServerScrapePort, "prometheus-apiserver-scrape-port", "PROMETHEUS_APISERVER_SCRAPE_PORT", 6443, "Port for scraping kube-apiserver (default 6443).")
同时,更改prometheus/manifests/master-ips/master-endpoints.yaml文件,把如下一行也改成6443
{{$PROMETHEUS_APISERVER_SCRAPE_PORT := DefaultParam .PROMETHEUS_APISERVER_SCRAPE_PORT 6443}}
2、node-exporter的安装
clusterloader2在安装node-exporter时,是通过ssh到master节点,然后以static pod的方式来安装的。这就需要master节点需要配置免密登录。这里我们更改源码文件pkg/prometheus/prometheus.go,不用clusterloader2来安装node-exporter,提示用户自己手动安装:
// runNodeExporter adds node-exporter as master's static manifest pod.
// TODO(mborsz): Consider migrating to something less ugly, e.g. daemonset-based approach,
// when master nodes have configured networking.
func (pc *Controller) runNodeExporter() error {
klog.V(2).Infof("Warning: Please install node-expoter on master mannually")
return nil
}
在本实验中,一开始我们手动能daemonset方式安装,发现有点问题,最后是通过二进制进行安装的。需要注意的是,node-exporter暴露的端口要为9100,否则的话要更改prometheus/manifests/master-ip/目录下的三个文件中的配置。
3、监控etcd
clusterloader2最开始会通过master节点的2382端口去获取监控etcd,如果失败则会ssh到master主机上,通过127.0.0.1:2379去监控etcd。
但实际上 kubeadm安装的k8s中,etcd暴露的端口为2381(注意kubeadm安装k8s时,etcd的监听地址要设置为0.0.0.0),因此我们需要改一下prometheus/manifests/master-ip/master-endpoints.yaml文件,把如下内容:
apiVersion: v1
kind: Endpoints
...
- name: etcd-2379
port: 2379
- name: etcd-2382
port: 2382
...
改成如下,即删除etcd-2379和etcd-2382,增加etcd-2381
apiVersion: v1
kind: Endpoints
...
- name: etcd-2381
port: 2381
...
然后,prometheus/manifests/master-ip/下的master-service.yaml和master-serviceMonitor.yaml也要像上面一样做相应的修改。
然后,再修改pkg/prometheus/prometheus.go文件,找到isEtcdEndpoint函数,函数的内容改成如下:
func isEtcdEndpoint(endpoint string) bool {
return endpoint == "etcd-2381"
}
最后,同样修改prometheus.go文件,找到isPrometheusReady函数,在expected targets注释那一行,把值从2改成1,这是因为删除了etcd-2329和etcd-2382,增加了etcd-2381:
func (pc *Controller) isPrometheusReady() (bool, error) {
...
if pc.clusterLoaderConfig.PrometheusConfig.ScrapeEtcd {
...
return CheckTargetsReady( // 1 out of 2 etcd targets should be ready.
pc.framework.GetClientSets().GetClient(),
func(t Target) bool { return isEtcdEndpoint(t.Labels["endpoint"]) },
1, // expected targets: etcd-2379 and etcd-2382, 这一行原来的值为2,要改成1
1) // one of them should be healthy
}
...
}
4、prometheus manifests的其他更改
最后,prometheus的manifests目录下的文件还有一些其他的修改,比如:
- prometheus与grafana的镜像要改成国内能拉到的
- prometheus的数据存储默认为google的网盘存储,改成emptyDir或hostPath
步骤二、搭建性能测试环境
1、架构图
本次我们性能测试的架构图如下:

2、安装Kubemark集群
Kubemark集群就是被压测的集群,它有三个Master。另外有一个External集群,它负责创建hollow pod,来模拟节点,注册到Kubemark集群中。虚拟节点通过LVS与Kubemark-Master通信。
对于kubemark集群:
- 使用kubeadm安装
- 需要安装网络插件,这里我们安装的是calico
- calico、kube-proxy、coredns这些工作负载需要手动更改,让它们只运行在master节点上,coredns可能需要添加toleration,让其能运行在master节点上
- master节点不用去掉taint(注意不用去掉,后面压测过程中,大量创建Pod时,那些Pod才不会调度在master节点上)
安装完成后, 如下:
$ kubectl get node | grep master
10.35.20.2 Ready control-plane,master 84d v1.23.3
10.35.20.3 Ready control-plane,master 84d v1.23.3
10.35.20.4 Ready control-plane,master 84d v1.23.3
$ kubectl get pod -n kube-system -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
calico-kube-controllers-7cf567797-l8q8k 1/1 Running 2 (51d ago) 84d 172.28.200.11 10.35.20.4 <none> <none>
calico-node-4s6gw 1/1 Running 2 (51d ago) 84d 10.35.20.4 10.35.20.4 <none> <none>
calico-node-grt64 1/1 Running 2 (51d ago) 84d 10.35.20.3 10.35.20.3 <none> <none>
calico-node-r5t5t 1/1 Running 3 (39h ago) 84d 10.35.20.2 10.35.20.2 <none> <none>
coredns-7466d9c549-85ss4 1/1 Running 2 (51d ago) 84d 172.28.200.10 10.35.20.4 <none> <none>
coredns-7466d9c549-br4km 1/1 Running 2 (51d ago) 84d 172.28.200.12 10.35.20.4 <none> <none>
etcd-10.35.20.2 1/1 Running 2 (51d ago) 84d 10.35.20.2 10.35.20.2 <none> <none>
etcd-10.35.20.3 1/1 Running 2 (51d ago) 84d 10.35.20.3 10.35.20.3 <none> <none>
etcd-10.35.20.4 1/1 Running 2 (51d ago) 84d 10.35.20.4 10.35.20.4 <none> <none>
kube-apiserver-10.35.20.2 1/1 Running 3 (51d ago) 84d 10.35.20.2 10.35.20.2 <none> <none>
kube-apiserver-10.35.20.3 1/1 Running 2 (51d ago) 84d 10.35.20.3 10.35.20.3 <none> <none>
kube-apiserver-10.35.20.4 1/1 Running 4 (51d ago) 84d 10.35.20.4 10.35.20.4 <none> <none>
kube-controller-manager-10.35.20.2 1/1 Running 3 (51d ago) 84d 10.35.20.2 10.35.20.2 <none> <none>
kube-controller-manager-10.35.20.3 1/1 Running 3 (51d ago) 84d 10.35.20.3 10.35.20.3 <none> <none>
kube-controller-manager-10.35.20.4 1/1 Running 7 (51d ago) 84d 10.35.20.4 10.35.20.4 <none> <none>
kube-proxy-rw58b 1/1 Running 2 (51d ago) 84d 10.35.20.4 10.35.20.4 <none> <none>
kube-proxy-tq4gk 1/1 Running 2 (51d ago) 84d 10.35.20.3 10.35.20.3 <none> <none>
kube-proxy-wz6zz 1/1 Running 2 (51d ago) 84d 10.35.20.2 10.35.20.2 <none> <none>
kube-scheduler-10.35.20.2 1/1 Running 3 (51d ago) 84d 10.35.20.2 10.35.20.2 <none> <none>
kube-scheduler-10.35.20.3 1/1 Running 5 (51d ago) 84d 10.35.20.3 10.35.20.3 <none> <none>
kube-scheduler-10.35.20.4 1/1 Running 6 (51d ago) 84d 10.35.20.4 10.35.20.4 <none> <none>
3、安装External集群
对于External集群,需要注意:
1、使用kubeadm安装
2、需要安装网络插件,这里我们安装calico
安装好后如下:
$ kubectl get node
NAME STATUS ROLES AGE VERSION
10.35.20.10 Ready <none> 84d v1.23.3
10.35.20.12 Ready <none> 84d v1.23.3
10.35.20.13 Ready <none> 84d v1.23.3
10.35.20.14 Ready <none> 84d v1.23.3
10.35.20.8 Ready control-plane,master 84d v1.23.3
10.35.20.9 Ready <none> 84d v1.23.3
$ kubectl get pod -n kube-system -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
calico-kube-controllers-7cf567797-59xhg 1/1 Running 2 (51d ago) 84d 10.10.138.139 10.35.20.8 <none> <none>
calico-node-8jx4l 1/1 Running 2 (51d ago) 84d 10.35.20.8 10.35.20.8 <none> <none>
calico-node-ls2z5 1/1 Running 2 (51d ago) 84d 10.35.20.10 10.35.20.10 <none> <none>
calico-node-plnjs 1/1 Running 2 (51d ago) 84d 10.35.20.14 10.35.20.14 <none> <none>
calico-node-tdcxx 1/1 Running 2 (51d ago) 84d 10.35.20.13 10.35.20.13 <none> <none>
calico-node-twbpc 1/1 Running 2 (51d ago) 84d 10.35.20.9 10.35.20.9 <none> <none>
calico-node-xtzfm 1/1 Running 2 (51d ago) 84d 10.35.20.12 10.35.20.12 <none> <none>
coredns-7466d9c549-gx7ht 1/1 Running 2 (51d ago) 84d 10.10.138.155 10.35.20.8 <none> <none>
coredns-7466d9c549-mfnxd 1/1 Running 2 (51d ago) 84d 10.10.138.170 10.35.20.8 <none> <none>
etcd-10.35.20.8 1/1 Running 4 (51d ago) 84d 10.35.20.8 10.35.20.8 <none> <none>
kube-apiserver-10.35.20.8 1/1 Running 14 (51d ago) 84d 10.35.20.8 10.35.20.8 <none> <none>
kube-controller-manager-10.35.20.8 1/1 Running 14 (51d ago) 84d 10.35.20.8 10.35.20.8 <none> <none>
kube-proxy-hfv4m 1/1 Running 3 (51d ago) 84d 10.35.20.12 10.35.20.12 <none> <none>
kube-proxy-hnhgw 1/1 Running 3 (51d ago) 84d 10.35.20.8 10.35.20.8 <none> <none>
kube-proxy-j4f62 1/1 Running 3 (51d ago) 84d 10.35.20.14 10.35.20.14 <none> <none>
kube-proxy-r9qrr 1/1 Running 3 (51d ago) 84d 10.35.20.10 10.35.20.10 <none> <none>
kube-proxy-smlwk 1/1 Running 3 (51d ago) 84d 10.35.20.13 10.35.20.13 <none> <none>
kube-proxy-zg8tx 1/1 Running 3 (51d ago) 84d 10.35.20.9 10.35.20.9 <none> <none>
kube-scheduler-10.35.20.8 1/1 Running 13 (51d ago) 84d 10.35.20.8 10.35.20.8 <none> <none>
然后,在External集群中创建kubemark集群的kubeconfig文件。拷贝Kubemark集群的admin.conf文件到External集群的Master节点上,重命名为kubemark-kubeconfig。然后执行以下命令把kubeconfig创建在kubemark命名空间的kubeconfig这个secret中
$ kubectl create ns kubemark
$ kubectl create secret generic kubeconfig --type=Opaque --namespace=kubemark --from-file=kubelet.kubeconfig=kubemark-kubeconfig --from-file=kubeproxy.kubeconfig=kubemark-kubeconfig
接着,我们创建如下的statefulset,向kubemark集群注册虚拟节点(我们使用statefulset,这里节点名字更有规律一点):
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: k8s-worker
namespace: kubemark
spec:
replicas: 2
podManagementPolicy: Parallel
serviceName: k8s-worker
selector:
matchLabels:
name: k8s-worker
template:
metadata:
labels:
name: k8s-worker
spec:
initContainers:
- name: init-inotify-limit
image: harbor.ccse.io:8021/library/busybox:latest
imagePullPolicy: IfNotPresent
command: ['sysctl', '-w', 'fs.inotify.max_user_instances=200']
securityContext:
privileged: true
volumes:
- name: kubeconfig-volume
secret:
secretName: kubeconfig
- name: logs-volume
hostPath:
path: /var/log
containers:
- name: hollow-kubelet
image: harbor.ccse.io:8021/kube-build/kubemark:v1.23.3
ports:
- containerPort: 4194
- containerPort: 10250
- containerPort: 10255
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
command:
- /kubemark
args:
- --morph=kubelet
- --use-host-image-service=false
- --name=$(NODE_NAME)
- --kubeconfig=/kubeconfig/kubelet.kubeconfig
- --alsologtostderr
- --v=2
volumeMounts:
- name: kubeconfig-volume
mountPath: /kubeconfig
readOnly: true
- name: logs-volume
mountPath: /var/log
resources:
requests:
cpu: 20m
memory: 50M
securityContext:
privileged: true
- name: hollow-proxy
image: harbor.ccse.io:8021/kube-build/kubemark:v1.23.3
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
command:
- /kubemark
args:
- --morph=proxy
- --name=$(NODE_NAME)
- --use-real-proxier=false
- --kubeconfig=/kubeconfig/kubeproxy.kubeconfig
- --alsologtostderr
- --v=2
volumeMounts:
- name: kubeconfig-volume
mountPath: /kubeconfig
readOnly: true
- name: logs-volume
mountPath: /var/log
resources:
requests:
cpu: 20m
memory: 50M
tolerations:
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
然后,我们在kubemark集群中就可以看到这两个虚拟节点了
$ kubectl get node
NAME STATUS ROLES AGE VERSION
10.35.20.2 Ready control-plane,master 84d v1.23.3
10.35.20.3 Ready control-plane,master 84d v1.23.3
10.35.20.4 Ready control-plane,master 84d v1.23.3
k8s-worker-0 Ready <none> 87m v1.23.3
k8s-worker-1 Ready <none> 87m v1.23.3
步骤三、运行density测试
1、拷贝并修改Prometheus的Manifest文件
拷贝prometheus的manifests目录到clusterloader2主机上的特定目录下,假设这里我们把它放在/home/docker/clusterloader2/prometheus/下。
另外,我们需要对其中的一些文件做修改:
- 0ssd-storage-class.yaml
该文件使用了gce的云盘,我们把它换成local-pv,内容改成如下:
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: ssd
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
- 0pv.yaml
在manifests/目录下新建0pv.yaml文件,内容如下,注意下面的<master-name>要改成集群中实际的某个Master的名称(可以用kubectl get node查看某个Master的名字)。
然后,在上面的Master节点上,手动创建目录/prometheus/data
apiVersion: v1
kind: PersistentVolume
metadata:
name: prometheus-data
spec:
capacity:
storage: 10Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
storageClassName: ssd
local:
path: /prometheus/data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- <master-name>
- prometheus-service.yaml
更改此文件,注释掉app: prometheus这一行
apiVersion: v1
kind: Service
metadata:
labels:
prometheus: k8s
name: prometheus-k8s
namespace: monitoring
spec:
ports:
- name: web
port: 9090
targetPort: web
selector:
# app: prometheus 注释掉此行
prometheus: k8s
sessionAffinity: ClientIP
2、测试步骤
我们在10.35.20.1进行测试。把clusterloader2文件拷贝到该主机上,然后把kubemark集群admin.conf文件拷贝到相同的目录下,并重命名为kubemark-kubeconfig。
接着,在相同的目录下创建config.yaml文件,内容如下注释了一些measurement,然后改了一些参数的值):
# ASSUMPTIONS:
# - Underlying cluster should have 100+ nodes.
# - Number of nodes should be divisible by NODES_PER_NAMESPACE (default 100).
#Constants
{{$DENSITY_RESOURCE_CONSTRAINTS_FILE := DefaultParam .DENSITY_RESOURCE_CONSTRAINTS_FILE ""}}
# Cater for the case where the number of nodes is less than nodes per namespace. See github.com/kubernetes/perf-tests/issues/887
# 每个命名空间100个节点,每个节点30个Pod,这样每个命名空间为3000个Pod
{{$NODES_PER_NAMESPACE := MinInt .Nodes (DefaultParam .NODES_PER_NAMESPACE 100)}}
{{$PODS_PER_NODE := DefaultParam .PODS_PER_NODE 30}}
{{$DENSITY_TEST_THROUGHPUT := DefaultParam .DENSITY_TEST_THROUGHPUT 20}}
{{$SCHEDULER_THROUGHPUT_THRESHOLD := DefaultParam .CL2_SCHEDULER_THROUGHPUT_THRESHOLD 0}}
# LATENCY_POD_MEMORY and LATENCY_POD_CPU are calculated for 1-core 4GB node.
# Increasing allocation of both memory and cpu by 10%
# decreases the value of priority function in scheduler by one point.
# This results in decreased probability of choosing the same node again.
{{$LATENCY_POD_CPU := DefaultParam .LATENCY_POD_CPU 100}}
{{$LATENCY_POD_MEMORY := DefaultParam .LATENCY_POD_MEMORY 350}}
{{$MIN_LATENCY_PODS := DefaultParam .MIN_LATENCY_PODS 500}}
{{$MIN_SATURATION_PODS_TIMEOUT := 180}}
{{$ENABLE_CHAOSMONKEY := DefaultParam .ENABLE_CHAOSMONKEY false}}
{{$ENABLE_SYSTEM_POD_METRICS:= DefaultParam .ENABLE_SYSTEM_POD_METRICS true}}
{{$ENABLE_CLUSTER_OOMS_TRACKER := DefaultParam .CL2_ENABLE_CLUSTER_OOMS_TRACKER true}}
{{$CLUSTER_OOMS_IGNORED_PROCESSES := DefaultParam .CL2_CLUSTER_OOMS_IGNORED_PROCESSES ""}}
{{$USE_SIMPLE_LATENCY_QUERY := DefaultParam .USE_SIMPLE_LATENCY_QUERY false}}
{{$ENABLE_RESTART_COUNT_CHECK := DefaultParam .ENABLE_RESTART_COUNT_CHECK true}}
{{$RESTART_COUNT_THRESHOLD_OVERRIDES:= DefaultParam .RESTART_COUNT_THRESHOLD_OVERRIDES ""}}
{{$ALLOWED_SLOW_API_CALLS := DefaultParam .CL2_ALLOWED_SLOW_API_CALLS 0}}
{{$ENABLE_VIOLATIONS_FOR_SCHEDULING_THROUGHPUT := DefaultParam .CL2_ENABLE_VIOLATIONS_FOR_SCHEDULING_THROUGHPUT true}}
#Variables
{{$namespaces := DivideInt .Nodes $NODES_PER_NAMESPACE}}
{{$podsPerNamespace := MultiplyInt $PODS_PER_NODE $NODES_PER_NAMESPACE}}
{{$totalPods := MultiplyInt $podsPerNamespace $namespaces}}
{{$latencyReplicas := DivideInt (MaxInt $MIN_LATENCY_PODS .Nodes) $namespaces}}
{{$totalLatencyPods := MultiplyInt $namespaces $latencyReplicas}}
{{$saturationDeploymentTimeout := DivideFloat $totalPods $DENSITY_TEST_THROUGHPUT | AddInt $MIN_SATURATION_PODS_TIMEOUT}}
# saturationDeploymentHardTimeout must be at least 20m to make sure that ~10m node
# failure won't fail the test. See github.com/kubernetes/kubernetes/issues/73461#issuecomment-467338711
# 根据经验每秒大概能调度20个Pod,5000节点时有150000个Pod,需要7500秒才能调度完,所以这里要改成7500+
{{$saturationDeploymentHardTimeout := MaxInt $saturationDeploymentTimeout 12000}}
{{$saturationDeploymentSpec := DefaultParam .SATURATION_DEPLOYMENT_SPEC "deployment.yaml"}}
{{$latencyDeploymentSpec := DefaultParam .LATENCY_DEPLOYMENT_SPEC "deployment.yaml"}}
# Probe measurements shared parameter
{{$PROBE_MEASUREMENTS_CHECK_PROBES_READY_TIMEOUT := DefaultParam .CL2_PROBE_MEASUREMENTS_CHECK_PROBES_READY_TIMEOUT "15m"}}
name: density
namespace:
number: {{$namespaces}}
tuningSets:
- name: Uniform5qps
qpsLoad:
# 每秒钟创建5个object,本文中object为deployment
qps: 5
# 该参数在上面为false,即不模拟节点故障
{{if $ENABLE_CHAOSMONKEY}}
chaosMonkey:
nodeFailure:
failureRate: 0.01
interval: 1m
jitterFactor: 10.0
simulatedDowntime: 10m
{{end}}
steps:
- name: Starting measurements
# 开始监控API调用
measurements:
- Identifier: APIResponsivenessPrometheus
Method: APIResponsivenessPrometheus
Params:
action: start
- Identifier: APIResponsivenessPrometheusSimple
Method: APIResponsivenessPrometheus
Params:
action: start
# TODO(oxddr): figure out how many probers to run in function of cluster
# 根据源码kubemark集群不支持InClusterNetworkLatency和DnsLookupLatency,故把它们注释掉
# - Identifier: InClusterNetworkLatency
# Method: InClusterNetworkLatency
# Params:
# action: start
# checkProbesReadyTimeout: {{$PROBE_MEASUREMENTS_CHECK_PROBES_READY_TIMEOUT}}
# replicasPerProbe: {{AddInt 2 (DivideInt .Nodes 100)}}
# - Identifier: DnsLookupLatency
# Method: DnsLookupLatency
# Params:
# action: start
# checkProbesReadyTimeout: {{$PROBE_MEASUREMENTS_CHECK_PROBES_READY_TIMEOUT}}
# replicasPerProbe: {{AddInt 2 (DivideInt .Nodes 100)}}
# 暂不清楚TestMetrics用来做什么,先注释
# - Identifier: TestMetrics
# Method: TestMetrics
# Params:
# action: start
# resourceConstraints: {{$DENSITY_RESOURCE_CONSTRAINTS_FILE}}
# systemPodMetricsEnabled: {{$ENABLE_SYSTEM_POD_METRICS}}
# clusterOOMsTrackerEnabled: {{$ENABLE_CLUSTER_OOMS_TRACKER}}
# clusterOOMsIgnoredProcesses: {{$CLUSTER_OOMS_IGNORED_PROCESSES}}
# restartCountThresholdOverrides: {{YamlQuote $RESTART_COUNT_THRESHOLD_OVERRIDES 4}}
# enableRestartCountCheck: {{$ENABLE_RESTART_COUNT_CHECK}}
- name: Starting saturation pod measurements
# 开始监控Pod启动延时
measurements:
- Identifier: SaturationPodStartupLatency
Method: PodStartupLatency
Params:
action: start
labelSelector: group = saturation
threshold: {{$saturationDeploymentTimeout}}s
- Identifier: WaitForRunningSaturationDeployments
Method: WaitForControlledPodsRunning
Params:
action: start
apiVersion: apps/v1
kind: Deployment
labelSelector: group = saturation
operationTimeout: {{$saturationDeploymentHardTimeout}}s
- Identifier: SchedulingThroughput
Method: SchedulingThroughput
Params:
action: start
labelSelector: group = saturation
# 开始创建saturation pod, 即30*N个Pod,N为节点数
- name: Creating saturation pods
phases:
- namespaceRange:
min: 1
max: {{$namespaces}}
# 一个命名空间中创建几个object,即几个deployment
replicasPerNamespace: 1
tuningSet: Uniform5qps
objectBundle:
- basename: saturation-deployment
objectTemplatePath: {{$saturationDeploymentSpec}}
# 下面的参数用于填充deployment.yaml中的变量,根据前面的variables,podsPerNamespace的值为3000,即一个命名空间中有一个deployment,有3000个Pod
templateFillMap:
Replicas: {{$podsPerNamespace}}
Group: saturation
CpuRequest: 1m
MemoryRequest: 10M
# 等待saturation pod都为Running状态
- name: Waiting for saturation pods to be running
measurements:
- Identifier: WaitForRunningSaturationDeployments
Method: WaitForControlledPodsRunning
Params:
action: gather
- name: Collecting saturation pod measurements
measurements:
# 统计saturation pod的启动延时
- Identifier: SaturationPodStartupLatency
Method: PodStartupLatency
Params:
action: gather
# 统计saturation pod的调度吞吐量,即每秒调度多少个Pod,如果小于threshold,则该项measurement为failed。threshhold上面的默认为0,所以不会失败
- Identifier: SchedulingThroughput
Method: SchedulingThroughput
Params:
action: gather
enableViolations: {{$ENABLE_VIOLATIONS_FOR_SCHEDULING_THROUGHPUT}}
threshold: {{$SCHEDULER_THROUGHPUT_THRESHOLD}}
# 在创建了30*N个Pod后,再创建500个latency pod(个数由前面的参数决定),观察当集群的Pod已经"饱和(saturation)"后,是否还能正常调度Pod
# 开始监控latency pod的启动延时
- name: Starting latency pod measurements
measurements:
- Identifier: PodStartupLatency
Method: PodStartupLatency
Params:
action: start
labelSelector: group = latency
- Identifier: WaitForRunningLatencyDeployments
Method: WaitForControlledPodsRunning
Params:
action: start
apiVersion: apps/v1
kind: Deployment
labelSelector: group = latency
operationTimeout: 15m
# 创建latency pod
- name: Creating latency pods
phases:
- namespaceRange:
min: 1
max: {{$namespaces}}
replicasPerNamespace: {{$latencyReplicas}}
tuningSet: Uniform5qps
objectBundle:
- basename: latency-deployment
objectTemplatePath: {{$latencyDeploymentSpec}}
templateFillMap:
Replicas: 1
Group: latency
CpuRequest: {{$LATENCY_POD_CPU}}m
MemoryRequest: {{$LATENCY_POD_MEMORY}}M
# 等待latency pod处于Running状态
- name: Waiting for latency pods to be running
measurements:
- Identifier: WaitForRunningLatencyDeployments
Method: WaitForControlledPodsRunning
Params:
action: gather
# 删除latency pod
- name: Deleting latency pods
phases:
- namespaceRange:
min: 1
max: {{$namespaces}}
replicasPerNamespace: 0
tuningSet: Uniform5qps
objectBundle:
- basename: latency-deployment
objectTemplatePath: {{$latencyDeploymentSpec}}
# 等待latency pod删除完成
- name: Waiting for latency pods to be deleted
measurements:
- Identifier: WaitForRunningLatencyDeployments
Method: WaitForControlledPodsRunning
Params:
action: gather
# 收集latency pod的启动延时
- name: Collecting pod startup latency
measurements:
- Identifier: PodStartupLatency
Method: PodStartupLatency
Params:
action: gather
# 删除saturation pod
- name: Deleting saturation pods
phases:
- namespaceRange:
min: 1
max: {{$namespaces}}
replicasPerNamespace: 0
tuningSet: Uniform5qps
objectBundle:
- basename: saturation-deployment
objectTemplatePath: {{$saturationDeploymentSpec}}
# 等待saturation pod删除完成
- name: Waiting for saturation pods to be deleted
measurements:
- Identifier: WaitForRunningSaturationDeployments
Method: WaitForControlledPodsRunning
Params:
action: gather
- name: Collecting measurements
measurements:
# APIResponsivenessPrometheusSimple统计API调用延时,使用的是Histgram类型的指标
- Identifier: APIResponsivenessPrometheusSimple
Method: APIResponsivenessPrometheus
Params:
action: gather
enableViolations: true
useSimpleLatencyQuery: true
summaryName: APIResponsivenessPrometheus_simple
allowedSlowCalls: {{$ALLOWED_SLOW_API_CALLS}}
# APIResponsivenessPrometheus统计API调用延时,使用的是Summary类型的指标,该指标更为准确,一般以它为准
{{if not $USE_SIMPLE_LATENCY_QUERY}}
- Identifier: APIResponsivenessPrometheus
Method: APIResponsivenessPrometheus
Params:
action: gather
allowedSlowCalls: {{$ALLOWED_SLOW_API_CALLS}}
{{end}}
# 注释掉这三个
# - Identifier: InClusterNetworkLatency
# Method: InClusterNetworkLatency
# Params:
# action: gather
# - Identifier: DnsLookupLatency
# Method: DnsLookupLatency
# Params:
# action: gather
# - Identifier: TestMetrics
# Method: TestMetrics
# Params:
# action: gather
# systemPodMetricsEnabled: {{$ENABLE_SYSTEM_POD_METRICS}}
# clusterOOMsTrackerEnabled: {{$ENABLE_CLUSTER_OOMS_TRACKER}}
# restartCountThresholdOverrides: {{YamlQuote $RESTART_COUNT_THRESHOLD_OVERRIDES 4}}
# enableRestartCountCheck: {{$ENABLE_RESTART_COUNT_CHECK}}
然后,在相同的目录下创建deployment.yaml文件,内容如下文件的内容一样,没做改动):
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.Name}}
labels:
group: {{.Group}}
spec:
replicas: {{.Replicas}}
selector:
matchLabels:
name: {{.Name}}
template:
metadata:
labels:
name: {{.Name}}
group: {{.Group}}
spec:
containers:
- image: k8s.gcr.io/pause:3.1
imagePullPolicy: IfNotPresent
name: {{.Name}}
ports:
resources:
requests:
cpu: {{.CpuRequest}}
memory: {{.MemoryRequest}}
# Add not-ready/unreachable tolerations for 15 minutes so that node
# failure doesn't trigger pod deletion.
tolerations:
- key: "node.kubernetes.io/not-ready"
operator: "Exists"
effect: "NoExecute"
tolerationSeconds: 900
- key: "node.kubernetes.io/unreachable"
operator: "Exists"
effect: "NoExecute"
tolerationSeconds: 900
注意,上面的deployment.yaml中,没有对master的toleration,所以它们的Pod不会调度在kubemark集群master上,只会调度在虚拟节点上。
接着,我们把虚拟节点扩容到500个,然后执行命令开始压测(注意要显示指定--node=500,否则clusterloader2会把三个master也算上,当成503个节点,创建的Pod数就是30*503):
$ ./clusterloader2 --testconfig=config.yaml --provider=kubemark --provider-configs=ROOT_KUBECONFIG=./kubemark-kubeconfig --kubeconfig=./kubemark-kubeconfig --v=2 --enable-exec-service=false \
--enable-prometheus-server=true --tear-down-prometheus-server=false --prometheus-manifest-path /home/docker/clusterloader2/prometheus/manifest --nodes=500 2>&1 | tee output.txt
3、测试结果
上面的命令,会输出如下的日志,在下面的日志中,有如下几点要注意:
1、在开始前,会在kubemark集群中安装prometheus stack,这是因为API调用延时的两个SLI依赖于Promtheus采集kube-apiserver的指标。而clusterloader2会默认在主机的$GOPATH/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests目录下寻找prometheus的yaml文件
I0816 19:56:50.070635 14229 network_performance_measurement.go:87] Registering Network Performance Measurement
I0816 19:56:50.134943 14229 clusterloader.go:157] ClusterConfig.MasterName set to 10.35.20.2
E0816 19:56:50.178965 14229 clusterloader.go:168] Getting master external ip error: didn't find any ExternalIP master IPs
I0816 19:56:50.221833 14229 clusterloader.go:175] ClusterConfig.MasterInternalIP set to [10.35.20.2 10.35.20.3 10.35.20.4]
I0816 19:56:50.221890 14229 clusterloader.go:267] Using config: {ClusterConfig:{KubeConfigPath:./kubemark-kubeconfig RunFromCluster:false Nodes:500 Provider:0xc00069aae0 EtcdCertificatePath:/etc/srv/kubernetes/pki/etcd-apiserver-server.crt EtcdKeyPath:/etc/srv/kubernetes/pki/etcd-apiserver-server.key EtcdInsecurePort:2382 MasterIPs:[] MasterInternalIPs:[10.35.20.2 10.35.20.3 10.35.20.4] MasterName:10.35.20.2 DeleteStaleNamespaces:false DeleteAutomanagedNamespaces:true APIServerPprofByClientEnabled:true KubeletPort:10250 K8SClientsNumber:5} ReportDir: EnableExecService:false ModifierConfig:{OverwriteTestConfig:[] SkipSteps:[]} PrometheusConfig:{EnableServer:true TearDownServer:false ScrapeEtcd:false ScrapeNodeExporter:false ScrapeKubelets:false ScrapeKubeProxy:true ScrapeKubeStateMetrics:false ScrapeMetricsServerMetrics:false ScrapeNodeLocalDNS:false ScrapeAnet:false APIServerScrapePort:6443 SnapshotProject: ManifestPath:$GOPATH/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests CoreManifests:$GOPATH/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/*.yaml DefaultServiceMonitors:$GOPATH/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/default/*.yaml MasterIPServiceMonitors:$GOPATH/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/master-ip/*.yaml KubeStateMetricsManifests:$GOPATH/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/exporters/kube-state-metrics/*.yaml MetricsServerManifests:$GOPATH/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/exporters/metrics-server/*.yaml NodeExporterPod:$GOPATH/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/exporters/node_exporter/node-exporter.yaml StorageClassProvisioner:kubernetes.io/gce-pd StorageClassVolumeType:pd-ssd ReadyTimeout:15m0s} OverridePaths:[]}
I0816 19:56:50.267717 14229 cluster.go:74] Listing cluster nodes:
I0816 19:56:50.267730 14229 cluster.go:86] Name: 10.35.20.2, clusterIP: 10.35.20.2, externalIP: , isSchedulable: true
I0816 19:56:50.267733 14229 cluster.go:86] Name: 10.35.20.3, clusterIP: 10.35.20.3, externalIP: , isSchedulable: true
I0816 19:56:50.267735 14229 cluster.go:86] Name: 10.35.20.4, clusterIP: 10.35.20.4, externalIP: , isSchedulable: true
I0816 19:56:50.267737 14229 cluster.go:86] Name: k8s-worker-0, clusterIP: 10.10.221.197, externalIP: , isSchedulable: true
I0816 19:56:50.267739 14229 cluster.go:86] Name: k8s-worker-1, clusterIP: 10.10.242.201, externalIP: , isSchedulable: true
I0816 19:56:50.267741 14229 cluster.go:86] Name: k8s-worker-10, clusterIP: 10.10.221.200, externalIP: , isSchedulable: true
...
...
I0816 19:56:50.317586 14229 framework.go:72] Creating framework with 5 clients and "./kubemark-kubeconfig" kubeconfig.
I0816 19:56:50.328376 14229 framework.go:72] Creating framework with 1 clients and "./kubemark-kubeconfig" kubeconfig.
I0816 19:56:50.329488 14229 prometheus.go:406] Using internal master ips ([10.35.20.2 10.35.20.3 10.35.20.4]) to monitor master's components
I0816 19:56:50.329508 14229 prometheus.go:186] Setting up prometheus stack
I0816 19:56:50.352537 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-0alertmanagerConfigCustomResourceDefinition.yaml
I0816 19:56:50.407743 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-0alertmanagerCustomResourceDefinition.yaml
I0816 19:56:50.473379 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-0podmonitorCustomResourceDefinition.yaml
I0816 19:56:50.487049 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-0probeCustomResourceDefinition.yaml
I0816 19:56:50.496292 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-0prometheusCustomResourceDefinition.yaml
I0816 19:56:50.582050 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-0prometheusruleCustomResourceDefinition.yaml
I0816 19:56:50.603479 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-0servicemonitorCustomResourceDefinition.yaml
I0816 19:56:50.621977 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-0thanosrulerCustomResourceDefinition.yaml
I0816 19:56:50.677669 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-clusterRole.yaml
I0816 19:56:50.684537 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-clusterRoleBinding.yaml
I0816 19:56:50.690106 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-deployment.yaml
I0816 19:56:50.698910 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-service.yaml
I0816 19:56:50.704062 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-serviceAccount.yaml
I0816 19:56:50.709162 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0prometheus-operator-serviceMonitor.yaml
I0816 19:56:50.742573 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/0ssd-storage-class.yaml
I0816 19:56:50.746934 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/grafana-dashboardDatasources.yaml
I0816 19:56:50.753183 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/grafana-dashboardDefinitions.yaml
I0816 19:56:50.843207 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/grafana-dashboardSources.yaml
I0816 19:56:50.847023 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/grafana-deployment.yaml
I0816 19:56:50.854351 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/grafana-service.yaml
I0816 19:56:50.864135 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/grafana-serviceAccount.yaml
I0816 19:56:50.869317 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/grafana-serviceMonitor.yaml
I0816 19:56:50.874331 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/prometheus-clusterRole.yaml
I0816 19:56:50.878233 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/prometheus-clusterRoleBinding.yaml
I0816 19:56:50.882729 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/prometheus-prometheus.yaml
I0816 19:56:50.960848 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/prometheus-roleBindingConfig.yaml
I0816 19:56:50.965558 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/prometheus-roleConfig.yaml
I0816 19:56:50.969571 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/prometheus-rules.yaml
I0816 19:56:51.002266 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/prometheus-service.yaml
I0816 19:56:51.011344 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/prometheus-serviceAccount.yaml
I0816 19:56:51.015258 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/prometheus-serviceMonitor.yaml
I0816 19:56:51.019967 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/prometheus-windows-scrape-configs.yaml
I0816 19:56:51.025094 14229 prometheus.go:294] Exposing kube-apiserver metrics in the cluster
I0816 19:56:51.047622 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/master-ip/master-endpoints.yaml
I0816 19:56:51.054637 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/master-ip/master-service.yaml
I0816 19:56:51.061353 14229 framework.go:274] Applying /home/docker/gopath/src/k8s.io/perf-tests/clusterloader2/pkg/prometheus/manifests/master-ip/master-serviceMonitor.yaml
I0816 19:56:51.067330 14229 prometheus.go:341] Waiting for Prometheus stack to become healthy...
I0816 19:57:21.089535 14229 util.go:104] All 11 expected targets are ready
I0816 19:57:21.089554 14229 prometheus.go:238] Prometheus stack set up successfully
W0816 19:57:21.089586 14229 imagepreload.go:87] No images specified. Skipping image preloading
I0816 19:57:21.095293 14229 clusterloader.go:408] Test config successfully dumped to: generatedConfig_density.yaml
I0816 19:57:21.095368 14229 clusterloader.go:221] --------------------------------------------------------------------------------
I0816 19:57:21.095378 14229 clusterloader.go:222] Running config.yaml
I0816 19:57:21.095386 14229 clusterloader.go:223] --------------------------------------------------------------------------------
2、当执行完后,会输出各种详细的指标数据。通过搜索关键字SchedulingThroughput,我们可以看到如下的调度吞量(对应config.yaml中的Identifier为SchedulingThroughput这个measurement)
I0816 20:26:20.733126 14229 simple_test_executor.go:83] SchedulingThroughput: {
"perc50": 20,
"perc90": 20,
"perc99": 20.2,
"max": 24
}
3、通过搜索关键字pod_startup,可以找到如下的PodStartupLatency_SaturationPodStartupLatency的启动延时;以及StatelessPodStartupLatency_SaturationPodStartupLatency的启动延时。由于这里创建的Pod都是Stateless的,所以这两个指标的数据是一致的。另外还可以找到StatefulPodStartupLatency_SaturationPodStartupLatency,不过由于没有stateful pod,所以数据为0。(这些数据对应着config.yaml中Identifier为SaturationPodStartupLatency这个measurement)
I0816 20:26:20.733129 14229 simple_test_executor.go:83] PodStartupLatency_SaturationPodStartupLatency: {
"version": "1.0",
"dataItems": [
...
{
"data": {
"Perc50": 1323.250478,
"Perc90": 1878.221624,
"Perc99": 2184.178124
},
"unit": "ms",
"labels": {
"Metric": "pod_startup"
}
},
...
I0816 20:26:20.733137 14229 simple_test_executor.go:83] StatelessPodStartupLatency_SaturationPodStartupLatency: {
"version": "1.0",
"dataItems": [
...
{
"data": {
"Perc50": 1323.250478,
"Perc90": 1878.221624,
"Perc99": 2184.178124
},
"unit": "ms",
"labels": {
"Metric": "pod_startup"
}
},
...
I0816 20:26:20.733142 14229 simple_test_executor.go:83] StatefulPodStartupLatency_SaturationPodStartupLatency: {
"version": "1.0",
"dataItems": [
...
{
"data": {
"Perc50": 0,
"Perc90": 0,
"Perc99": 0
},
"unit": "ms",
"labels": {
"Metric": "pod_startup"
}
},
...
另外,我们还可以看到latency pod的启动延时,如下(对应着config.yaml中Identifier为PodStartupLatency这个measurement):
I0816 20:26:20.733148 14229 simple_test_executor.go:83] PodStartupLatency_PodStartupLatency: {
"version": "1.0",
"dataItems": [
...
{
"data": {
"Perc50": 1350.344608,
"Perc90": 1943.066452,
"Perc99": 2169.727106
},
"unit": "ms",
"labels": {
"Metric": "pod_startup"
}
}
...
I0816 20:26:20.733152 14229 simple_test_executor.go:83] StatelessPodStartupLatency_PodStartupLatency: {
"version": "1.0",
"dataItems": [
...
{
"data": {
"Perc50": 1350.344608,
"Perc90": 1943.066452,
"Perc99": 2169.727106
},
"unit": "ms",
"labels": {
"Metric": "pod_startup"
}
},
...
I0816 20:26:20.733156 14229 simple_test_executor.go:83] StatefulPodStartupLatency_PodStartupLatency: {
"version": "1.0",
"dataItems": [
...
{
"data": {
"Perc50": 0,
"Perc90": 0,
"Perc99": 0
},
"unit": "ms",
"labels": {
"Metric": "pod_startup"
}
},
...
4、另外,我们还可以看到API调用延时的结果,它会列出所有(resource,verb)对的结果。对应config.yaml文件中Identifier为APIResponsivenessPrometheus这个measurement。
I0816 20:26:20.733160 14229 simple_test_executor.go:83] APIResponsivenessPrometheus: {
"version": "v1",
"dataItems": [
{
"data": {
"Perc50": 500,
"Perc90": 580,
"Perc99": 598
},
"unit": "ms",
"labels": {
"Count": "3",
"Resource": "events",
"Scope": "cluster",
"SlowCount": "0",
"Subresource": "",
"Verb": "LIST"
}
},
{
"data": {
"Perc50": 26.017594,
"Perc90": 46.83167,
"Perc99": 167.899999
},
"unit": "ms",
"labels": {
"Count": "1008",
"Resource": "pods",
"Scope": "namespace",
"SlowCount": "0",
"Subresource": "",
"Verb": "LIST"
}
},
...
还可以看到APIResponsivenessPrometheus_simple这个measurement的结果:
I0816 20:26:20.735165 14229 simple_test_executor.go:83] APIResponsivenessPrometheus_simple: {
"version": "v1",
"dataItems": [
{
"data": {
"Perc50": 450,
"Perc90": 570,
"Perc99": 597
},
"unit": "ms",
"labels": {
"Count": "3",
"Resource": "events",
"Scope": "cluster",
"SlowCount": "0",
"Subresource": "",
"Verb": "LIST"
}
},
{
"data": {
"Perc50": 33.333333,
"Perc90": 80,
"Perc99": 98
},
...
可以看到,config.yaml中的每个measurement都会输出详细的信息。当然,clusterloader2最后会判断每个measurement,如果都通过的话,最后几行就会得到如下的Success的结果(如果想要知道每个Measurement是如何判断成功或失败的,需要阅读clusterloader2的源码):
I0816 20:26:20.743052 14229 simple_test_executor.go:98]
I0816 20:26:35.762300 14229 simple_test_executor.go:395] Resources cleanup time: 15.019234743s
I0816 20:26:35.762329 14229 clusterloader.go:231] --------------------------------------------------------------------------------
I0816 20:26:35.762337 14229 clusterloader.go:232] Test Finished
I0816 20:26:35.762344 14229 clusterloader.go:233] Test: config.yaml
I0816 20:26:35.762350 14229 clusterloader.go:234] Status: Success
I0816 20:26:35.762356 14229 clusterloader.go:238] --------------------------------------------------------------------------------
最后,我们回到前面介绍的那三个SLI,在这个测试中,三个SLI是如何在这里面实现的呢?前两个API调用延时是通过APIResponsivenessPrometheus这个method实现的,第三个Pod启动延时是通过PodStartupLatency这个method实现的。
4、Grafana
上面的命令会自动安装prometheus、grafana等,在grafana上已经自动配置好了四个Dashboard,如下:
- DNS:DNS延时的监控信息
- Master dashboard:kubemark集群中master相关的监控信息
- Network:网络相关的监控信息
- SLO:API调度延时相关的监控信息

我们查看SLO这个dashboard,如下,可以看到API调用延时以及threhlold。发现,在mutating api call latency中,有一个指标已经超了threshold,其他的都没有超过。但是为什么我们的测试用例还是通过的呢?详情请参考Measurement下的《APIResponsivenessPrometheus》一文。


5、耗时统计
clusterloader2命令执行完后,会在目录下生成一个junit.xml文件,统计了此次测试过程中的耗时分布,如下:
$ cat junit.xml
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="ClusterLoaderV2" tests="0" failures="0" errors="0" time="1754.772">
<testcase name="density overall (config.yaml)" classname="ClusterLoaderV2" time="1754.767000937"></testcase>
<testcase name="density: [step: 01] Starting measurements" classname="ClusterLoaderV2" time="0.000106709"></testcase>
<testcase name="density: [step: 02] Starting saturation pod measurements" classname="ClusterLoaderV2" time="0.100424074"></testcase>
<testcase name="density: [step: 03] Creating saturation pods" classname="ClusterLoaderV2" time="1.007091926"></testcase>
<testcase name="density: [step: 04] Waiting for saturation pods to be running" classname="ClusterLoaderV2" time="758.146062481"></testcase>
<testcase name="density: [step: 05] Collecting saturation pod measurements" classname="ClusterLoaderV2" time="0.596172704"></testcase>
<testcase name="density: [step: 06] Starting latency pod measurements" classname="ClusterLoaderV2" time="0.101019002"></testcase>
<testcase name="density: [step: 07] Creating latency pods" classname="ClusterLoaderV2" time="100.284284775"></testcase>
<testcase name="density: [step: 08] Waiting for latency pods to be running" classname="ClusterLoaderV2" time="19.857551787"></testcase>
<testcase name="density: [step: 09] Deleting latency pods" classname="ClusterLoaderV2" time="100.305020092"></testcase>
<testcase name="density: [step: 10] Waiting for latency pods to be deleted" classname="ClusterLoaderV2" time="5.0046168"></testcase>
<testcase name="density: [step: 11] Collecting pod startup latency" classname="ClusterLoaderV2" time="0.535112677"></testcase>
<testcase name="density: [step: 12] Deleting saturation pods" classname="ClusterLoaderV2" time="1.00338642"></testcase>
<testcase name="density: [step: 13] Waiting for saturation pods to be deleted" classname="ClusterLoaderV2" time="751.552869757"></testcase>
<testcase name="density: [step: 14] Collecting measurements" classname="ClusterLoaderV2" time="1.157418612"></testcase>
</testsuite>
步骤四、运行load测试
load测试主要是模拟创建各种类型的资源。然后判断API调用延时那两个SLO是否满足。一般来说,这里不再创建工作负载与Pod,所以与节点规模的关系不大。
1、测试的配置文件
config.yaml
# ASSUMPTIONS:
# - Underlying cluster should have 100+ nodes.
# - Number of nodes should be divisible by NODES_PER_NAMESPACE (default 100).
# - The number of created SVCs is half the number of created Deployments.
# - Only half of Deployments will be assigned 1-1 to existing SVCs.
#Constants
# Cater for the case where the number of nodes is less than nodes per namespace. See github.com/kubernetes/perf-tests/issues/887
{{$NODES_PER_NAMESPACE := MinInt .Nodes (DefaultParam .NODES_PER_NAMESPACE 100)}}
# See github.com/kubernetes/perf-tests/pull/1667#issuecomment-769642266
{{$IS_SMALL_CLUSTER := lt .Nodes 100}}
{{$PODS_PER_NODE := DefaultParam .PODS_PER_NODE 30}}
{{$LOAD_TEST_THROUGHPUT := DefaultParam .CL2_LOAD_TEST_THROUGHPUT 10}}
{{$DELETE_TEST_THROUGHPUT := DefaultParam .CL2_DELETE_TEST_THROUGHPUT $LOAD_TEST_THROUGHPUT}}
{{$BIG_GROUP_SIZE := DefaultParam .BIG_GROUP_SIZE 250}}
{{$MEDIUM_GROUP_SIZE := DefaultParam .MEDIUM_GROUP_SIZE 30}}
{{$SMALL_GROUP_SIZE := DefaultParam .SMALL_GROUP_SIZE 5}}
{{$SMALL_STATEFUL_SETS_PER_NAMESPACE := DefaultParam .SMALL_STATEFUL_SETS_PER_NAMESPACE 1}}
{{$MEDIUM_STATEFUL_SETS_PER_NAMESPACE := DefaultParam .MEDIUM_STATEFUL_SETS_PER_NAMESPACE 1}}
{{$ENABLE_CHAOSMONKEY := DefaultParam .ENABLE_CHAOSMONKEY false}}
{{$ENABLE_API_AVAILABILITY_MEASUREMENT := DefaultParam .CL2_ENABLE_API_AVAILABILITY_MEASUREMENT false}}
{{$ENABLE_HUGE_SERVICES := DefaultParam .CL2_ENABLE_HUGE_SERVICES false}}
{{$HUGE_SERVICES_SIZE := DefaultParam .CL2_HUGE_SERVICES_SIZE .Nodes}}
# Determines number of pods per deployment. Should be a divider of $HUGE_SERVICES_SIZE.
{{$HUGE_SERVICES_PODS_PER_DEPLOYMENT := DefaultParam .CL2_HUGE_SERVICES_PODS_PER_DEPLOYMENT 1000}}
{{$RANDOM_SCALE_FACTOR := 0.5}}
#Variables
{{$namespaces := DivideInt .Nodes $NODES_PER_NAMESPACE}}
{{$totalPods := MultiplyInt $namespaces $NODES_PER_NAMESPACE $PODS_PER_NODE}}
{{$podsPerNamespace := DivideInt $totalPods $namespaces}}
{{$saturationTime := DivideInt $totalPods $LOAD_TEST_THROUGHPUT}}
{{$deletionTime := DivideInt $totalPods $DELETE_TEST_THROUGHPUT}}
# bigDeployments - 1/4 of namespace pods should be in big Deployments.
{{$bigDeploymentsPerNamespace := DivideInt $podsPerNamespace (MultiplyInt 4 $BIG_GROUP_SIZE)}}
# mediumDeployments - 1/4 of namespace pods should be in medium Deployments.
{{$mediumDeploymentsPerNamespace := DivideInt $podsPerNamespace (MultiplyInt 4 $MEDIUM_GROUP_SIZE)}}
# smallDeployments - 1/2 of namespace pods should be in small Deployments.
{{$smallDeploymentsPerNamespace := DivideInt $podsPerNamespace (MultiplyInt 2 $SMALL_GROUP_SIZE)}}
# Stateful sets are enabled. Reduce the number of small and medium deployments per namespace
# See github.com/kubernetes/perf-tests/issues/1036#issuecomment-607631768
# Ensure non zero or negative after subtraction.
{{$smallDeploymentsPerNamespace := MaxInt 0 (SubtractInt $smallDeploymentsPerNamespace $SMALL_STATEFUL_SETS_PER_NAMESPACE)}}
{{$mediumDeploymentsPerNamespace := MaxInt 0 (SubtractInt $mediumDeploymentsPerNamespace $MEDIUM_STATEFUL_SETS_PER_NAMESPACE)}}
# Jobs are enabled. Reduce the number of small, medium, big deployments per namespace.
# Ensure non zero or negative after subtraction.
{{$smallDeploymentsPerNamespace := MaxInt 0 (SubtractInt $smallDeploymentsPerNamespace 1)}}
{{$mediumDeploymentsPerNamespace := MaxInt 0 (SubtractInt $mediumDeploymentsPerNamespace 1)}}
{{$bigDeploymentsPerNamespace := MaxInt 0 (SubtractInt $bigDeploymentsPerNamespace 1)}}
# Disable big jobs on small clusters.
{{$bigJobsPerNamespace := IfThenElse $IS_SMALL_CLUSTER 0 1}}
# The minimal number of pods to be used to measure various things like
# pod-startup-latency or scheduler-throughput. The purpose of it is to avoid
# problems in small clusters where we wouldn't have enough samples (pods) to
# measure things accurately.
{{$MIN_PODS_IN_SMALL_CLUSTERS := 500}}
# BEGIN scheduler-throughput section
# TODO( github.com/kubernetes/perf-tests/issues/1027): Lower the number of "min-pods" once we fix the scheduler throughput measurement.
{{$totalSchedulerThroughputPods := MaxInt (MultiplyInt 2 $MIN_PODS_IN_SMALL_CLUSTERS) .Nodes}}
{{$schedulerThroughputReplicasPerNamespace := 1}}
{{$schedulerThroughputPodsPerDeployment := .Nodes}}
{{$schedulerThroughputNamespaces := DivideInt $totalSchedulerThroughputPods $schedulerThroughputPodsPerDeployment}}
{{if and $ENABLE_HUGE_SERVICES (ge $HUGE_SERVICES_SIZE $HUGE_SERVICES_PODS_PER_DEPLOYMENT)}}
{{$schedulerThroughputReplicasPerNamespace = DivideInt $HUGE_SERVICES_SIZE $HUGE_SERVICES_PODS_PER_DEPLOYMENT}}
{{$schedulerThroughputPodsPerDeployment = $HUGE_SERVICES_PODS_PER_DEPLOYMENT}}
{{$schedulerThroughputNamespaces = 1}}
{{end}}
# Set schedulerThroughputNamespaces to 1 on small clusters otherwise it will result
# in an unnecessary number of namespaces.
{{$schedulerThroughputNamespaces := IfThenElse $IS_SMALL_CLUSTER 1 $schedulerThroughputNamespaces}}
# END scheduler-throughput section
# Command to be executed
{{$EXEC_COMMAND := DefaultParam .CL2_EXEC_COMMAND nil}}
{{$EXIT_AFTER_EXEC := DefaultParam .CL2_EXIT_AFTER_EXEC false}}
{{$SLEEP_AFTER_EXEC_DURATION := DefaultParam .CL2_SLEEP_AFTER_EXEC_DURATION "0s"}}
{{$latencyPodImage := DefaultParam .CL2_LATENCY_POD_IMAGE "k8s.gcr.io/pause:3.1"}}
name: load
namespace:
number: {{AddInt $namespaces $schedulerThroughputNamespaces}}
tuningSets:
- name: Sequence
parallelismLimitedLoad:
parallelismLimit: 1
# Dedicated tuningSet for SchedulerThroughput phases that results in fully
# parallel creation of deployments.
- name: SchedulerThroughputParallel
parallelismLimitedLoad:
parallelismLimit: {{MultiplyInt $schedulerThroughputNamespaces $schedulerThroughputReplicasPerNamespace}}
# TODO(github.com/kubernetes/perf-tests/issues/1024): This TuningSet is used only for pod-startup-latency, get rid of it
# Uniform5qps: for each running phase, use 5 qps.
- name: Uniform5qps
qpsLoad:
qps: 5
# Global100qps: use 100 qps globally:
# * split equally qps among all running phases
# * if some phase finishes, other phases will get more qps.
- name: Global100qps
globalQPSLoad:
qps: 100
burst: 1
- name: RandomizedSaturationTimeLimited
RandomizedTimeLimitedLoad:
timeLimit: {{$saturationTime}}s
- name: RandomizedScalingTimeLimited
RandomizedTimeLimitedLoad:
# The expected number of created/deleted pods is totalPods/4 when scaling,
# as each RS changes its size from X to a uniform random value in [X/2, 3X/2].
# To match 10 [pods/s] requirement, we need to divide saturationTime by 4.
timeLimit: {{DivideInt $saturationTime 4}}s
- name: DeletionTimeLimited
TimeLimitedLoad:
timeLimit: 5m
- name: RandomizedDeletionTimeLimited
RandomizedTimeLimitedLoad:
timeLimit: {{$deletionTime}}s
{{if $ENABLE_CHAOSMONKEY}}
chaosMonkey:
nodeFailure:
failureRate: 0.01
interval: 5m
jitterFactor: 2.0
simulatedDowntime: 10m
{{end}}
steps:
- module:
path: /modules/measurements.yaml
params:
action: start
- module:
path: modules/services.yaml
params:
actionName: "Creating"
namespaces: {{$namespaces}}
smallServicesPerNamespace: {{DivideInt (AddInt $smallDeploymentsPerNamespace 1) 2}}
mediumServicesPerNamespace: {{DivideInt (AddInt $mediumDeploymentsPerNamespace 1) 2}}
bigServicesPerNamespace: {{DivideInt (AddInt $bigDeploymentsPerNamespace 1) 2}}
- name: Creating PriorityClass for DaemonSets
phases:
- replicasPerNamespace: 1
tuningSet: Sequence
objectBundle:
- basename: daemonset-priorityclass
objectTemplatePath: daemonset-priorityclass.yaml
# Moved from reconcile-objects.yaml to mitigate github.com/kubernetes/kubernetes/issues/96635.
# TODO(github.com/kubernetes/perf-tests/issues/1823): Merge back to reconcile-objects.yaml once the k/k bug is fixed.
- module:
path: /modules/configmaps-secrets.yaml
params:
actionName: create
tuningSet: Global100qps
namespaces: {{$namespaces}}
bigDeploymentsPerNamespace: {{$bigDeploymentsPerNamespace}}
mediumDeploymentsPerNamespace: {{$mediumDeploymentsPerNamespace}}
smallDeploymentsPerNamespace: {{$smallDeploymentsPerNamespace}}
# 不再测试工作负载
#- module:
# path: /modules/reconcile-objects.yaml
# params:
# actionName: "create"
# namespaces: {{$namespaces}}
# tuningSet: RandomizedSaturationTimeLimited
# testMaxReplicaFactor: {{$RANDOM_SCALE_FACTOR}}
# # We rely on the fact that daemonset is using the same image as the 'pod-startup-latency' module.
# # The goal is to cache the image to all nodes before we start any latency pod,
# # so that when we measure pod startup latency, the image is already present on all nodes.
# # This way, the pod startup latency we measure excludes (or limits impact) of image pulling,
# # whuch matches our SLO definition: github.com/kubernetes/community/blob/master/sig-scalability/slos/pod_startup_latency.md.
# daemonSetImage: {{$latencyPodImage}}
# daemonSetEnv: "before update"
# daemonSetReplicas: 1
# bigDeploymentSize: {{$BIG_GROUP_SIZE}}
# bigDeploymentsPerNamespace: {{$bigDeploymentsPerNamespace}}
# mediumDeploymentSize: {{$MEDIUM_GROUP_SIZE}}
# mediumDeploymentsPerNamespace: {{$mediumDeploymentsPerNamespace}}
# smallDeploymentSize: {{$SMALL_GROUP_SIZE}}
# smallDeploymentsPerNamespace: {{$smallDeploymentsPerNamespace}}
# smallStatefulSetSize: {{$SMALL_GROUP_SIZE}}
# smallStatefulSetsPerNamespace: {{$SMALL_STATEFUL_SETS_PER_NAMESPACE}}
# mediumStatefulSetSize: {{$MEDIUM_GROUP_SIZE}}
# mediumStatefulSetsPerNamespace: {{$MEDIUM_STATEFUL_SETS_PER_NAMESPACE}}
# bigJobSize: {{$BIG_GROUP_SIZE}}
# bigJobsPerNamespace: {{$bigJobsPerNamespace}}
# mediumJobSize: {{$MEDIUM_GROUP_SIZE}}
# mediumJobsPerNamespace: 1
# smallJobSize: {{$SMALL_GROUP_SIZE}}
# smallJobsPerNamespace: 1
# 不再测试scheduler-throughput
#{{if not $IS_SMALL_CLUSTER}}
## BEGIN scheduler throughput
# {{if $ENABLE_HUGE_SERVICES}}
#- module:
# path: modules/huge-services.yaml
# params:
# action: create
# namespaces: {{$namespaces}}
# replicasPerNamespace: 1
# schedulerThroughputNamespaces: {{$schedulerThroughputNamespaces}}
# {{end}}
#- module:
# path: modules/scheduler-throughput.yaml
# params:
# action: create
# namespaces: {{$namespaces}}
# replicasPerNamespace: {{$schedulerThroughputReplicasPerNamespace}}
# schedulerThroughputNamespaces: {{$schedulerThroughputNamespaces}}
# schedulerThroughputPodsPerDeployment: {{$schedulerThroughputPodsPerDeployment}}
# {{if $ENABLE_HUGE_SERVICES}}
# serviceName: huge-service
# {{end}}
#{{end}}
# kubemark集群不支持EXEC_COMMAND
#{{if $EXEC_COMMAND}}
#
#{{if $ENABLE_API_AVAILABILITY_MEASUREMENT}}
#- name: Pausing APIAvailability measurement
# measurements:
# - Identifier: APIAvailability
# Method: APIAvailability
# Params:
# action: pause
#{{end}}
#
#- name: Exec command
# measurements:
# - Identifier: ExecCommand
# Method: Exec
# Params:
# command:
# {{range $EXEC_COMMAND}}
# - {{.}}
# {{end}}
#
#{{if $ENABLE_API_AVAILABILITY_MEASUREMENT}}
#- name: Unpausing APIAvailability measurement
# measurements:
# - Identifier: APIAvailability
# Method: APIAvailability
# Params:
# action: unpause
#{{end}}
#
#- name: Sleep
# measurements:
# - Identifier: WaitAfterExec
# Method: Sleep
# Params:
# duration: {{$SLEEP_AFTER_EXEC_DURATION}}
#{{end}}
{{if not $EXIT_AFTER_EXEC}}
#{{if not $IS_SMALL_CLUSTER}}
#- module:
# path: modules/scheduler-throughput.yaml
# params:
# action: delete
# namespaces: {{$namespaces}}
# replicasPerNamespace: 0
# schedulerThroughputNamespaces: {{$schedulerThroughputNamespaces}}
# schedulerThroughputPodsPerDeployment: {{$schedulerThroughputPodsPerDeployment}}
# {{if $ENABLE_HUGE_SERVICES}}
# serviceName: huge-service
#- module:
# path: modules/huge-services.yaml
# params:
# action: delete
# namespaces: {{$namespaces}}
# replicasPerNamespace: 0
# schedulerThroughputNamespaces: {{$schedulerThroughputNamespaces}}
# {{end}}
# END scheduler throughput
{{end}}
#{{if not $IS_SMALL_CLUSTER}}
## TODO(kubernetes/perf-tests/issues/1024): We shouldn't have a dedicated module for measuring pod-startup-latency.
#- module:
# path: modules/pod-startup-latency.yaml
# params:
# namespaces: {{$namespaces}}
# minPodsInSmallCluster: {{$MIN_PODS_IN_SMALL_CLUSTERS}}
# image: {{$latencyPodImage}}
#{{end}}
#- module:
# path: /modules/reconcile-objects.yaml
# params:
# actionName: "scale and update"
# namespaces: {{$namespaces}}
# tuningSet: RandomizedScalingTimeLimited
# randomScaleFactor: {{$RANDOM_SCALE_FACTOR}}
# testMaxReplicaFactor: {{$RANDOM_SCALE_FACTOR}}
# daemonSetImage: {{$latencyPodImage}}
# daemonSetEnv: "after update"
# daemonSetReplicas: 1
# bigDeploymentSize: {{$BIG_GROUP_SIZE}}
# bigDeploymentsPerNamespace: {{$bigDeploymentsPerNamespace}}
# mediumDeploymentSize: {{$MEDIUM_GROUP_SIZE}}
# mediumDeploymentsPerNamespace: {{$mediumDeploymentsPerNamespace}}
# smallDeploymentSize: {{$SMALL_GROUP_SIZE}}
# smallDeploymentsPerNamespace: {{$smallDeploymentsPerNamespace}}
# smallStatefulSetSize: {{$SMALL_GROUP_SIZE}}
# smallStatefulSetsPerNamespace: {{$SMALL_STATEFUL_SETS_PER_NAMESPACE}}
# mediumStatefulSetSize: {{$MEDIUM_GROUP_SIZE}}
# mediumStatefulSetsPerNamespace: {{$MEDIUM_STATEFUL_SETS_PER_NAMESPACE}}
# bigJobSize: {{$BIG_GROUP_SIZE}}
# bigJobsPerNamespace: {{$bigJobsPerNamespace}}
# mediumJobSize: {{$MEDIUM_GROUP_SIZE}}
# mediumJobsPerNamespace: 1
# smallJobSize: {{$SMALL_GROUP_SIZE}}
# smallJobsPerNamespace: 1
#
#- module:
# path: /modules/reconcile-objects.yaml
# params:
# actionName: "delete"
# namespaces: {{$namespaces}}
# tuningSet: RandomizedDeletionTimeLimited
# testMaxReplicaFactor: {{$RANDOM_SCALE_FACTOR}}
# daemonSetReplicas: 0
# bigDeploymentSize: {{$BIG_GROUP_SIZE}}
# bigDeploymentsPerNamespace: 0
# mediumDeploymentSize: {{$MEDIUM_GROUP_SIZE}}
# mediumDeploymentsPerNamespace: 0
# smallDeploymentSize: {{$SMALL_GROUP_SIZE}}
# smallDeploymentsPerNamespace: 0
# smallStatefulSetSize: {{$SMALL_GROUP_SIZE}}
# smallStatefulSetsPerNamespace: 0
# mediumStatefulSetSize: {{$MEDIUM_GROUP_SIZE}}
# mediumStatefulSetsPerNamespace: 0
# bigJobSize: {{$BIG_GROUP_SIZE}}
# bigJobsPerNamespace: 0
# mediumJobSize: {{$MEDIUM_GROUP_SIZE}}
# mediumJobsPerNamespace: 0
# smallJobSize: {{$SMALL_GROUP_SIZE}}
# smallJobsPerNamespace: 0
# pvSmallStatefulSetSize: {{$SMALL_STATEFUL_SETS_PER_NAMESPACE}}
# pvMediumStatefulSetSize: {{$MEDIUM_STATEFUL_SETS_PER_NAMESPACE}}
- module:
path: /modules/configmaps-secrets.yaml
params:
actionName: delete
tuningSet: Global100qps
namespaces: {{$namespaces}}
bigDeploymentsPerNamespace: 0
mediumDeploymentsPerNamespace: 0
smallDeploymentsPerNamespace: 0
- name: Deleting PriorityClass for DaemonSets
phases:
- replicasPerNamespace: 0
tuningSet: Sequence
objectBundle:
- basename: daemonset-priorityclass
objectTemplatePath: daemonset-priorityclass.yaml
- module:
path: modules/services.yaml
params:
actionName: "Deleting"
namespaces: {{$namespaces}}
smallServicesPerNamespace: 0
mediumServicesPerNamespace: 0
bigServicesPerNamespace: 0
{{end}} # not EXIT_AFTER_EXEC
- module:
path: /modules/measurements.yaml
params:
action: gather
module/measurement.yaml
## Measurement module defines test scoped measurement.
## Input params
# Valid actions: "start", "gather"
{{$action := .action}}
## Feature-gates and configs:
{{$ALLOWED_SLOW_API_CALLS := DefaultParam .CL2_ALLOWED_SLOW_API_CALLS 0}}
{{$API_AVAILABILITY_PERCENTAGE_THRESHOLD := DefaultParam .CL2_API_AVAILABILITY_PERCENTAGE_THRESHOLD 0.0}}
{{$CLUSTER_OOMS_IGNORED_PROCESSES := DefaultParam .CL2_CLUSTER_OOMS_IGNORED_PROCESSES ""}}
{{$CUSTOM_API_CALL_THRESHOLDS := DefaultParam .CUSTOM_API_CALL_THRESHOLDS ""}}
{{$ENABLE_API_AVAILABILITY_MEASUREMENT := DefaultParam .CL2_ENABLE_API_AVAILABILITY_MEASUREMENT false}}
{{$ENABLE_CLUSTER_OOMS_TRACKER := DefaultParam .CL2_ENABLE_CLUSTER_OOMS_TRACKER true}}
{{$ENABLE_NODE_LOCAL_DNS_LATENCY := DefaultParam .CL2_ENABLE_NODE_LOCAL_DNS_LATENCY false}}
{{$ENABLE_RESTART_COUNT_CHECK := DefaultParam .ENABLE_RESTART_COUNT_CHECK true}}
{{$ENABLE_SYSTEM_POD_METRICS:= DefaultParam .ENABLE_SYSTEM_POD_METRICS true}}
{{$ENABLE_VIOLATIONS_FOR_API_CALL_PROMETHEUS := DefaultParam .CL2_ENABLE_VIOLATIONS_FOR_API_CALL_PROMETHEUS false}}
{{$ENABLE_VIOLATIONS_FOR_API_CALL_PROMETHEUS_SIMPLE := DefaultParam .CL2_ENABLE_VIOLATIONS_FOR_API_CALL_PROMETHEUS_SIMPLE true}}
{{$NODE_LOCAL_DNS_LATENCY_THRESHOLD := DefaultParam .CL2_NODE_LOCAL_DNS_LATENCY_THRESHOLD "5s"}}
{{$PROMETHEUS_SCRAPE_KUBE_PROXY := DefaultParam .PROMETHEUS_SCRAPE_KUBE_PROXY true}}
{{$PROMETHEUS_SCRAPE_KUBE_STATE_METRICS := DefaultParam .PROMETHEUS_SCRAPE_KUBE_STATE_METRICS false}}
{{$PROMETHEUS_SCRAPE_METRICS_SERVER_METRICS := DefaultParam .PROMETHEUS_SCRAPE_METRICS_SERVER_METRICS false}}
{{$RESTART_COUNT_THRESHOLD_OVERRIDES:= DefaultParam .RESTART_COUNT_THRESHOLD_OVERRIDES ""}}
{{$USE_SIMPLE_LATENCY_QUERY := DefaultParam .USE_SIMPLE_LATENCY_QUERY false}}
# Probe measurements shared parameter
{{$PROBE_MEASUREMENTS_CHECK_PROBES_READY_TIMEOUT := DefaultParam .CL2_PROBE_MEASUREMENTS_CHECK_PROBES_READY_TIMEOUT "15m"}}
steps:
- name: "{{$action}}ing measurements"
measurements:
- Identifier: APIResponsivenessPrometheus
Method: APIResponsivenessPrometheus
Params:
action: {{$action}}
{{if not $USE_SIMPLE_LATENCY_QUERY}}
enableViolations: {{$ENABLE_VIOLATIONS_FOR_API_CALL_PROMETHEUS}}
allowedSlowCalls: {{$ALLOWED_SLOW_API_CALLS}}
customThresholds: {{YamlQuote $CUSTOM_API_CALL_THRESHOLDS 4}}
{{end}}
- Identifier: APIResponsivenessPrometheusSimple
Method: APIResponsivenessPrometheus
Params:
action: {{$action}}
enableViolations: {{$ENABLE_VIOLATIONS_FOR_API_CALL_PROMETHEUS_SIMPLE}}
useSimpleLatencyQuery: true
summaryName: APIResponsivenessPrometheus_simple
allowedSlowCalls: {{$ALLOWED_SLOW_API_CALLS}}
customThresholds: {{YamlQuote $CUSTOM_API_CALL_THRESHOLDS 4}}
# density中已经测试了PodStartupLatency,这里不再测试
#Identifier: CreatePhasePodStartupLatency
# Method: PodStartupLatency
# Params:
# action: {{$action}}
# labelSelector: group = load
# threshold: 1h # TODO(github.com/kubernetes/perf-tests/issues/1024): Ideally, this should be 5s
# kubemark集群不支持InClusterNetworkLatency指标
#- Identifier: InClusterNetworkLatency
# Method: InClusterNetworkLatency
# Params:
# action: {{$action}}
# checkProbesReadyTimeout: {{$PROBE_MEASUREMENTS_CHECK_PROBES_READY_TIMEOUT}}
# replicasPerProbe: {{AddInt 2 (DivideInt .Nodes 100)}}
# kubemark集群不支持该指标
#{{if $ENABLE_NODE_LOCAL_DNS_LATENCY}}
# - Identifier: NodeLocalDNSLatency
# Method: NodeLocalDNSLatencyPrometheus
# Params:
# action: {{$action}}
# enableViolations: true
# threshold: {{$NODE_LOCAL_DNS_LATENCY_THRESHOLD}}
#{{end}}
# 不清楚该指标,先保留
#- Identifier: SLOMeasurement
# Method: SLOMeasurement
# Params:
# action: {{$action}}
# checkProbesReadyTimeout: {{$PROBE_MEASUREMENTS_CHECK_PROBES_READY_TIMEOUT}}
# replicasPerProbe: {{AddInt 2 (DivideInt .Nodes 100)}}
# kubemark集群不支持以下指标
#{{if $PROMETHEUS_SCRAPE_KUBE_PROXY}}
# - Identifier: NetworkProgrammingLatency
# Method: NetworkProgrammingLatency
# Params:
# action: {{$action}}
#{{end}}
#{{if $PROMETHEUS_SCRAPE_KUBE_STATE_METRICS}}
# - Identifier: KubeStateMetricsLatency
# Method: KubeStateMetricsLatency
# Params:
# action: {{$action}}
#{{end}}
#{{if $PROMETHEUS_SCRAPE_METRICS_SERVER_METRICS}}
# - Identifier: MetricsServerPrometheus
# Method: MetricsServerPrometheus
# Params:
# action: {{$action}}
#{{end}}
{{if $ENABLE_API_AVAILABILITY_MEASUREMENT}}
- Identifier: APIAvailability
Method: APIAvailability
Params:
action: {{$action}}
pollFrequency: "5s"
hostPollTimeoutSeconds: 5
threshold: {{$API_AVAILABILITY_PERCENTAGE_THRESHOLD}}
{{end}}
#- Identifier: TestMetrics
# Method: TestMetrics
# Params:
# action: {{$action}}
# systemPodMetricsEnabled: {{$ENABLE_SYSTEM_POD_METRICS}}
# clusterOOMsIgnoredProcesses: {{YamlQuote $CLUSTER_OOMS_IGNORED_PROCESSES 4}}
# clusterOOMsTrackerEnabled: {{$ENABLE_CLUSTER_OOMS_TRACKER}}
# restartCountThresholdOverrides: {{YamlQuote $RESTART_COUNT_THRESHOLD_OVERRIDES 4}}
# enableRestartCountCheck: {{$ENABLE_RESTART_COUNT_CHECK}}
其他的文件内容保持不变
2、测试命令
和density的命令完全一样。