We are trying to move from using spark-submit to a programmatic solution using SparkLauncher (Spark 2.4 running on Cloudera Hadoop), and have encountered this problem:
Exception javax.security.auth.login.LoginException: Cannot locate KDC
on the error output stream of a job process after calling startApplication().
The launcher is configured with the same settings as spark-submit, including setting "spark.kerberos.principal" and "spark.kerberos.keytab" (also tried using the spark.yarn prefix, and setting --principle and --keytab with setSparkArg() as well - but these properties are not the issue).
Even though krb5.conf is in the default location on all machines and the driver, I tried setting
.setConf("spark.executor.extraJavaOptions", "-Djava.security.krb5.conf=/etc/krb5.conf")
.setConf("spark.driver.extraJavaOptions", "-Djava.security.krb5.conf=/etc/krb5.conf")
as well, with the same result.
There are no other auth/kerberos-related conf settings with the spark-submit call (only principal and keytab are set), and all other conf settings are replicated on the Launcher.
The output from SparkLauncher confirms all Spark properties are set as expected.
"Cannot locate KDC" indicates that the krb5.conf file is not found, but how can this be if it's in the default location and spark-submit evidently finds it?
kinit <principal_name> -kt <path_to_keytab_file>
and see how it goes. – Syam Sankar-Djava.security.debug=gssloginconfig,configfile,configparser,logincontext
might explain what happens exacty when JAAS tries to connect to the KDC. – Samson Scharfrichter-Dsun.security.krb5.debug=true
if you are not afraid of huge amounts of cryptical stuff. – Samson Scharfrichter