Skip to content

Commit

Permalink
Add support for Ray Operator on GKE (#11145) (#18825)
Browse files Browse the repository at this point in the history
[upstream:78b6e94c2527e11e0011805e7b61fcd2cd7d427e]

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Jul 24, 2024
1 parent 8711aaa commit 17e5778
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/11145.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
container: added field `ray_operator_config` for `resource_container_cluster`
```
87 changes: 87 additions & 0 deletions google/services/container/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ var (
"addons_config.0.config_connector_config",
"addons_config.0.gcs_fuse_csi_driver_config",
"addons_config.0.stateful_ha_config",
"addons_config.0.ray_operator_config",
}

privateClusterConfigKeys = []string{
Expand Down Expand Up @@ -477,6 +478,52 @@ func ResourceContainerCluster() *schema.Resource {
},
},
},
"ray_operator_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
AtLeastOneOf: addonsConfigKeys,
MaxItems: 3,
Description: `The status of the Ray Operator addon, which enabled management of Ray AI/ML jobs on GKE. Defaults to disabled; set enabled = true to enable.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
},
"ray_cluster_logging_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `The status of Ray Logging, which scrapes Ray cluster logs to Cloud Logging. Defaults to disabled; set enabled = true to enable.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
},
},
},
},
"ray_cluster_monitoring_config": {
Type: schema.TypeList,
Optional: true,
Computed: true,
MaxItems: 1,
Description: `The status of Ray Cluster monitoring, which shows Ray cluster metrics in Cloud Console. Defaults to disabled; set enabled = true to enable.`,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Required: true,
},
},
},
},
},
},
},
},
},
},
Expand Down Expand Up @@ -4124,6 +4171,28 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig {
}
}

if v, ok := config["ray_operator_config"]; ok && len(v.([]interface{})) > 0 {
addon := v.([]interface{})[0].(map[string]interface{})
ac.RayOperatorConfig = &container.RayOperatorConfig{
Enabled: addon["enabled"].(bool),
ForceSendFields: []string{"Enabled"},
}
if v, ok := addon["ray_cluster_logging_config"]; ok && len(v.([]interface{})) > 0 {
loggingConfig := v.([]interface{})[0].(map[string]interface{})
ac.RayOperatorConfig.RayClusterLoggingConfig = &container.RayClusterLoggingConfig{
Enabled: loggingConfig["enabled"].(bool),
ForceSendFields: []string{"Enabled"},
}
}
if v, ok := addon["ray_cluster_monitoring_config"]; ok && len(v.([]interface{})) > 0 {
loggingConfig := v.([]interface{})[0].(map[string]interface{})
ac.RayOperatorConfig.RayClusterMonitoringConfig = &container.RayClusterMonitoringConfig{
Enabled: loggingConfig["enabled"].(bool),
ForceSendFields: []string{"Enabled"},
}
}
}

return ac
}

Expand Down Expand Up @@ -5177,6 +5246,24 @@ func flattenClusterAddonsConfig(c *container.AddonsConfig) []map[string]interfac
},
}
}
if c.RayOperatorConfig != nil {
rayConfig := c.RayOperatorConfig
result["ray_operator_config"] = []map[string]interface{}{
{
"enabled": rayConfig.Enabled,
},
}
if rayConfig.RayClusterLoggingConfig != nil {
result["ray_operator_config"].([]map[string]any)[0]["ray_cluster_logging_config"] = []map[string]interface{}{{
"enabled": rayConfig.RayClusterLoggingConfig.Enabled,
}}
}
if rayConfig.RayClusterMonitoringConfig != nil {
result["ray_operator_config"].([]map[string]any)[0]["ray_cluster_monitoring_config"] = []map[string]interface{}{{
"enabled": rayConfig.RayClusterMonitoringConfig.Enabled,
}}
}
}

return []map[string]interface{}{result}
}
Expand Down
15 changes: 15 additions & 0 deletions google/services/container/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4475,6 +4475,9 @@ resource "google_container_cluster" "primary" {
initial_node_count = 1
min_master_version = "latest"
release_channel {
channel = "RAPID"
}
workload_identity_config {
workload_pool = "${data.google_project.project.project_id}.svc.id.goog"
Expand Down Expand Up @@ -4514,6 +4517,9 @@ resource "google_container_cluster" "primary" {
stateful_ha_config {
enabled = false
}
ray_operator_config {
enabled = false
}
}
deletion_protection = false
network = "%s"
Expand Down Expand Up @@ -4574,6 +4580,15 @@ resource "google_container_cluster" "primary" {
}
stateful_ha_config {
enabled = true
}
ray_operator_config {
enabled = true
ray_cluster_logging_config {
enabled = true
}
ray_cluster_monitoring_config {
enabled = true
}
}
}
deletion_protection = false
Expand Down
14 changes: 14 additions & 0 deletions website/docs/r/container_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,20 @@ Fleet configuration for the cluster. Structure is [documented below](#nested_fle
The status of the Stateful HA addon, which provides automatic configurable failover for stateful applications.
It is disabled by default for Standard clusters. Set `enabled = true` to enable.

* `ray_operator_config` - (Optional). The status of the [Ray Operator
addon](https://cloud.google.com/kubernetes-engine/docs/add-on/ray-on-gke/concepts/overview).
It is disabled by default. Set `enabled = true` to enable. The minimum
cluster version to enable Ray is 1.30.0-gke.1747000.

Ray Operator config has optional subfields
`ray_cluster_logging_config.enabled` and
`ray_cluster_monitoring_config.enabled` which control Ray Cluster logging
and monitoring respectively. See [Collect and view logs and metrics for Ray
clusters on
GKE](https://cloud.google.com/kubernetes-engine/docs/add-on/ray-on-gke/how-to/collect-view-logs-metrics)
for more information.


This example `addons_config` disables two addons:

```hcl
Expand Down

0 comments on commit 17e5778

Please sign in to comment.