Search code examples
google-cloud-platformgoogle-cloud-dataproc

Add shutdown script to Dataproc instance


I am creating Dataproc clusters via REST API (of ZEPPELIN type). Before shutdown I would like to copy some setting to GS (for example Interpreter instance) and then load it after startup. Initialization part is easy with initializationActions option, but I can't find any option to set some script that will be executed on one of the nodes just before shutdown. Computation instance itself contains such option (https://cloud.google.com/compute/docs/shutdownscript) but how to integrate it with cluster creation via REST API?

Should I perform additional REST call like https://cloud.google.com/compute/docs/startupscript#startupscriptrunninginstances after cluster is created?


Solution

  • The Dataproc create API can take the GCE metadata as well. You set metadata through ClusterConfig.GceClusterConfig

    In your case it would be key: "shutdown-script", value: "content of the script".