Apache Spark的spark-submit k8s API https报错
创始人
2024-09-04 21:30:51
0

在使用Apache Spark的spark-submit k8s API时,如果遇到https报错,可能是由于证书验证失败导致的。以下是解决方法的示例代码:

  1. 禁用证书验证:
from pyspark.sql import SparkSession
from pyspark.conf import SparkConf

# 创建SparkSession
spark = SparkSession.builder \
    .appName("spark-submit k8s API with https") \
    .config("spark.kubernetes.authenticate.caCertFile", "/path/to/ca-certificate") \
    .config("spark.kubernetes.authenticate.clientKeyFile", "/path/to/client-key") \
    .config("spark.kubernetes.authenticate.clientCertFile", "/path/to/client-certificate") \
    .config("spark.kubernetes.authenticate.driver.serviceAccountName", "spark") \
    .config("spark.kubernetes.authenticate.submission.caCertFile", "/path/to/ca-certificate") \
    .config("spark.kubernetes.authenticate.submission.clientKeyFile", "/path/to/client-key") \
    .config("spark.kubernetes.authenticate.submission.clientCertFile", "/path/to/client-certificate") \
    .config("spark.kubernetes.authenticate.submission.oauthToken", "your-oauth-token") \
    .config("spark.kubernetes.authenticate.submission.oauthTokenFile", "/path/to/oauth-token-file") \
    .config("spark.kubernetes.authenticate.submission.oauthTokenSecret", "your-oauth-token-secret") \
    .config("spark.kubernetes.authenticate.submission.oauthTokenSecretFile", "/path/to/oauth-token-secret-file") \
    .config("spark.kubernetes.authenticate.submission.ssl.enabled", "false") \  # 禁用SSL验证
    .getOrCreate()

# 使用SparkSession执行Spark作业
df = spark.read.csv("/path/to/input/file.csv")
df.show()
  1. 添加自定义证书:
from pyspark.sql import SparkSession
from pyspark.conf import SparkConf

# 创建SparkSession
spark = SparkSession.builder \
    .appName("spark-submit k8s API with https") \
    .config("spark.kubernetes.authenticate.caCertFile", "/path/to/ca-certificate") \
    .config("spark.kubernetes.authenticate.clientKeyFile", "/path/to/client-key") \
    .config("spark.kubernetes.authenticate.clientCertFile", "/path/to/client-certificate") \
    .config("spark.kubernetes.authenticate.driver.serviceAccountName", "spark") \
    .config("spark.kubernetes.authenticate.submission.caCertFile", "/path/to/ca-certificate") \
    .config("spark.kubernetes.authenticate.submission.clientKeyFile", "/path/to/client-key") \
    .config("spark.kubernetes.authenticate.submission.clientCertFile", "/path/to/client-certificate") \
    .config("spark.kubernetes.authenticate.submission.oauthToken", "your-oauth-token") \
    .config("spark.kubernetes.authenticate.submission.oauthTokenFile", "/path/to/oauth-token-file") \
    .config("spark.kubernetes.authenticate.submission.oauthTokenSecret", "your-oauth-token-secret") \
    .config("spark.kubernetes.authenticate.submission.oauthTokenSecretFile", "/path/to/oauth-token-secret-file") \
    .config("spark.kubernetes.authenticate.submission.ssl.enabled", "true") \
    .config("spark.kubernetes.authenticate.submission.ssl.caCertFile", "/path/to/custom-ca-certificate") \  # 添加自定义CA证书
    .config("spark.kubernetes.authenticate.submission.ssl.keyFile", "/path/to/custom-key") \  # 添加自定义私钥
    .config("spark.kubernetes.authenticate.submission.ssl.certFile", "/path/to/custom-certificate") \  # 添加自定义证书
    .getOrCreate()

# 使用SparkSession执行Spark作业
df = spark.read.csv("/path/to/input/file.csv")
df.show()

请根据实际情况修改上述代码中的证书文件路径和其他配置参数。

相关内容

热门资讯

热门推荐!微信小程序多功能辅助... 热门推荐!微信小程序多功能辅助,盛世辅助器,详细app(有挂神器)1、实时微信小程序多功能辅助透视辅...
最新技巧!黑科技微乐小程序辅助... 最新技巧!黑科技微乐小程序辅助器免费,随意玩工具箱辅助器,详细教程(真是有挂)1、点击下载安装,黑科...
盘点十款!乐乐围棋入门辅助,小... 盘点十款!乐乐围棋入门辅助,小程序游戏赴沪期,详细app(有挂教学)1、首先打开小程序游戏赴沪期辅助...
实操分享!新超凡手游辅助,雀友... 实操分享!新超凡手游辅助,雀友会广东潮汕麻雀万能辅助器,详细挂(有挂教程)1、全新机制【雀友会广东潮...
一起来探讨!纳祥游戏脚本,微信... 一起来探讨!纳祥游戏脚本,微信小程序辅助工具,详细攻略(有挂解惑)1、这是跨平台的微信小程序辅助工具...
一分钟揭秘!新八戒辅助,挂是真... 一分钟揭秘!新八戒辅助,挂是真的假的,详细器(确实有挂)1、全新机制【挂是真的假的ai辅助工具激活码...
最新通报!微信小程序微乐房间怎... 最新通报!微信小程序微乐房间怎么开挂,打哈儿床将辅助最新,详细软件(有挂技巧)1、全新机制【微信小程...
玩家实测!欢乐达人暗堡破解,赣... 您好,欢乐达人暗堡破解这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩...
一分钟揭秘!情怀手机麻将辅助器... 一分钟揭秘!情怀手机麻将辅助器,功夫川麻辅助,详细工具(详细教程)1、金币登录送、破产送、升级送、活...
今日科普!微信广东雀神挂件辅助... 今日科普!微信广东雀神挂件辅助,对战互娱辅助系统,详细神器(有挂规律);1、下载好微信广东雀神挂件辅...