From a1073b1ec0699624147ea38f2f135a0671fbfe0d Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 9 Jul 2022 20:18:42 +0300 Subject: [PATCH 1/8] notebooks --- mmv1/products/notebooks/api.yaml | 43 +++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/mmv1/products/notebooks/api.yaml b/mmv1/products/notebooks/api.yaml index 4f836d4819fb..31cc58817b16 100644 --- a/mmv1/products/notebooks/api.yaml +++ b/mmv1/products/notebooks/api.yaml @@ -293,7 +293,6 @@ objects: - UNSPECIFIED_NIC_TYPE - VIRTIO_NET - GVNIC - min_version: beta - !ruby/object:Api::Type::NestedObject name: 'reservationAffinity' description: | @@ -317,7 +316,6 @@ objects: description: | Corresponds to the label values of reservation resource. item_type: Api::Type::String - min_version: beta - !ruby/object:Api::Type::String name: 'state' description: | @@ -342,6 +340,7 @@ objects: - PD_STANDARD - PD_SSD - PD_BALANCED + - PD_EXTREME description: | Possible disk types for notebook instances. - !ruby/object:Api::Type::Integer @@ -357,6 +356,7 @@ objects: - PD_STANDARD - PD_SSD - PD_BALANCED + - PD_EXTREME description: | Possible disk types for notebook instances. - !ruby/object:Api::Type::Integer @@ -370,6 +370,11 @@ objects: name: 'noRemoveDataDisk' description: | If true, the data disk will not be auto deleted when deleting the instance. + - !ruby/object:Api::Type::Boolean + name: 'canIpForward' + default_value: false + description: | + Flag to enable ip forwarding or not, default false/off. - !ruby/object:Api::Type::Enum name: 'diskEncryption' values: @@ -856,12 +861,16 @@ objects: description: | The config settings for accessing runtime. properties: - - !ruby/object:Api::Type::String + - !ruby/object:Api::Type::Enum name: 'accessType' description: | The type of access mode this instance. For valid values, see `https://cloud.google.com/vertex-ai/docs/workbench/reference/ rest/v1/projects.locations.runtimes#RuntimeAccessType`. + values: + - RUNTIME_ACCESS_TYPE_UNSPECIFIED + - SINGLE_USER + - SERVICE_ACCOUNT - !ruby/object:Api::Type::String name: 'runtimeOwner' description: | @@ -902,6 +911,10 @@ objects: name: "installGpuDriver" description: | Install Nvidia Driver automatically. + - !ruby/object:Api::Type::Boolean + name: "upgradeable" + description: | + Bool indicating whether an newer image is available in an image family. - !ruby/object:Api::Type::String name: "customGpuDriverPath" description: | @@ -913,6 +926,30 @@ objects: Path to a Bash script that automatically runs after a notebook instance fully boots up. The path must be a URL or Cloud Storage path (gs://path-to-file/file-name). + - !ruby/object:Api::Type::Enum + name: 'postStartupScriptBehavior' + values: + - POST_STARTUP_SCRIPT_BEHAVIOR_UNSPECIFIED + - RUN_EVERY_START + - DOWNLOAD_AND_RUN_EVERY_START + description: | + Behavior for the post startup script. + - !ruby/object:Api::Type::Array + name: 'kernels' + description: | + Use a list of container images to use as Kernels in the notebook instance. + item_type: !ruby/object:Api::Type::NestedObject + properties: + - !ruby/object:Api::Type::String + name: 'repository' + description: | + The path to the container image repository. + For example: gcr.io/{project_id}/{imageName} + required: true + - !ruby/object:Api::Type::String + name: 'tag' + description: | + The tag of the container image. If not specified, this defaults to the latest tag. - !ruby/object:Api::Type::NestedObject name: "metrics" description: | From 4f795446c0e86d6ac6891fffa060ff8f675d0d26 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Tue, 12 Jul 2022 20:05:32 +0300 Subject: [PATCH 2/8] rebase --- mmv1/products/notebooks/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/notebooks/api.yaml b/mmv1/products/notebooks/api.yaml index 31cc58817b16..5e3b3102a9e9 100644 --- a/mmv1/products/notebooks/api.yaml +++ b/mmv1/products/notebooks/api.yaml @@ -913,6 +913,7 @@ objects: Install Nvidia Driver automatically. - !ruby/object:Api::Type::Boolean name: "upgradeable" + output: true description: | Bool indicating whether an newer image is available in an image family. - !ruby/object:Api::Type::String From 6ce1e25c91ae573281dcf0faf6d183251aa9c198 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 23 Jul 2022 21:10:52 +0300 Subject: [PATCH 3/8] revert --- mmv1/products/notebooks/api.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/mmv1/products/notebooks/api.yaml b/mmv1/products/notebooks/api.yaml index 5e3b3102a9e9..e0df4f50e92c 100644 --- a/mmv1/products/notebooks/api.yaml +++ b/mmv1/products/notebooks/api.yaml @@ -861,16 +861,12 @@ objects: description: | The config settings for accessing runtime. properties: - - !ruby/object:Api::Type::Enum + - !ruby/object:Api::Type::String name: 'accessType' description: | The type of access mode this instance. For valid values, see `https://cloud.google.com/vertex-ai/docs/workbench/reference/ - rest/v1/projects.locations.runtimes#RuntimeAccessType`. - values: - - RUNTIME_ACCESS_TYPE_UNSPECIFIED - - SINGLE_USER - - SERVICE_ACCOUNT + rest/v1/projects.locations.runtimes#RuntimeAccessType`. - !ruby/object:Api::Type::String name: 'runtimeOwner' description: | From c433a753ed057515a5ea5f6bc7afec88da6f40ba Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 23 Jul 2022 21:12:23 +0300 Subject: [PATCH 4/8] space --- mmv1/products/notebooks/api.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/products/notebooks/api.yaml b/mmv1/products/notebooks/api.yaml index e0df4f50e92c..cd48451f2c7a 100644 --- a/mmv1/products/notebooks/api.yaml +++ b/mmv1/products/notebooks/api.yaml @@ -866,7 +866,7 @@ objects: description: | The type of access mode this instance. For valid values, see `https://cloud.google.com/vertex-ai/docs/workbench/reference/ - rest/v1/projects.locations.runtimes#RuntimeAccessType`. + rest/v1/projects.locations.runtimes#RuntimeAccessType`. - !ruby/object:Api::Type::String name: 'runtimeOwner' description: | From 75e65d0d369d15c7c3d9ddf21ce3ddaa7c1c06d1 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 23 Jul 2022 21:25:33 +0300 Subject: [PATCH 5/8] add forward example --- mmv1/products/notebooks/terraform.yaml | 8 ++++++++ .../examples/notebook_instance_forward_ip.tf.erb | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 mmv1/templates/terraform/examples/notebook_instance_forward_ip.tf.erb diff --git a/mmv1/products/notebooks/terraform.yaml b/mmv1/products/notebooks/terraform.yaml index 60cee664e2b3..ac7525ba665a 100644 --- a/mmv1/products/notebooks/terraform.yaml +++ b/mmv1/products/notebooks/terraform.yaml @@ -58,6 +58,14 @@ overrides: !ruby/object:Overrides::ResourceOverrides instance_name: "notebooks-instance" test_env_vars: service_account: :SERVICE_ACCT + - !ruby/object:Provider::Terraform::Examples + name: "notebook_instance_forward_ip" + skip_docs: true + primary_resource_id: "instance" + primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-instance%s\", context[\"random_suffix\"])" + region_override: "us-west1-a" + vars: + instance_name: "notebooks-instance" description: | {{description}} diff --git a/mmv1/templates/terraform/examples/notebook_instance_forward_ip.tf.erb b/mmv1/templates/terraform/examples/notebook_instance_forward_ip.tf.erb new file mode 100644 index 000000000000..5885b9942399 --- /dev/null +++ b/mmv1/templates/terraform/examples/notebook_instance_forward_ip.tf.erb @@ -0,0 +1,10 @@ +resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" { + name = "<%= ctx[:vars]["instance_name"] %>" + location = "us-west1-a" + machine_type = "e2-medium" + vm_image { + project = "deeplearning-platform-release" + image_family = "tf-latest-cpu" + } + can_forward_ip = true +} From b4e91f9fecea1ba11d6a3056e1430d1119f75d91 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 23 Jul 2022 21:45:19 +0300 Subject: [PATCH 6/8] remove ip forward --- mmv1/products/notebooks/api.yaml | 7 +------ mmv1/products/notebooks/terraform.yaml | 10 +--------- .../examples/notebook_instance_forward_ip.tf.erb | 10 ---------- 3 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 mmv1/templates/terraform/examples/notebook_instance_forward_ip.tf.erb diff --git a/mmv1/products/notebooks/api.yaml b/mmv1/products/notebooks/api.yaml index cd48451f2c7a..00cf1a1d5c0c 100644 --- a/mmv1/products/notebooks/api.yaml +++ b/mmv1/products/notebooks/api.yaml @@ -369,12 +369,7 @@ objects: - !ruby/object:Api::Type::Boolean name: 'noRemoveDataDisk' description: | - If true, the data disk will not be auto deleted when deleting the instance. - - !ruby/object:Api::Type::Boolean - name: 'canIpForward' - default_value: false - description: | - Flag to enable ip forwarding or not, default false/off. + If true, the data disk will not be auto deleted when deleting the instance. - !ruby/object:Api::Type::Enum name: 'diskEncryption' values: diff --git a/mmv1/products/notebooks/terraform.yaml b/mmv1/products/notebooks/terraform.yaml index ac7525ba665a..36b47cda1165 100644 --- a/mmv1/products/notebooks/terraform.yaml +++ b/mmv1/products/notebooks/terraform.yaml @@ -57,15 +57,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides vars: instance_name: "notebooks-instance" test_env_vars: - service_account: :SERVICE_ACCT - - !ruby/object:Provider::Terraform::Examples - name: "notebook_instance_forward_ip" - skip_docs: true - primary_resource_id: "instance" - primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-instance%s\", context[\"random_suffix\"])" - region_override: "us-west1-a" - vars: - instance_name: "notebooks-instance" + service_account: :SERVICE_ACCT description: | {{description}} diff --git a/mmv1/templates/terraform/examples/notebook_instance_forward_ip.tf.erb b/mmv1/templates/terraform/examples/notebook_instance_forward_ip.tf.erb deleted file mode 100644 index 5885b9942399..000000000000 --- a/mmv1/templates/terraform/examples/notebook_instance_forward_ip.tf.erb +++ /dev/null @@ -1,10 +0,0 @@ -resource "google_notebooks_instance" "<%= ctx[:primary_resource_id] %>" { - name = "<%= ctx[:vars]["instance_name"] %>" - location = "us-west1-a" - machine_type = "e2-medium" - vm_image { - project = "deeplearning-platform-release" - image_family = "tf-latest-cpu" - } - can_forward_ip = true -} From 885ccc18500604119b2d57a8e986f04e81da2c50 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 23 Jul 2022 22:07:33 +0300 Subject: [PATCH 7/8] add test --- mmv1/products/notebooks/api.yaml | 2 +- mmv1/products/notebooks/terraform.yaml | 9 ++++++- .../examples/notebook_runtime_kernels.tf.erb | 25 +++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 mmv1/templates/terraform/examples/notebook_runtime_kernels.tf.erb diff --git a/mmv1/products/notebooks/api.yaml b/mmv1/products/notebooks/api.yaml index 00cf1a1d5c0c..f53088a3b335 100644 --- a/mmv1/products/notebooks/api.yaml +++ b/mmv1/products/notebooks/api.yaml @@ -369,7 +369,7 @@ objects: - !ruby/object:Api::Type::Boolean name: 'noRemoveDataDisk' description: | - If true, the data disk will not be auto deleted when deleting the instance. + If true, the data disk will not be auto deleted when deleting the instance. - !ruby/object:Api::Type::Enum name: 'diskEncryption' values: diff --git a/mmv1/products/notebooks/terraform.yaml b/mmv1/products/notebooks/terraform.yaml index 36b47cda1165..6655081a8acf 100644 --- a/mmv1/products/notebooks/terraform.yaml +++ b/mmv1/products/notebooks/terraform.yaml @@ -57,7 +57,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides vars: instance_name: "notebooks-instance" test_env_vars: - service_account: :SERVICE_ACCT + service_account: :SERVICE_ACCT description: | {{description}} @@ -136,6 +136,13 @@ overrides: !ruby/object:Overrides::ResourceOverrides region_override: "us-central1" vars: runtime_name: "notebooks-runtime-container" + - !ruby/object:Provider::Terraform::Examples + name: "notebook_runtime_kernels" + primary_resource_id: "runtime_container" + primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-runtime-container%s\", context[\"random_suffix\"])" + region_override: "us-central1" + vars: + runtime_name: "notebooks-runtime-kernel" description: | {{description}} diff --git a/mmv1/templates/terraform/examples/notebook_runtime_kernels.tf.erb b/mmv1/templates/terraform/examples/notebook_runtime_kernels.tf.erb new file mode 100644 index 000000000000..d97313a6bbff --- /dev/null +++ b/mmv1/templates/terraform/examples/notebook_runtime_kernels.tf.erb @@ -0,0 +1,25 @@ +resource "google_notebooks_runtime" "<%= ctx[:primary_resource_id] %>" { + name = "<%= ctx[:vars]["runtime_name"] %>" + location = "us-central1" + access_config { + access_type = "SINGLE_USER" + runtime_owner = "admin@hashicorptest.com" + } + software_config { + kernels { + repository = "gcr.io/deeplearning-platform-release/base-cpu" + tag = "latest" + } + } + virtual_machine { + virtual_machine_config { + machine_type = "n1-standard-4" + data_disk { + initialize_params { + disk_size_gb = "100" + disk_type = "PD_STANDARD" + } + } + } + } +} From 582e519c9f77eb6b2bca51210f1c202cd8528bff Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Sat, 23 Jul 2022 22:14:53 +0300 Subject: [PATCH 8/8] startup behaviour --- mmv1/products/notebooks/terraform.yaml | 9 +++++++- .../examples/notebook_runtime_script.tf.erb | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 mmv1/templates/terraform/examples/notebook_runtime_script.tf.erb diff --git a/mmv1/products/notebooks/terraform.yaml b/mmv1/products/notebooks/terraform.yaml index 6655081a8acf..264ff5c4a2e7 100644 --- a/mmv1/products/notebooks/terraform.yaml +++ b/mmv1/products/notebooks/terraform.yaml @@ -142,7 +142,14 @@ overrides: !ruby/object:Overrides::ResourceOverrides primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-runtime-container%s\", context[\"random_suffix\"])" region_override: "us-central1" vars: - runtime_name: "notebooks-runtime-kernel" + runtime_name: "notebooks-runtime-kernel" + - !ruby/object:Provider::Terraform::Examples + name: "notebook_runtime_script" + primary_resource_id: "runtime_container" + primary_resource_name: "fmt.Sprintf(\"tf-test-notebooks-runtime-container%s\", context[\"random_suffix\"])" + region_override: "us-central1" + vars: + runtime_name: "notebooks-runtime-script" description: | {{description}} diff --git a/mmv1/templates/terraform/examples/notebook_runtime_script.tf.erb b/mmv1/templates/terraform/examples/notebook_runtime_script.tf.erb new file mode 100644 index 000000000000..d9320d924dbd --- /dev/null +++ b/mmv1/templates/terraform/examples/notebook_runtime_script.tf.erb @@ -0,0 +1,22 @@ +resource "google_notebooks_runtime" "<%= ctx[:primary_resource_id] %>" { + name = "<%= ctx[:vars]["runtime_name"] %>" + location = "us-central1" + access_config { + access_type = "SINGLE_USER" + runtime_owner = "admin@hashicorptest.com" + } + software_config { + post_startup_script_behavior = "RUN_EVERY_START" + } + virtual_machine { + virtual_machine_config { + machine_type = "n1-standard-4" + data_disk { + initialize_params { + disk_size_gb = "100" + disk_type = "PD_STANDARD" + } + } + } + } +}