我的目标是设置 configmap,然后在 spark 应用程序中使用配置文件。以下是详细信息:
我有一个如下所示的配置文件 (test_config.cfg):
[test_tracker]
url = http://localhost:8080/testsomething/
username = TEST
password = SECRET
我通过运行以下命令创建了配置映射:
kubectl create configmap testcfg1 --from-file test_config.cfg
现在,我有一个 YAML 文件 (testprog.yaml),其 SparkApplication 规范如下所示:
apiVersion: "sparkoperator.k8s.io/v1beta2"
kind: SparkApplication
metadata:
name: testprog
namespace: default
spec:
type: Python
pythonVersion: "3"
mode: cluster
image: "<ip-url>:5000/schemamatcher/schemamatcher-spark-py:latest"
imagePullPolicy: Always
mainApplicationFile: local:///opt/spark/dependencies/testprog.py
arguments: ['s3a://f1.parquet', 's3a://f2.parquet', '--tokenizer-type', 'param']
sparkVersion: "3.0.0"
restartPolicy:
type: OnFailure
onFailureRetries: 3
onFailureRetryInterval: 10
onSubmissionFailureRetries: 5
onSubmissionFailureRetryInterval: 20
driver:
cores: 1
coreLimit: "1200m"
memory: "16g"
labels:
version: 3.0.0
serviceAccount: default
configMaps:
- name: testcfg1
path: /mnt/config-maps
executor:
cores: 1
instances: 2
memory: "20g"
labels:
version: 3.0.0
hadoopConf:
"fs.s3a.access.key": minio
"fs.s3a.secret.key": minio123
"fs.s3a.endpoint": http://<ip-url>:9000
现在,我可以使用以下方式运行该程序:
kubectl apply -f testprog.yaml
pod 运行良好,没有抛出任何错误。但是我无法在给定的路径上看到我的配置文件,我不明白为什么。 当 pod 正在执行时,我会这样做:
kubectl exec --stdin --tty test-driver -- /bin/bash
然后我尝试在路径/mnt/config-maps 中查找配置文件,但我没有看到任何东西。我尝试了几件事但没有运气。此外,一些文档说应该设置 mutation webhook,我认为之前的人已经做到了,但我不确定如何检查它(但我认为它在那里)。
任何帮助都会很棒,因为我是新手而且我仍在学习 k8s。
更新: 也试过像这样更新规范并运行但仍然没有运气。
volumes:
- name: config
configMap:
name: testcfg1
driver:
cores: 1
coreLimit: "1200m"
memory: "16g"
labels:
version: 3.0.0
serviceAccount: default
volumeMounts:
- name: config
mountPath: /opt/spark
executor:
cores: 1
instances: 2
memory: "20g"
labels:
version: 3.0.0
volumeMounts:
- name: config
mountPath: /opt/spark
最佳答案
不确定这个问题是否在 Spark v3.0.0(您似乎正在使用)中得到解决,但 Kubernetes 上的 Spark 中存在一个错误,该错误阻止了 ConfigMaps 的正确安装。请参阅此讨论:https://stackoverflow.com/a/58508313/8570169
关于python-3.x - 无法在运行 Sparkapplication 的 pod 上使用 configmap 挂载配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66450175/