前置条件
硬件资源
- 一台linux服务器,实体机或者虚拟机都可以
- 硬件配置按照1000并发,8核16G的标准进行配置
软件资源
k8s部署
wget https://download.edoc2.com:5999/stress_test/AutoStressTest/latest/auto-stress-test.yaml
#下载镜像包
wget https://download.edoc2.com:5999/stress_test/AutoStressTest/latest/autostresstest_latest.tar.gz
#解压镜像
tar zxf autostresstest_latest.tar.gz
#加载镜像
docker load -i autostresstest_latest.tar.gz
apiVersion: apps/v1
kind: Deployment
metadata:
name: autostress
spec:
replicas: 1
selector:
matchLabels:
app: autostress
template:
metadata:
labels:
app: autostress
spec:
containers:
- name: autostress
image: registry.edoc2.com:5000/edoc2v5/autostress:latest
#当前pod一直重启,无法成功启动时,打开此注释,以特权模式启动
#ecurityContext:
# privileged: true
ports:
- containerPort: 8080
- containerPort: 18080
volumeMounts:
- name: test
mountPath: /opt/test
- name: jenkins-home
mountPath: /var/jenkins_home
- name: prometheus
mountPath: /opt/prometheus
- name: consul
mountPath: /opt/consul
env:
- name: TZ
value: "Asia/Shanghai"
- name: HOST_IP
value: "192.168.251.86" #物理机IP地址
- name: Product
value: "ECM" #将ECM替换为要测试的产品
- name: Version
value: "v6.6.0.0" #将v6.0.0.0替换为要测试的版本
volumes:
- name: test
hostPath:
path: /data/test #物理机挂载目录
- name: jenkins-home
hostPath:
path: /data/jenkins_home #物理机挂载目录
- name: prometheus
hostPath:
path: /data/prometheus #物理机挂载目录
- name: consul
hostPath:
path: /data/consul #物理机挂载目录
---
apiVersion: v1
kind: Service
metadata:
name: autostress
spec:
selector:
app: autostress
ports:
- name: jenkins-8080
protocol: TCP
port: 8080
targetPort: 8080
nodePort: 30080 #压测工具入口端口
- name: report-18080
protocol: TCP
port: 18080
targetPort: 18080
nodePort: 31080 #查看测试报告端口
- name: monitor-3000
protocol: TCP
port: 3000
targetPort: 3000
nodePort: 33000 #监控面板端口
- name: prometheus-9090
protocol: TCP
port: 9090
targetPort: 9090
nodePort: 39090 #Prometheus端口
- name: consul-8500
protocol: TCP
port: 8500
targetPort: 8500
nodePort: 38500 #服务器注册中心端口
type: NodePort
kubectl apply -f auto-stress-test.yaml
Swarm部署
wget https://download.edoc2.com:5999/stress_test/AutoStressTest/latest/auto-stress-test.yml
- (可选) 服务器没有外网时,下载离线镜像包,并导入镜像
#下载镜像包
wget https://download.edoc2.com:5999/stress_test/AutoStressTest/latest/autostresstest_latest.tar.gz
#解压镜像
tar zxf autostresstest_latest.tar.gz
#加载镜像
docker load -i autostresstest_latest.tar.gz
version: '3.5'
services:
stress:
hostname: autostress
image: registry.edoc2.com:5000/edoc2v5/autostress:latest
volumes:
#修改下面的挂载目录
- /data/test:/opt/test
- /data/jenkins_home:/var/jenkins_home
- /data/prometheus:/opt/prometheus
- /data/consul:/opt/consul
ports:
- "8080:8080" #压测程序端口
- "18080:18080" #测试报告端口
- "3000:3000" #监控看板端口
- "9090:9090" #普罗米修斯端口
- "8500:8500" #consul注册中心端口
labels:
"type": "1"
environment:
- TZ=Asia/Shanghai
- HOST_IP=192.168.251.158 #物理机IP
- Product=ECM #将ECM替换为要测试的产品
- Version=v6.6.0.0 #将v6.6.0.0替换为要测试的版本
deploy:
replicas: 1
restart_policy:
condition: on-failure
docker stack deploy -c auto-stress-test.yml autostress
- 当容器无法启动时,需要改成使用特权模式启动,特权模式仅支持docker run启动,参考如下启动命令
docker run -d --name autostress \
-p 8080:8080 \
-p 18080:18080 \
-p 9090:9090 \
-p 3000:3000 \
-p 8500:8500 \
-v /opt/data/test:/opt/test \
-v /opt/data/jenkins_home:/var/jenkins_home \
-v /opt/data/prometheus:/opt/prometheus \
-v /opt/data/consul:/opt/consul \
-e "TZ=Asia/Shanghai" \
-e "HOST_IP=192.168.251.86" \
-e "Product=ECM" \
-e "Version=v6.6.0.0" \
--privileged=true \
registry.edoc2.com:5000/edoc2v5/autostress:latest