Nesta página, mostramos como ativar o operador Ray para o Google Kubernetes Engine (GKE),
para que seja possível usar as APIs do KubeRay ao escalonar e gerenciar os clusters do Ray. Para mais
informações sobre o Ray e o KubeRay, consulte
Visão geral do Ray no GKE.
Antes de começar
Antes de começar, verifique se você realizou as seguintes tarefas:
Se você quiser usar a CLI do Google Cloud para essa tarefa,
instale e, em seguida,
inicialize a
CLI gcloud. Se você instalou a gcloud CLI anteriormente, instale a versão
mais recente executando gcloud components update.
Ativar o operador Ray para um cluster
É possível ativar o operador Ray em clusters novos ou atuais do Autopilot
ou do GKE Standard usando a Google Cloud CLI, o console Google Cloud
ou o Terraform.
Console
Acesse a página do Google Kubernetes Engine no Google Cloud console.
VERSION: a versão do GKE, que precisa
ser 1.30.0-gke.1747000 ou mais recente. Também é possível usar a
opção --release-channel para selecionar um canal de lançamento. O
canal de lançamento precisa ter como versão padrão a 1.30.0-gke.1747000 ou
uma versão mais recente.
É possível ativar o operador Ray em um cluster atual usando o comando
gcloud container clusters update
com a opção --update-addons=RayOperator=ENABLED.
Terraform
O exemplo do Terraform a seguir cria e configura um cluster padrão:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-01 UTC."],[],[],null,["# Enable the Ray operator on Google Kubernetes Engine (GKE)\n\n[Autopilot](/kubernetes-engine/docs/concepts/autopilot-overview) [Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\nThis page shows you how to enable the Ray operator for Google Kubernetes Engine (GKE),\nletting you use the KubeRay APIs to scale and manage Ray clusters. For more\ninformation on Ray and KubeRay, see\n[Ray on GKE overview](/kubernetes-engine/docs/add-on/ray-on-gke/concepts/overview).\n\nBefore you begin\n----------------\n\nBefore you start, make sure that you have performed the following tasks:\n\n- Enable the Google Kubernetes Engine API.\n[Enable Google Kubernetes Engine API](https://console.cloud.google.com/flows/enableapi?apiid=container.googleapis.com)\n- If you want to use the Google Cloud CLI for this task, [install](/sdk/docs/install) and then [initialize](/sdk/docs/initializing) the gcloud CLI. If you previously installed the gcloud CLI, get the latest version by running `gcloud components update`. **Note:** For existing gcloud CLI installations, make sure to set the `compute/region` [property](/sdk/docs/properties#setting_properties). If you use primarily zonal clusters, set the `compute/zone` instead. By setting a default location, you can avoid errors in the gcloud CLI like the following: `One of [--zone, --region] must be supplied: Please specify location`. You might need to specify the location in certain commands if the location of your cluster differs from the default that you set.\n\nEnable the Ray operator for a cluster\n-------------------------------------\n\nYou can enable the Ray operator on new or existing Autopilot or\nStandard GKE clusters using the Google Cloud CLI, the Google Cloud console,\nor Terraform. \n\n### Console\n\n1. Go to the **Google Kubernetes Engine** page in the Google Cloud console.\n\n [Go to Google Kubernetes Engine](https://console.cloud.google.com/kubernetes/list)\n2. Click add_box **Create** then in the Standard or Autopilot section, click **Configure**.\n\n3. For Standard, from the navigation pane, under **Cluster** , click **Features** . For Autopilot, click **Advanced Settings**.\n\n4. In the **AI and Machine Learning** section, select the **Enable Ray Operator**\n checkbox.\n\n5. Click **Create**.\n\n### gcloud\n\nCreate a cluster using the `--addons=RayOperator` option: \n\n gcloud container clusters create \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e \\\n --cluster-version=\u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e \\\n --addons=RayOperator\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e: the name of the new cluster.\n- \u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e: the GKE version, which must be 1.30.0-gke.1747000 or later. You can also use the `--release-channel` option to select a release channel. The release channel must have a default version of 1.30.0-gke.1747000 or later.\n\nYou can enable the Ray operator on an existing cluster by using the\n[`gcloud container clusters update`](/sdk/gcloud/reference/container/clusters/update)\ncommand with option `--update-addons=RayOperator=ENABLED`.\n\n### Terraform\n\nThe following Terraform example creates and configures a Standard\ncluster: \n\n resource \"google_container_cluster\" \"default\" {\n name = \"gke-standard-regional-ray-operator\"\n location = \"us-west1\"\n\n initial_node_count = 1\n\n release_channel {\n channel = \"RAPID\"\n }\n\n addons_config {\n ray_operator_config {\n enabled = true\n ray_cluster_logging_config {\n enabled = true\n }\n ray_cluster_monitoring_config {\n enabled = true\n }\n }\n }\n }\n\nTo learn more about using Terraform, see\n[Terraform support for GKE](/kubernetes-engine/docs/resources/use-terraform-gke).\n\nVersioning\n----------\n\nThe Ray Operator is available in the following GKE minor versions with a corresponding KubeRay version:\n\nVerify the Ray operator is enabled\n----------------------------------\n\nYou can verify that the Ray operator is enabled on an Autopilot or\nStandard GKE cluster using the gcloud CLI or\nthe Google Cloud console. \n\n### Console\n\n1. Go to the **Google Kubernetes Engine** page in the Google Cloud console.\n\n [Go to Google Kubernetes Engine](https://console.cloud.google.com/kubernetes/list)\n2. In the cluster list, click the name of the cluster that you want to\n verify.\n\n3. In the **Features** section, confirm that the **Ray Operator** checkbox is\n selected.\n\n### gcloud\n\nDescribe your cluster: \n\n gcloud container clusters describe \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e\n\nReplace \u003cvar translate=\"no\"\u003eCLUSTER_NAME\u003c/var\u003e with the name of the cluster.\n\nThe output is similar to the following \n\n # Several lines omitted\n addonsConfig:\n rayOperatorConfig:\n enabled: true\n\nThis output indicates that the Ray operator is enabled for the cluster.\n\nWhat's next\n-----------\n\n- Learn about [Ray on Kubernetes](https://docs.ray.io/en/latest/cluster/kubernetes/index.html).\n- Learn how to [collect and view logs and metrics for Ray clusters](/kubernetes-engine/docs/add-on/ray-on-gke/how-to/collect-view-logs-metrics).\n- Explore the [KubeRay documentation](https://docs.ray.io/en/latest/cluster/kubernetes/getting-started.html)."]]