이전에 만든 워크플로 템플릿 리소스를 인스턴스화하는 표준 워크플로와 달리 인라인 워크플로는 YAML 파일 또는 삽입된 WorkflowTemplate 정의를 사용하여 워크플로를 실행합니다.
인라인 워크플로 만들기 및 실행
YAML 파일을 사용하여 워크플로 인스턴스화를 참조하세요.
요청 데이터를 사용하기 전에 다음을 바꿉니다.
- project-id: Google Cloud 프로젝트 ID
- region : 클러스터 리전(예: 'us-central1')
- zoneUri: Dataproc 자동 영역 배치를 사용하려면 클러스터 리전(예: 'us-central1-b')에 zone를 지정하거나 비워 둡니다("").
- clusterName: 클러스터 이름
HTTP 메서드 및 URL:
POST https://dataproc.googleapis.com/v1/projects/project-id /regions/region /workflowTemplates:instantiateInline
JSON 요청 본문:
{ "jobs": [ { "hadoopJob": { "mainJarFileUri": "file:///usr/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar", "args": [ "teragen", "1000", "hdfs:///gen/" ] }, "stepId": "teragen" }, { "hadoopJob": { "mainJarFileUri": "file:///usr/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar", "args": [ "terasort", "hdfs:///gen/", "hdfs:///sort/" ] }, "stepId": "terasort", "prerequisiteStepIds": [ "teragen" ] } ], "placement": { "managedCluster": { "clusterName": "cluster-name ", "config": { "gceClusterConfig": { "zoneUri": "zone " } } } } }
요청을 보내려면 다음 옵션 중 하나를 펼칩니다.
cURL(Linux, macOS, Cloud Shell)
요청 본문을 request.json
파일에 저장하고 다음 명령어를 실행합니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://dataproc.googleapis.com/v1/projects/project-id /regions/region /workflowTemplates:instantiateInline"
PowerShell(Windows)
요청 본문을 request.json
파일에 저장하고 다음 명령어를 실행합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://dataproc.googleapis.com/v1/projects/project-id /regions/region /workflowTemplates:instantiateInline" | Select-Object -Expand Content
다음과 비슷한 JSON 응답이 표시됩니다.
{ "name": "projects/project-id/regions/region/operations/2fbd0dad-...", "metadata": { "@type": "type.googleapis.com/google.cloud.dataproc.v1.WorkflowMetadata", "graph": { "nodes": [ { "stepId": "teragen", "state": "RUNNABLE" }, { "stepId": "terasort", "prerequisiteStepIds": [ "teragen" ], "state": "BLOCKED" } ] }, "state": "PENDING", "startTime": "2020-04-02T22:50:44.826Z" } }
현재 Google Cloud 콘솔에서는 인라인 워크플로 생성이 지원되지 않습니다. 워크플로 템플릿 및 인스턴스화된 워크플로는 Dataproc 워크플로 페이지에서 볼 수 있습니다.