Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for boost configs in workstations configs #10176

Merged
merged 10 commits into from
Mar 19, 2024
39 changes: 39 additions & 0 deletions mmv1/products/workstations/WorkstationConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ examples:
vars:
workstation_cluster_name: 'workstation-cluster'
workstation_config_name: 'workstation-config'
- !ruby/object:Provider::Terraform::Examples
name: 'workstation_config_boost'
min_version: beta
primary_resource_id: 'default'
vars:
workstation_cluster_name: 'workstation-cluster'
workstation_config_name: 'workstation-config'
- !ruby/object:Provider::Terraform::Examples
name: 'workstation_config_encryption_key'
min_version: beta
Expand Down Expand Up @@ -213,6 +220,7 @@ properties:
- 'host.gceInstance.shieldedInstanceConfig.enableIntegrityMonitoring'
- 'host.gceInstance.confidentialInstanceConfig.enableConfidentialCompute'
- 'host.gceInstance.accelerators'
- 'host.gceInstance.boostConfigs'
- 'host.gceInstance.disableSsh'
properties:
- !ruby/object:Api::Type::NestedObject
Expand Down Expand Up @@ -319,6 +327,37 @@ properties:
description: |
Number of accelerator cards exposed to the instance.
required: true
- !ruby/object:Api::Type::Array
name: 'boostConfigs'
description: |
A list of the boost configurations that workstations created using this workstation configuration are allowed to use.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: 'id'
description: |
The id to be used for the boost config.
required: true
- !ruby/object:Api::Type::String
name: 'machineType'
description: |
The type of machine that boosted VM instances will use. Defaults to `e2-standard-4`.
joelkattapuram marked this conversation as resolved.
Show resolved Hide resolved
- !ruby/object:Api::Type::Array
name: 'accelerators'
description: |
An accelerator card attached to the boost instance.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: 'type'
description: |
Type of accelerator resource to attach to the instance, for example, "nvidia-tesla-p100".
required: true
- !ruby/object:Api::Type::Integer
name: 'count'
description: |
Number of accelerator cards exposed to the instance.
required: true
joelkattapuram marked this conversation as resolved.
Show resolved Hide resolved
- !ruby/object:Api::Type::Array
name: 'persistentDirectories'
description: |
Expand Down
56 changes: 56 additions & 0 deletions mmv1/templates/terraform/examples/workstation_config_boost.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
resource "google_compute_network" "default" {
provider = google-beta
name = "<%= ctx[:vars]['workstation_cluster_name'] %>"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "default" {
provider = google-beta
name = "<%= ctx[:vars]['workstation_cluster_name'] %>"
ip_cidr_range = "10.0.0.0/24"
region = "us-central1"
network = google_compute_network.default.name
}

resource "google_workstations_workstation_cluster" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
workstation_cluster_id = "<%= ctx[:vars]['workstation_cluster_name'] %>"
network = google_compute_network.default.id
subnetwork = google_compute_subnetwork.default.id
location = "us-central1"

labels = {
"label" = "key"
}

annotations = {
label-one = "value-one"
}
}

resource "google_workstations_workstation_config" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta
workstation_config_id = "<%= ctx[:vars]['workstation_config_name'] %>"
workstation_cluster_id = google_workstations_workstation_cluster.<%= ctx[:primary_resource_id] %>.workstation_cluster_id
location = "us-central1"

host {
gce_instance {
machine_type = "e2-standard-4"
boot_disk_size_gb = 35
disable_public_ip_addresses = true
boost_configs {
id = "boost-1"
machine_type = "n1-standard-2"
accelerators {
type = "nvidia-tesla-t4"
count = "1"
}
}
boost_configs {
id = "boost-1"
machine_type = "e2-standard-2"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,80 @@ func testAccWorkstationsWorkstationConfig_serviceAccount(context map[string]inte
`, context)
}

func TestAccWorkstationsWorkstationConfig_boost(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
CheckDestroy: testAccCheckWorkstationsWorkstationConfigDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccWorkstationsWorkstationConfig_boost(context),
},
{
ResourceName: "google_workstations_workstation_cluster.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"etag"},
},
},
joelkattapuram marked this conversation as resolved.
Show resolved Hide resolved
})
}

func testAccWorkstationsWorkstationConfig_boost(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_compute_network" "default" {
provider = google-beta
name = "tf-test-workstation-cluster%{random_suffix}"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "default" {
provider = google-beta
name = "tf-test-workstation-cluster%{random_suffix}"
ip_cidr_range = "10.0.0.0/24"
region = "us-central1"
network = google_compute_network.default.name
}

resource "google_workstations_workstation_cluster" "default" {
provider = google-beta
workstation_cluster_id = "tf-test-workstation-cluster%{random_suffix}"
network = google_compute_network.default.id
subnetwork = google_compute_subnetwork.default.id
location = "us-central1"
}

resource "google_workstations_workstation_config" "default" {
provider = google-beta
workstation_config_id = "tf-test-workstation-config%{random_suffix}"
workstation_cluster_id = google_workstations_workstation_cluster.default.workstation_cluster_id
location = "us-central1"
host {
gce_instance {
boost_configs {
id = "boost-1"
machine_type = "n1-standard-2"
accelerators {
type = "nvidia-tesla-t4"
count = "1"
joelkattapuram marked this conversation as resolved.
Show resolved Hide resolved
}
}
boost_configs {
id = "boost-1"
machine_type = "e2-standard-2"
}
}
}
}
`, context)
}

func TestAccWorkstationsWorkstationConfig_disableTcpConnections(t *testing.T) {
t.Parallel()

Expand Down