Cette page vous explique comment activer l'opérateur Ray pour Google Kubernetes Engine (GKE), ce qui vous permet d'utiliser les API KubeRay pour mettre à l'échelle et gérer les clusters Ray. Pour en savoir plus sur Ray et KubeRay, consultez la présentation de Ray sur GKE.
Avant de commencer
Avant de commencer, effectuez les tâches suivantes :
Si vous souhaitez utiliser Google Cloud CLI pour cette tâche, installez puis initialisez gcloud CLI. Si vous avez déjà installé gcloud CLI, assurez-vous de disposer de la dernière version en exécutant la commande gcloud components update.
Activer l'opérateur Ray pour un cluster
Vous pouvez activer l'opérateur Ray sur des clusters GKE Autopilot ou Standard nouveaux ou existants à l'aide de la Google Cloud CLI, de la console Google Cloud ou de Terraform.
Console
Accédez à la page Google Kubernetes Engine dans la console Google Cloud .
VERSION : version de GKE, qui doit être 1.30.0-gke.1747000 ou ultérieure. Vous pouvez également utiliser l'option --release-channel pour sélectionner une version disponible. Le canal de publication doit disposer de la version par défaut 1.30.0-gke.1747000 ou ultérieure.
Vous pouvez activer l'opérateur Ray sur un cluster existant à l'aide de la commande gcloud container clusters update avec l'option --update-addons=RayOperator=ENABLED.
Terraform
L'exemple Terraform suivant crée et configure un cluster Standard :
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/01 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)."]]