示例中的
./bin/docker-image-tool.sh -r <repo> -t my-tag build
./bin/docker-image-tool.sh -r <repo> -t my-tag push
<repo> 具体到 某个命名空间
例如registry.cn-beijing.aliyuncs.com/xxx
其中xxx
是 阿里云容器服务的命名空间
提交时如果 driver pod日志出现 getURL错误,大概是提交的jars 路径有问题,写绝对路径,且driver要访问到。
./bin/spark-submit \
--master k8s://https://<k8s-apiserver-host>:<k8s-apiserver-port> \
--deploy-mode cluster \
--name spark-pi \
--class org.apache.spark.examples.SparkPi \
--conf spark.executor.instances=5 \
--conf spark.kubernetes.container.image=<spark-image> \
local:///path/to/examples.jar
local
代表 本地文件系统,jar路径是容器里的绝对路径。
如果出现 driver没有权限 创建pods ,stackflow
Create a serviceaccount
kubectl create serviceaccount spark
Give the service account the edit role on the cluster
kubectl create clusterrolebinding spark-role --clusterrole=edit --serviceaccount=default:spark --namespace=default
Run spark submit with the following flag, in order to run it with the (just created(service account)
--conf spark.kubernetes.authenticate.driver.serviceAccountName=spark
问题
driver无法创建 executor pods,提示 CPU不足,memory不足,把节点换成4cpu 16GB memory的ecs,k8s对Node节点有最低要求。
若上传本地jar包
file:///home/zhuchuang/Documents/spark-3.0.1-bin-hadoop2.7/examples/jars/spark-examples_2.12-3.0.1.jar
以file 开头,且注意 上传目录--conf spark.kubernetes.file.upload.path=oss://dpai-01/tmp
。
log初始化出错的话,可能是submit 的版本和容器spark的版本不匹配。
以client模式提交或者使用spark-shell连接 k8s集群,需要client 与k8s 的的容器能连上,executors要能够连接到 client的ip。
所以最好client和k8s在同一局域网下,可能可以设置路由解决这个问题?