Search code examples
apache-flinkflink-streaming

Flink - How to pass custom parameter when submitting Flink job through REST API


I need to provide a decrypted password in a Flink job to connect it to redis. But the redis password can only be decrypted on a local machine. So my plan is to decrypt it locally first and then try to pass it to Flink when submitting the job through REST API. (I'm not allowed to write the decrypted password to the properties file.)

Is this possible? I noticed that I can specify programArgs and programArgsList in the JSON POST request. However, I'm not finding any means to access these parameters inside my program.

I have checked StreamExecutionEnvironment.getExecutionEnvironment().getConfig(), but the parameters are not saved there.

Is there any way to access the parameters which I submitted with the job? Or are there better ways to achieve the same goal?


Solution

  • They are Java program arguments:

    public static void main (String[] args) {
    
    }
    

    You'll have them in the args array. The documentation mentions it in here: https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/datastream/application_parameters/#from-the-command-line-arguments