开发者社区> 问答> 正文

spark-submit遇到PKIX路径构建失败

我在Google Kubernetes Engine上有集群节点,我做spark-submit来运行一些spark工作。(我没有使用spark-submit,我使用java代码启动提交,但它们本质上是调用相同的Scala类,即SparkSubmit.class)

在我的情况下,我有两个集群,我可以通过使用gcloud命令在我的笔记本电脑上连接。

例如

gcloud container clusters get-credentials cluster-1
gcloud container clusters get-credentials cluster-2
当我连接到cluster-1,并且spark-submit正在提交到cluster-1时,它可以工作。但是,当我运行第二个gcloud命令并仍然提交到cluster-1时,它将无法工作,并显示以下堆栈轨道(删节版本)

io.fabric8.kubernetes.client.KubernetesClientException: Failed to start websocket
at io.fabric8.kubernetes.client.dsl.internal.WatchConnectionManager$2.onFailure(WatchConnectionManager.java:194)
at okhttp3.internal.ws.RealWebSocket.failWebSocket(RealWebSocket.java:543)
at okhttp3.internal.ws.RealWebSocket$2.onFailure(RealWebSocket.java:208)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:148)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:748)
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:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1514)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
我一直在寻找一段时间没有成功。主要问题可能是当spark-submit启动时,它会在本地机器上搜索与Kubernetes相关的某种凭证,并且前两个gcloud命令改变的上下文搞砸了它。

我只是很好奇,当我们做spark提交时,远程K8s服务器到底知道我是谁?什么是auth过程涉及所有这些?

展开
收起
社区小助手 2018-12-12 18:14:52 4935 0
1 条回答
写回答
取消 提交回答
  • 社区小助手是spark中国社区的管理员,我会定期更新直播回顾等资料和文章干货,还整合了大家在钉群提出的有关spark的问题及回答。

    一个PKIX path building failed错误是指的Java试图打开一个SSL连接,但无法找到证书链(路径)用于验证服务器提供的证书。

    您运行的代码不信任群集提供的证书。群集可能使用自签名证书。

    从命令行运行,Java在位于jre / lib / security / cacerts的信任库中查找链。作为更大环境(Tomcat,Glassfish等)的一部分运行,它将使用该环境的证书信任库。

    由于您手动启动spark_submit,因此您可能缺少指定在何处查找密钥库(服务器证书和私钥)和信任库(CA证书)的选项。这些通常指定为:

    -Djavax.net.ssl.trustStore=/somepath/truststore.jks
    -Djavax.net.ssl.keyStore=/somepath/keystore.jks
    如果您在Java 9+上运行,则还需要指定StoreType:

    -Djavax.net.ssl.keyStoreType=
    -Djavax.net.ssl.trustStoreType=
    通过Java 8,密钥库始终是JKS。从Java 9开始,它们也可以是PKCS12。

    对于自签名密钥,您可以从密钥库导出它,并将其作为可信证书导入信任库。

    2019-07-17 23:20:15
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Hybrid Cloud and Apache Spark 立即下载
Scalable Deep Learning on Spark 立即下载
Comparison of Spark SQL with Hive 立即下载