flink on yarn的情况下配置的keytab文件会根据每次yarn application 分配taskmanager的变化都是不一样的,在部分场景下用户代码也需要获得keytab文件在yarn上的本地路径,可以通过以下方式拿到文件地址。
代码语言:javascript复制 final Map<String, String> ENV = System.getenv();
final String currDir = ENV.get("PWD");
log.info("Current working/local Directory: {}", currDir);
String keytabPath = null;
File f = new File(currDir, "krb5.keytab");
keytabPath = f.getAbsolutePath();
log.info("local keytab path: {}", keytabPath);
final String remoteKeytabPrincipal = ENV.get("_KEYTAB_PRINCIPAL");
log.info("TM: remote keytab principal obtained {}", remoteKeytabPrincipal);