-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate_clustermode_podspec.sh
executable file
·64 lines (63 loc) · 1.6 KB
/
generate_clustermode_podspec.sh
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
#!/usr/bin/env bash
cat > clustermode-podspec-with-rbac.yaml << EOF
apiVersion: v1
kind: ServiceAccount
metadata:
name: spark
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: spark-cluster-role
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["get", "watch", "list", "create", "delete"]
- apiGroups: [""] # "" indicates the core API group
resources: ["services"]
verbs: ["get", "create", "delete"]
- apiGroups: [""] # "" indicates the core API group
resources: ["configmaps"]
verbs: ["get", "create", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: spark-cluster-role-binding
subjects:
- kind: ServiceAccount
name: spark
namespace: default
roleRef:
kind: ClusterRole
name: spark-cluster-role
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: Pod
metadata:
name: spark-submit-example
spec:
serviceAccountName: spark
containers:
- name: spark-submit-example
args:
- /opt/spark/bin/spark-submit
- --master
- k8s://https://\$(KUBERNETES_PORT_443_TCP_ADDR):\$(KUBERNETES_PORT_443_TCP_PORT)
- --deploy-mode
- cluster
- --conf
- spark.kubernetes.container.image=$(./get_image_name.sh spark)
- --conf
- spark.kubernetes.authenticate.driver.serviceAccountName=spark
- --class
- org.apache.spark.examples.SparkPi
- local:///opt/spark/examples/jars/spark-examples_2.11-2.4.4.jar
env:
- name: SPARK_HOME
value: /opt/spark
resources: {}
image: $(./get_image_name.sh spark):latest
imagePullPolicy: Always
EOF