【问题标题】:Apache Spark spark-submit k8s API https ERRORApache Spark spark-提交 k8s API https 错误
【发布时间】:2020-12-17 03:45:45
【问题描述】:

Spark 版本:2.4.4

k8s 版本:1.18

我有一个 Spark 和一个 k8s 集群。

我关注了 Spark 文档:https://spark.apache.org/docs/2.4.4/running-on-kubernetes.html

当我在 k8s 上使用 HTTP 代理提交作业时:一切正常。

但是在 k8s 上使用本机 HTTPS API 我得到了这个错误:

以前我必须将 k8s API 证书导入我的主 Spark(keytool)。

internal.WatchConnectionManager: Exec Failure: HTTP 403, Status: 403 - pods "spark-pi-1598541432880-driver" is forbidden: User "system:anonymous" cannot watch resource "pods" in API group "" in the namespace "default"
java.net.ProtocolException: Expected HTTP 101 response but was '403 Forbidden'
    at okhttp3.internal.ws.RealWebSocket.checkResponse(RealWebSocket.java:216)
    at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:183)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:141)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

这很好奇,因为没有匿名用户。

我已经尝试将“匿名”用户添加到 k8s,但没有任何效果。

如果我尝试不导入 API 证书,我会收到此错误:

Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:198)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1967)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:331)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:325)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1688)

我提交作业的命令:

-bash-4.2$ spark-submit --master k8s://https://ip:port  --deploy-mode cluster --name spark-pi --class org.apache.spark.examples.SparkPi --conf spark.executor.instances=3 --conf spark.kubernetes.authenticate.driver.serviceAccountName=spark --conf spark.kubernetes.container.image=docker.io/spawnxx/spark:fink-test-2 hdfs://hdfs_ip/user/sacha.pateyron/spark-examples_2.11-2.4.4.jar 1000

Apache Spark 本身不支持 K8s https API(所以我必须导入证书)?

有什么想法吗?

【问题讨论】:

  • 集群是否配置了身份验证代理? http代理有什么作用?
  • 没有。我使用 k8s http 代理只是为了避免使用 https TLS API。

标签: java api apache-spark kubernetes https


【解决方案1】:

解决方案:

HTTPS k8s API 使用证书和令牌进行身份验证。

首先下载k8s HTTPS API:

在主火花上->

echo -n|openssl s_client -connect ip_master_k8s:port_https_api|openssl x509 -outform PEM > selfsigned_certificate.pem

在 k8s 主机上获取 spark 令牌:

kubectl get secret

kubectl describe secret spark-token-XXX

然后在 Spark master 上我们提交一个带有证书和令牌的作业:

spark-submit --master k8s://https://ip_master_k8s:port_https_api  --deploy-mode cluster --name spark-pi --class org.apache.spark.examples.SparkPi --conf spark.executor.instances=3 --conf spark.kubernetes.authenticate.driver.serviceAccountName=spark --conf spark.kubernetes.container.image=your_image --conf spark.kubernetes.authenticate.submission.caCertFile=selfsigned_certificate.pem --conf spark.kubernetes.authenticate.submission.oauthToken=spark-token-XXX hdfs://ip_master_hdfs/my_jar

【讨论】:

    猜你喜欢
    • 2016-09-07
    • 1970-01-01
    • 2022-12-31
    • 1970-01-01
    • 2015-09-01
    • 1970-01-01
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多