Konektor untuk Cloud Run

Konektor Workflows yang menentukan fungsi bawaan yang digunakan untuk mengakses Cloud Run dalam alur kerja.

Jelajahi lebih lanjut

Untuk dokumentasi mendetail yang menyertakan contoh kode ini, lihat artikel berikut:

Contoh kode

YAML

# This workflow demonstrates how to use the the Cloud Run connector to create
# a new service and then deletes it. Note that the location has to be specified.
# Expected successful output: delete operation's response

- init:
    assign:
      - service_name: "test-service"
      - project: "your-project-id"
- create_service:
    call: googleapis.run.v1.namespaces.services.create
    args:
      location: "us-central1"
      parent: ${"namespaces/" + project}
      body:
        apiVersion: "serving.knative.dev/v1"
        kind: "Service"
        metadata:
          name: ${service_name}
          namespace: ${project}
        spec:
          traffic:
            latest_revision: true
            percent: 100
          template:
            metadata:
              labels:
                serving.knative.dev/type: "container"
            spec:
              containers:
                - image: "us-docker.pkg.dev/cloudrun/container/hello:latest"
    result: create_rsp
- get_service:
    call: googleapis.run.v1.namespaces.services.get
    args:
      name: ${"namespaces/" + project + "/services/" + service_name}
      location: "us-central1"
    result: get_resp
- delete_service:
    call: googleapis.run.v1.namespaces.services.delete
    args:
      location: "us-central1"
      name: ${"namespaces/" + project + "/services/" + service_name}
    result: delete_rsp
- return:
    return: ${delete_rsp}

Langkah selanjutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat browser contoh Google Cloud.