Available on: >= 0.17.0

Run tasks as containers on Google Cloud Run.

The containerImage property is required because Cloud Run executes tasks as containers. You can use any image from a public or private registry.

To use inputFiles, outputFiles or namespaceFiles properties, make sure to set the bucket property. The bucket serves as an intermediary storage layer for the task runner. Input and namespace files will be uploaded to the cloud storage bucket before the task run. Similarly, the task runner will store outputFiles in this bucket during the task run. In the end, the task runner will make those files available for download and preview from the UI by sending them to internal storage. To make it easier to track where all files are stored, the task runner will generate a folder for each task run. You can access that folder using the {{bucketPath}} Pebble expression or the BUCKET_PATH environment variable.

Due to the ephemeral nature of Cloud Run, the task runner will not run the task in the working directory but in the root directory. Therefore, you have to use the {{workingDir}} Pebble expression or the WORKING_DIR environment variable to access the inputFiles and namespaceFiles from the task's working directory. Similarly, you can use the {{outputDir}} Pebble expression or the OUTPUT_DIR environment variable when generating outputFiles.

Examples

The following example runs a simple Shell command in a Cloud Run container:

yaml
id: new-shell
namespace: myteam

tasks:
  - id: shell
    type: io.kestra.plugin.scripts.shell.Commands
    taskRunner:
      type: io.kestra.plugin.gcp.runner.GcpCloudRunTaskRunner
      projectId: "{{vars.projectId}}"
      region: "{{vars.region}}"
    commands:
    - echo "Hello World"

The following example runs a Shell command in a Cloud Run container and passes input files to the task:

yaml
id: new-shell-with-file
namespace: myteam

inputs:
  - id: file
    type: FILE

tasks:
  - id: shell
    type: io.kestra.plugin.scripts.shell.Commands
    inputFiles:
      data.txt: "{{inputs.file}}"
    outputFiles:
      - out.txt
    containerImage: centos
    taskRunner:
      type: io.kestra.plugin.gcp.runner.GcpCloudRunTaskRunner
      projectId: "{{vars.projectId}}"
      region: "{{vars.region}}"
      bucket: "{{vars.bucker}}"
    commands:
    - cp {{workingDir}}/data.txt {{workingDir}}/out.txt

Was this page helpful?