如何在 Spark on YARN 中为 Spark UI 创建安全过滤器

How to create security filter for Spark UI in Spark on YARN

环境: AWS EMR,yarn 集群。

描述: 我正在尝试使用 java 过滤器来保护对 spark ui 的访问,这是通过使用 属性 spark.ui.filters;问题是,当 spark 在纱线模式下 运行 时,属性 总是被 hadoop 使用过滤器 org.apache.hadoop.yarn.server.webproxy.amfilter.AmIpFilter:

覆盖
spark.ui.filters: org.apache.hadoop.yarn.server.webproxy.amfilter.AmIpFilter

这两个参数是haddoop自动传递的

spark.org.apache.hadoop.yarn.server.webproxy.amfilter.AmIpFilter.param.PROXY_HOSTS: ip-x-x-x-226.eu-west-1.compute.internal

spark.org.apache.hadoop.yarn.server.webproxy.amfilter.AmIpFilter.param.PROXY_URI_BASES: http://ip-x-x-x-226.eu-west-1.compute.internal:20888/proxy/application_xxxxxxxxxxxxx_xxxx

关于如何添加 java 安全过滤器以使 hadoop 不覆盖它,或者如何从 hadoop 端配置安全性的任何建议?

谢谢。

这可以通过使用 属性 hadoop.http.authentication.type 来解决 指定包含身份验证的自定义 Java 处理程序对象 逻辑。 class 只需执行 界面 org.apache.hadoop.security.authentication.server.AuthenticationHandler。 参见:

https://hadoop.apache.org/docs/r2.7.3/hadoop-project-dist/hadoop-common/HttpAuthentication.html