On a Flink standalone cluster, running on a server, I am developing a Flink streaming job in Scala. The job consumes data from more than 1 Kafka topics, (do some formatting,) and write results to HDFS.
One of the Kafka topic, and HDFS, they both require separate Kerberos authentications (because they belong to completely different clusters).
My questions are:
security.kerberos.login.keytab
and security.kerberos.login.principal
in flink-conf.yaml
Manually switching the Kerberos authentication between the two principals was possible. In [realm] section in krb5.conf
file, I specified two realms, one for Kafka, the other for HDFS.
kinit -kt path/to/hdfs.keytab [principal: xxx@XXX.XXX...]
kinit -kt path/to/kafka.keytab [principal: yyy@YYY.YYY...]
Thanks for your attentions and feedbacks!
After three years from my initial post, our architecture has moved from standalone bare metal server to Docker container on Mesos, but let me summarize the workaround (for Flink 1.8):
Place krb5.conf
with all realm definitions and domain-realm mappings (for example under /etc/
of the container)
Place Hadoop krb5.keytab
(for example under /kerberos/HADOOP_CLUSTER.ORG.EXAMPLE.COM/
)
Configure Flink's security.kerberos.login.*
properties in flink-conf.yaml
security.kerberos.login.use-ticket-cache: true
security.kerberos.login.principal: username@HADOOP_CLUSTER.ORG.EXAMPLE.COM
security.kerberos.login.contexts
should not be configured. This ensures that Flink does not use Hadoop’s credentials for Kafka and Zookeeper.Copy keytabs for Kafka into separate directories inside the container (for example under /kerberos/KAFKA_CLUSTER.ORG.EXAMPLE.COM/
)
Periodically run custom script to renew ticket cache
KINIT_COMMAND_1='kinit -kt /kerberos/HADOOP_CLUSTER.ORG.EXAMPLE.COM/krb5.keytab username@HADOOP_CLUSTER.ORG.EXAMPLE.COM'
KINIT_COMMAND_2='kinit -kt /kerberos/KAFKA_CLUSTER.ORG.EXAMPLE.COM/krb5.keytab username@KAFKA_CLUSTER.ORG.EXAMPLE.COM -c /tmp/krb5cc_kafka'
...
sasl.jaas.config
when instantiating each FlinkKafkaConsumer to the actual JAAS configuration string.
props.setProperty("sasl.jaas.config",
"com.sun.security.auth.module.Krb5LoginModule required " +
"refreshKrb5Config=true " +
"useKeyTab=true " +
"storeKey=true " +
"debug=true " +
"keyTab=\"/kerberos/KAFKA_CLUSTER.ORG.EXAMPLE.COM/krb5.keytab\" " +
"principal=\"username@KAFKA_CLUSTER.ORG.EXAMPLE.COM\";")