-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathall-spark-cluster-openshift-template.yaml
525 lines (512 loc) · 17.5 KB
/
all-spark-cluster-openshift-template.yaml
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: all-spark-cluster-template
annotations:
openshift.io/display-name: "Spark Cluster"
description: >-
Template for deploying a standalone Spark Cluster within OpenShift
iconClass: "icon-hadoop"
tags: "spark"
parameters:
- name: APP_NAME
description: Application name used to group resources and form URLs
value: spark
required: true
- name: SHARED_STORAGE_SIZE
description: Size of the storage claim for shared data directory
value: 10Gi
required: true
- name: ACCESS_KEY_ID
description: S3 access key ID
required: true
- name: SECRET_ACCESS_KEY
description: S3 secret access key
required: true
objects:
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
labels:
app: "${APP_NAME}"
name: spark-history-server
spec:
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: spark-history-server
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
labels:
app: "${APP_NAME}"
name: spark-master-ui
spec:
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: spark-master-ui
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
labels:
app: "${APP_NAME}"
name: spark-notebook
spec:
port:
targetPort: 8888-tcp
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: spark-notebook
- apiVersion: v1
kind: Service
metadata:
labels:
app: "${APP_NAME}"
name: spark-history-server
spec:
ports:
- port: 8087
protocol: TCP
targetPort: 8087
selector:
app: "${APP_NAME}"
deploymentconfig: spark-history-server
- apiVersion: v1
kind: Service
metadata:
labels:
app: "${APP_NAME}"
name: spark-master
spec:
ports:
- port: 7077
protocol: TCP
targetPort: 7077
selector:
app: "${APP_NAME}"
deploymentconfig: spark-master
- apiVersion: v1
kind: Service
metadata:
labels:
app: "${APP_NAME}"
name: spark-master-ui
spec:
ports:
- port: 8087
protocol: TCP
targetPort: 8087
selector:
app: "${APP_NAME}"
deploymentconfig: spark-master
- apiVersion: v1
kind: Service
metadata:
labels:
app: "${APP_NAME}"
name: spark-notebook
spec:
ports:
- name: 4040-tcp
port: 4040
protocol: TCP
targetPort: 4040
- name: 8888-tcp
port: 8888
protocol: TCP
targetPort: 8888
- name: 2222-tcp
port: 2222
protocol: TCP
targetPort: 2222
- name: 7777-tcp
port: 7777
protocol: TCP
targetPort: 7777
- name: 9999-tcp
port: 9999
protocol: TCP
targetPort: 9999
selector:
deploymentconfig: spark-notebook
app: "${APP_NAME}"
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
labels:
app: "${APP_NAME}"
name: spark-history-server
spec:
selector:
app: "${APP_NAME}"
deploymentconfig: spark-history-server
strategy:
type: Recreate
template:
metadata:
labels:
app: "${APP_NAME}"
deploymentconfig: spark-history-server
spec:
containers:
- args:
- /usr/local/spark/sbin/start-history-server.sh
- --properties-file
- /usr/local/spark/conf/spark-defaults.conf
command:
- /usr/local/bin/start.sh
env:
- name: SPARK_NO_DAEMONIZE
value: "true"
image: quay.io/hsci/all-spark:spark-3.4.1
imagePullPolicy: Always
name: all-spark
ports:
- containerPort: 18080
protocol: TCP
resources:
limits:
cpu: 1500m
requests:
cpu: 50m
volumeMounts:
- mountPath: /usr/local/spark/conf
name: spark-config
- mountPath: /home/jovyan/work
name: recovery-data
- env:
- name: FORWARD_PORT
value: "18080"
- name: BASIC_AUTH_USERNAME
valueFrom:
secretKeyRef:
key: username
name: spark-credentials
- name: BASIC_AUTH_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: spark-credentials
image: xscys/nginx-sidecar-basic-auth
imagePullPolicy: Always
name: auth-proxy
ports:
- containerPort: 8087
protocol: TCP
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 50m
memory: 32Mi
restartPolicy: Always
volumes:
- configMap:
defaultMode: 420
name: spark-config
name: spark-config
- name: recovery-data
persistentVolumeClaim:
claimName: "${APP_NAME}-pvc"
triggers:
- type: ConfigChange
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
labels:
app: "${APP_NAME}"
name: spark-master
spec:
selector:
app: "${APP_NAME}"
deploymentconfig: spark-master
strategy:
type: Recreate
template:
metadata:
labels:
app: "${APP_NAME}"
deploymentconfig: spark-master
spec:
containers:
- args:
- /usr/local/spark/sbin/start-master.sh
command:
- /usr/local/bin/start.sh
env:
- name: SPARK_MASTER_HOST
value: 0.0.0.0
- name: SPARK_MASTER_PORT
value: "7077"
- name: SPARK_NO_DAEMONIZE
value: "true"
image: quay.io/hsci/all-spark:spark-3.4.1
imagePullPolicy: Always
name: all-spark
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: 1500m
requests:
cpu: 50m
volumeMounts:
- mountPath: /usr/local/spark/conf
name: spark-config
- mountPath: /home/jovyan/work
name: recovery-data
- env:
- name: BASIC_AUTH_USERNAME
valueFrom:
secretKeyRef:
key: username
name: spark-credentials
- name: BASIC_AUTH_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: spark-credentials
image: xscys/nginx-sidecar-basic-auth
imagePullPolicy: Always
name: auth-proxy
ports:
- containerPort: 8087
protocol: TCP
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 50m
memory: 32Mi
volumes:
- configMap:
defaultMode: 420
name: spark-config
name: spark-config
- name: recovery-data
persistentVolumeClaim:
claimName: hpc-hd-spark-pvc
triggers:
- type: ConfigChange
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
labels:
app: "${APP_NAME}"
name: spark-notebook
spec:
selector:
app: "${APP_NAME}"
deploymentconfig: spark-notebook
strategy:
type: Recreate
template:
metadata:
labels:
app: "${APP_NAME}"
deploymentconfig: spark-notebook
spec:
containers:
- args:
- /bin/sh
- -c
- /usr/local/bin/start-notebook.sh --NotebookApp.password=${NBPASSWORD}
env:
- name: RESTARTABLE
value: "yes"
- name: NBPASSWORD
valueFrom:
secretKeyRef:
key: nbpassword
name: spark-credentials
image: quay.io/hsci/all-spark:spark-3.4.1
imagePullPolicy: Always
name: all-spark
ports:
- containerPort: 4040
protocol: TCP
- containerPort: 8888
protocol: TCP
- containerPort: 2222
protocol: TCP
- containerPort: 7777
protocol: TCP
- containerPort: 9999
protocol: TCP
resources:
limits:
memory: 16Gi
volumeMounts:
- mountPath: /home/jovyan/work
name: data
- mountPath: /usr/local/spark/conf
name: spark-config
volumes:
- configMap:
defaultMode: 420
name: spark-config
name: spark-config
- name: data
persistentVolumeClaim:
claimName: "${APP_NAME}-data"
triggers:
- type: ConfigChange
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
labels:
app: "${APP_NAME}"
name: spark-worker
spec:
selector:
app: "${APP_NAME}"
deploymentconfig: spark-worker
strategy:
type: Recreate
template:
metadata:
labels:
app: "${APP_NAME}"
deploymentconfig: spark-worker
spec:
containers:
- args:
- /usr/local/spark/sbin/start-worker.sh
- spark://spark-master:7077
command:
- /usr/local/bin/start.sh
env:
- name: SPARK_WORKER_PORT
value: "7077"
- name: SPARK_NO_DAEMONIZE
value: "true"
image: quay.io/hsci/all-spark:spark-3.4.1
imagePullPolicy: Always
name: all-spark
resources:
limits:
memory: 16Gi
volumeMounts:
- mountPath: /usr/local/spark/conf
name: spark-config
- mountPath: /home/jovyan/work
name: data
volumes:
- configMap:
defaultMode: 420
name: spark-config
name: spark-config
- name: data
persistentVolumeClaim:
claimName: "${APP_NAME}-data"
triggers:
- type: ConfigChange
- apiVersion: v1
data:
spark-defaults.conf: |
# Spark configuration shared by all the components
# 15.5G = 15872M
# 14.5G = 14848M
# 13.5G = 13824M
spark.master spark://spark-master:7077
#spark.scheduler.mode FAIR
spark.deploy.recoveryMode FILESYSTEM
spark.deploy.recoveryDirectory /home/jovyan/work/spark-recovery-state
spark.ui.reverseProxy true
spark.worker.cleanup.enabled true
spark.cleaner.referenceTracking.cleanCheckpoints true
spark.driver.supervise true
spark.eventLog.enabled true
spark.eventLog.compress true
spark.eventLog.dir /home/jovyan/work/spark-logs
spark.history.fs.logDirectory /home/jovyan/work/spark-logs
spark.history.fs.cleaner.enabled true
spark.shuffle.service.enabled true
spark.shuffle.service.fetch.rdd.enabled true
spark.shuffle.io.maxRetries 16
spark.shuffle.io.numConnectionsPerPeer 3
spark.shuffle.consolidateFiles true
spark.rdd.compress true
spark.serializer org.apache.spark.serializer.KryoSerializer
spark.kryoserializer.buffer.max 2047M
#spark.dynamicAllocation.enabled false
spark.dynamicAllocation.enabled true
spark.dynamicAllocation.minExecutors 1
spark.dynamicAllocation.executorIdleTimeout 240s
spark.executor.instances 16
spark.worker.memory 13G
spark.worker.cores 2
spark.executor.memory 12G
spark.executor.cores 2
spark.network.timeout 3600s
spark.driver.memory 14G
spark.driver.maxResultSize 13G
spark.driver.cores 2
spark.driver.host spark-notebook
spark.driver.bindAddress 0.0.0.0
spark.driver.port 2222
spark.driver.blockManager.port 7777
spark.repl.class.port 9999
# a3s
spark.hadoop.fs.s3a.path.style.access true
spark.hadoop.fs.s3a.endpoint a3s.fi
spark.hadoop.fs.s3a.access.key ${ACCESS_KEY_ID}
spark.hadoop.fs.s3a.secret.key ${SECRET_ACCESS_KEY}
spark.hadoop.fs.s3a.bucket.all.committer.magic.enabled true
spark.hadoop.fs.s3a.threads.max 20
spark.hadoop.fs.s3a.connection.maximum 20
spark.hadoop.fs.s3a.block.size 128M
spark.hadoop.fs.s3a.ssl.channel.mode openssl
#spark.hadoop.fs.s3a.fast.upload.buffer bytebuffer
spark.hadoop.mapreduce.fileoutputcommitter.algorithm.version 2
spark.hadoop.fs.s3a.directory.marker.retention keep
# S3 optimised parquet options
spark.sql.parquet.aggregatePushdown true
spark.sql.parquet.compression.codec zstd
spark.hadoop.parquet.summary.metadata.level none
spark.hadoop.parquet.writer.version PARQUET_2_0
spark.hadoop.parquet.bloom.filter.enabled true
spark.hadoop.parquet.bloom.filter.adaptive.enabled true
spark.hadoop.parquet.bloom.filter.max.bytes 33554432
spark.sql.parquet.mergeSchema false
spark.sql.hive.metastorePartitionPruning true
# Other parquet options
spark.sql.parquet.datetimeRebaseModeInRead CORRECTED
spark.sql.parquet.datetimeRebaseModeInWrite CORRECTED
spark.sql.parquet.int96RebaseModeInRead CORRECTED
spark.sql.parquet.int96RebaseModeInWrite CORRECTED
# Spark SQL tuning
spark.sql.shuffle.partitions 256
spark.sql.optimizer.canChangeCachedPlanOutputPartitioning true
spark.sql.bucketing.coalesceBucketsInJoin.enabled true
spark.sql.adaptive.coalescePartitions.parallelismFirst false
spark.sql.adaptive.advisoryPartitionSizeInBytes 80MB
spark.sql.adaptive.coalescePartitions.minPartitionSize 16MB
kind: ConfigMap
metadata:
labels:
app: "${APP_NAME}"
name: spark-config
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
app: "${APP_NAME}"
name: "${APP_NAME}-data"
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: "${SHARED_STORAGE_SIZE}"