-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpx-bench-main.yml
244 lines (242 loc) · 6.74 KB
/
px-bench-main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
apiVersion: v1
kind: ConfigMap
metadata:
name: files
namespace: px-bench
data:
run.sh: |-
#!/usr/bin/bash
mkdir /tmp/fio
#iterate throught the block sizes and rw settings
i=0
for sc in $storageclass_list; do
for blocksize in ${blocksize_list}; do
for readwrite in ${readwrite_list}; do
export sc readwrite blocksize
export loops=1000
export time_based=time_based
i=$[$i+1]
filename=/tmp/fio/$(printf %.3d $i)_${sc}_$blocksize-$readwrite.fio
envsubst < /px-bench/main.fio.tmpl > $filename
if [[ ! " ${mixed_workloads[@]} " =~ " ${rw} " ]]; then
sed -i '/rwmix/d' $filename
fi
sed -i '/##/d' $filename
done
done
done
for sc in $storageclass_list; do
filename=/tmp/fio/000_${sc}_warmup.fio
export blocksize=$warmup_blocksize
export readwrite=write
export loops=$warmup_loops
export runtime=86400
export time_based=
envsubst < /px-bench/main.fio.tmpl > $filename
done
nodeSelector=$(echo $node_selector | sed 's/=/: /')
kubectl create configmap fio-config --from-file=/tmp/fio -n px-bench
for sc in $storageclass_list; do
volumes="$volumes\
- name: mnt-$sc
persistentVolumeClaim:
claimName: mnt-$sc
"
volumemounts="$volumemounts\
- name: mnt-$sc
mountPath: /mnt/$sc
"
kubectl apply -f - <<EOF
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mnt-$sc
namespace: px-bench
spec:
storageClassName: $sc
accessModes:
- ReadWriteOnce
resources:
requests:
storage: $pvc_size
EOF
done
kubectl apply -f - <<EOF
apiVersion: batch/v1
kind: Job
metadata:
name: fio
namespace: px-bench
spec:
template:
metadata:
name: fio
labels:
px-bench: fio
spec:
nodeSelector:
$nodeSelector
securityContext:
fsGroupChangePolicy: "OnRootMismatch"
serviceAccountName: px-bench
terminationGracePeriodSeconds: 0
containers:
- name: fio
image: andrewh1978/px-bench
imagePullPolicy: "Always"
command: [ "/bin/bash", "/px-bench/fio.sh" ]
securityContext:
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop: ["ALL"]
volumeMounts:
- name: files
mountPath: /px-bench
- name: fio
mountPath: /fio
$volumemounts
volumes:
- name: files
configMap:
name: files
- name: fio
configMap:
name: fio-config
$volumes
restartPolicy: OnFailure
EOF
kubectl wait --for=condition=complete --timeout=86400s job/fio -n px-bench
main.fio.tmpl: |-
############################################################
## main.fio.tmpl
##
## This is a template for creating a fio jobfile.
## Do not edit. This is read by other scripts/functions.
##
############################################################
# This file was automatically created by px-bench
############################################################
#
[global]
size=$file_size
runtime=${runtime}
${time_based}
loops=${loops}
iodepth=${iodepth}
ioengine=${ioengine}
direct=${direct}
fsync_on_close=1
numjobs=${numjobs}
group_reporting=1
directory=/mnt/${sc}
filename=fio.dat
##----layout output-------
[layout-output]
blocksize=${blocksize}
readwrite=read # This will force fio to write to create the file, not just sparse creation.
create_only=1
##----Begin Workload Test-------
[${sc}_${blocksize}_${readwrite}]
stonewall
blocksize=${blocksize}
readwrite=${readwrite}
rwmixread=${rwmixread}
rwmixwrite=${rwmixwrite}
ramp_time=$ramp_time
fio.sh: |-
#!/usr/bin/bash
mkdir /tmp/output-json
mkdir /tmp/output-csv
for i in /fio/*; do
echo $(date +"%Y-%m-%d %H:%M:%S") - Running fio for $i
fio $i --output-format=json | tee /tmp/output-json/$(basename $i .fio)
if ! [[ $i =~ warmup ]] ; then
jq '.jobs[1] | {jobname, read_iops: .read.iops, write_iops: .write.iops, read_lat: .read.lat_ns.mean, write_lat: .write.lat_ns.mean, read_bw: .read.bw, write_bw: .write.bw }' /tmp/output-json/$(basename $i .fio) | jq -r ' flatten | @csv' >/tmp/output-csv/$(basename $i .fio)
fi
done
kubectl create configmap fio-output --from-file=/tmp/output-json -n px-bench
kubectl create configmap fio-csv --from-file=/tmp/output-csv -n px-bench
echo "storageclass, blocksize, workload, read_iops, write_iops, read_lat, write_lat, read_bw, write_bw" >/tmp/csv
kubectl get cm -n px-bench fio-csv -o yaml | grep -A 1 '|' | grep -v '|' | sed 's/^ *//;s/"//g;s/_/,/g' >>/tmp/csv
kubectl create configmap csv --from-file=/tmp/csv -n px-bench
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: px-bench
namespace: px-bench
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: px-bench
namespace: px-bench
rules:
- apiGroups: [""]
resources:
- configmaps
- persistentvolumeclaims
verbs:
- create
- get
- apiGroups: ["batch"]
resources:
- jobs
verbs:
- create
- list
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: px-bench
namespace: px-bench
subjects:
- kind: ServiceAccount
name: px-bench
roleRef:
kind: Role
name: px-bench
apiGroup: rbac.authorization.k8s.io
---
apiVersion: batch/v1
kind: Job
metadata:
name: run
namespace: px-bench
spec:
template:
metadata:
name: run
labels:
px-bench: run
spec:
securityContext:
fsGroupChangePolicy: "OnRootMismatch"
serviceAccountName: px-bench
terminationGracePeriodSeconds: 0
containers:
- name: run
image: andrewh1978/px-bench
imagePullPolicy: "Always"
command: [ "/bin/bash", "/px-bench/run.sh" ]
securityContext:
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop: ["ALL"]
envFrom:
- configMapRef:
name: env
volumeMounts:
- name: files
mountPath: /px-bench
volumes:
- name: files
configMap:
name: files
restartPolicy: OnFailure