Utilizzare i selettori di cluster con i flussi di lavoro
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
In alternativa all'esecuzione di un workflow su un cluster gestito, puoi utilizzare un selettore di cluster per scegliere un cluster esistente per il tuo workflow. Al termine del workflow, il cluster selezionato non viene eliminato.
I selettori specificano una o più
etichette utente Dataproc.
I cluster nella stessa
regione del workflow le cui etichette
corrispondono a tutte le etichette del selettore sono idonei per l'esecuzione dei job del workflow. Se più cluster corrispondono al selettore, Dataproc sceglierà il cluster con la maggior quantità di memoria YARN libera.
Aggiungere un selettore di cluster a un modello
Puoi aggiungere un selettore di cluster a un modello di flusso di lavoro utilizzando
Google Cloud CLI o l'API Dataproc.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eCluster selectors allow workflows to run on existing clusters instead of managed clusters, and the selected cluster is not deleted post-workflow.\u003c/p\u003e\n"],["\u003cp\u003eSelectors use Dataproc user labels to identify eligible clusters within the same region as the workflow, and Dataproc chooses the cluster with the most free YARN memory if multiple clusters match.\u003c/p\u003e\n"],["\u003cp\u003eYou can add a cluster selector to a workflow template using either the Google Cloud CLI or the Dataproc API, with options to set specific cluster labels.\u003c/p\u003e\n"],["\u003cp\u003eAutomatically-applied cluster labels like \u003ccode\u003egoog-dataproc-cluster-name\u003c/code\u003e and \u003ccode\u003egoog-dataproc-cluster-uuid\u003c/code\u003e can be used to point a cluster selector to an existing cluster.\u003c/p\u003e\n"],["\u003cp\u003eClusters with matching labels can be used to create cluster pools, and the workflow template can select a cluster within that pool based on the applied labels.\u003c/p\u003e\n"]]],[],null,["As an alternative to running a workflow on a\n[managed cluster](/dataproc/docs/concepts/workflows/using-workflows#configuring_or_selecting_a_cluster), you can use a\ncluster selector to choose an existing cluster for your workflow. At the\nconclusion of the workflow, the selected cluster is not deleted.\n\nSelectors specify one or more\n[Dataproc user labels](/dataproc/docs/concepts/labels).\nClusters in same\n[region](/compute/docs/regions-zones#available) as the workflow whose labels\nmatch all of the selector labels are eligible to run workflow jobs. If multiple\nclusters match the selector, Dataproc will\nchoose the cluster with the most free YARN memory.\n\nAdd a cluster selector to a template\n\nYou can add a cluster selector to a workflow template using the\nGoogle Cloud CLI or the Dataproc API. \n\ngcloud command \n\n```\ngcloud dataproc workflow-templates set-cluster-selector template-id \\\n --region=region \\\n --cluster-labels=name=value[[,name=value]...]\n```\n\nREST API See [WorkflowTemplatePlacement.ClusterSelector](/dataproc/docs/reference/rest/v1/projects.locations.workflowTemplates#clusterselector). This field is provided as part of a completed [WorkflowTemplate](/dataproc/docs/reference/rest/v1/projects.regions.workflowTemplates#resource-workflowtemplate) submitted with a [workflowTemplates.create](/dataproc/docs/reference/rest/v1/projects.regions.workflowTemplates/create) or [workflowTemplates.update](/dataproc/docs/reference/rest/v1/projects.regions.workflowTemplates/update) request.\n\nConsole\n\nYou can view existing workflow templates and instantiated workflows from\nthe Dataproc\n[**Workflows**](https://console.cloud.google.com/dataproc/workflows/instances) page in Google Cloud console.\n\nUse automatically applied labels\n\nYou can point a cluster selector to an existing cluster by using\none of the following [automatically-applied cluster labels](/dataproc/docs/concepts/labels#automatically-applied_labels):\n\n- `goog-dataproc-cluster-name`\n- `goog-dataproc-cluster-uuid`\n\n**Example:** \n\n```\ngcloud dataproc workflow-templates set-cluster-selector template-id \\\n --region=region \\\n --cluster-labels=goog-dataproc-cluster-name=my-cluster\n```\n\n\u003cbr /\u003e\n\nSelect from a cluster pool\n\nYou can let Dataproc choose a cluster from a pool of clusters.\nThe cluster pools can be defined with labels.\n\n**Example:** \n\n```\ngcloud dataproc clusters create cluster-1 --labels cluster-pool=pool-1 \\\n --region=\u003cvar translate=\"no\"\u003eregion\u003c/var\u003e\ngcloud dataproc clusters create cluster-2 --labels cluster-pool=pool-1 \\\n --region=\u003cvar translate=\"no\"\u003eregion\u003c/var\u003e\ngcloud dataproc clusters create cluster-3 --labels cluster-pool=pool-2 \\\n --region=\u003cvar translate=\"no\"\u003eregion\u003c/var\u003e\n```\n\nAfter cluster creation ... \n\n```\ngcloud dataproc workflow-templates create my-template \\\n --region=\u003cvar translate=\"no\"\u003eregion\u003c/var\u003e\ngcloud dataproc workflow-templates set-cluster-selector my-template \\\n --region=\u003cvar translate=\"no\"\u003eregion\u003c/var\u003e \\\n --cluster-labels=cluster-pool=pool-1\n```\n\nThe workflow will be run on either cluster-1 or cluster-2, but not on cluster-3."]]