Preparing for Security Authentication
Scenario
In a cluster with the security mode enabled, the components must be mutually authenticated before communicating with each other to ensure communication security.
To submit a Flink application, you need to ensure that Flink can communicate with Yarn and HDFS. Security authentication needs to be configured for the Flink application to be submitted.
Flink supports authentication and encrypted transmission. This section describes how to prepare for the authentication and encrypted transmission.
Security Authentication
Flink supports the following authentication modes:
- Kerberos authentication is used between Flink Yarn client and Yarn ResourceManager, JobManager and ZooKeeper, JobManager and HDFS, TaskManager and HDFS, Kafka and TaskManager, and TaskManager and ZooKeeper.
- Security cookie authentication is used between Flink Yarn client and JobManager, JobManager and TaskManager, and TaskManager and TaskManager.
- Internal authentication of Yarn is used between Yarn ResourceManager and ApplicationMaster (AM).
- Flink JobManager and Yarn ApplicationMaster are in the same process.
- If security mode is enabled, you must use the Kerberos authentication and security cookie authentication.
Authentication Mode |
Configuration Method |
---|---|
Kerberos authentication (Currently, only keytab is supported.) |
|
Security cookie authentication |
|
Internal authentication of Yarn |
You do not need to do any configuration for this authentication mode. |
One Flink cluster belongs to only one user. One user can create multiple Flink clusters.
Encrypted Transmission
Flink supports the following encrypted transmission:
- Encrypted transmission inside Yarn is used between Flink Yarn client and Yarn ResourceManager, and Yarn ResourceManager and JobManager.
- SSL transmission is used between Flink Yarn client and JobManager, JobManager and TaskManager, and TaskManager and TaskManager.
- Internal encrypted transmission of Hadoop is used between JobManager and HDFS, TaskManager and HDFS, JobManager and ZooKeeper, and TaskManager and ZooKeeper.
You do not need to do any configurations for internal encryption of Yarn and Hadoop. Only SSL configuration is required.
To configure SSL encrypted transmission, perform the following steps to configure the flink-conf.yaml file on the client:
- Turn on the SSL switch and set SSL encryption algorithms. Table 2 describes the parameters. Set the parameters based on your need.
Table 2 Parameters Parameter
Example Value
Description
security.ssl.enabled
true
Enabling the SSL function
akka.ssl.enabled
true
Enabling Akka SSL
blob.service.ssl.enabled
true
Enabling SSL for the BLOB channel
taskmanager.data.ssl.enabled
true
Enabling SSL for communications between TaskManagers
security.ssl.algorithms
TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
Setting SSL encryption algorithms
Enabling SSL for data transmission between TaskManagers may lead to a drop of system performance.
- In the bin directory of the Flink client, run sh generate_keystore.sh <password>. For details, see Authentication and Encryption. The configuration items in Table 3 are set by default, you can set these parameters as needed.
Table 3 Parameters Parameter
Example Value
Description
security.ssl.keystore
${path}/flink.keystore
Path for storing the keystore. flink.keystore indicates the name of the keystore file generated by the generate_keystore.sh* tool.
security.ssl.keystore-password
-
A user-defined password of keystore.
security.ssl.key-password
-
A user-defined password of the SSL key.
security.ssl.truststore
${path}/flink.truststore
Path for storing the truststore. flink.truststore indicates the name of the truststore file generated by the generate_keystore.sh* tool.
security.ssl.truststore-password
-
A user-defined password of truststore.
- If the keystore or truststore file path is a relative path, the Flink client directory where the command is executed needs to access this relative path directly. Either of the following method can be used to transmit the keystore and truststore file:
- Add -t option to the CLI yarn-session.sh command of Flink to transmit the KeyStore and TrustStore files to each execution node. The following is an example:
cd /opt/client/Flink/flink
./bin/yarn-session.sh -t ssl/
- Add -yt to the flink run command to transfer the keystore and truststore file to execution nodes. The following is an example:
./bin/flink run -yt ssl/ -ys 3 -m yarn-cluster -c com.huawei.SocketWindowWordCount ../lib/flink-eg-1.0.jar --hostname r3-d3 --port 9000
- In the example, ssl/ is a user-defined subdirectory in the Flink client directory, which is used to store configuration files of the SSL keystore and truststore.
- The relative path of ssl/ must be accessible from the current path where the Flink client command is run.
- Add -t option to the CLI yarn-session.sh command of Flink to transmit the KeyStore and TrustStore files to each execution node. The following is an example:
- If the keystore or truststore file path is an absolute path, the keystore and truststore files must exist in the absolute path on Flink Client and Yarn nodes.
Either of the following methods can be used to execute applications. The -t or -yt option does not need to be added to transmit the keystore and truststore files.
- Run the CLI yarn-session.sh command of Flink to execute applications. The following is an example command:
./bin/yarn-session.sh
- Run the flink run command to execute applications. The following is an example command:
./bin/flink run -ys 3 -m yarn-cluster -c com.huawei.SocketWindowWordCount ../lib/flink-eg-1.0.jar --hostname r3-d3 --port 9000
- Run the CLI yarn-session.sh command of Flink to execute applications. The following is an example command:
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot