Skip to content

Commit

Permalink
GCLOUD2-17975: add description and examples for gpu cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
IsabellaMerkulova committed Feb 27, 2025
1 parent 83af2de commit 947eda7
Show file tree
Hide file tree
Showing 11 changed files with 294 additions and 127 deletions.
6 changes: 3 additions & 3 deletions docs/data-sources/ai_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
page_title: "gcore_ai_cluster Data Source - terraform-provider-gcore"
subcategory: ""
description: |-
Represent AI Cluster
Represent GPU Cluster
---

# gcore_ai_cluster (Data Source)

Represent AI Cluster
Represent GPU Cluster

## Example Usage

Expand Down Expand Up @@ -64,7 +64,7 @@ output "view" {
- `interface` (List of Object) Networks managed by user and associated with the cluster (see [below for nested schema](#nestedatt--interface))
- `keypair_name` (String) Ssh keypair name
- `password` (String) A password for baremetal instance. This parameter is used to set a password for the Admin user on a Windows instance, a default user or a new user on a Linux instance
- `poplar_servers` (List of Object) Poplar servers (see [below for nested schema](#nestedatt--poplar_servers))
- `poplar_servers` (List of Object) GPU cluster servers list (see [below for nested schema](#nestedatt--poplar_servers))
- `security_group` (Set of Object) Security groups attached to the cluster (see [below for nested schema](#nestedatt--security_group))
- `task_id` (String) Task ID associated with the cluster
- `task_status` (String) Task status
Expand Down
135 changes: 99 additions & 36 deletions docs/resources/ai_cluster.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,104 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gcore_ai_cluster Resource - terraform-provider-gcore"
subcategory: ""
description: |-
Represent instance
Represent GPU cluster
---

# gcore_ai_cluster (Resource)

Represent instance
Represent GPU cluster

## Example Usage

##### Prerequisite

```terraform
provider gcore {
permanent_api_token = "251$d3361.............1b35f26d8"
}
resource "gcore_ai_cluster" "cluster1" {
region_id = 10
project_id = 15
flavor = "g2a-ai-fake-v1pod-8"
image_id = "f6aa6e75-ab88-4c19-889d-79133366cb83"
cluster_name = "cluster1"
keypair_name = "front"
volume {
source = "image"
image_id = "f6aa6e75-ab88-4c19-889d-79133366cb83"
volume_type = "standard"
size = 20
}
data "gcore_project" "project" {
name = "Default"
}
data "gcore_region" "region" {
name = "Luxembourg-2"
}
resource "gcore_network" "network" {
name = "my-network"
type = "vlan"
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}
resource "gcore_subnet" "subnet" {
name = "my-subnet"
cidr = "192.168.10.0/24"
network_id = gcore_network.network.id
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}
resource "gcore_keypair" "keypair" {
project_id = data.gcore_project.project.id
sshkey_name = "my-keypair"
public_key = "ssh-ed25519 ...your public key... [email protected]"
}
```

### Basic example

#### Creating GPU cluster of one node with one public interface and metadata provided

```terraform
resource "gcore_ai_cluster" "gpu_cluster" {
flavor = "bm3-ai-1xlarge-h100-80-8"
image_id = "37c4fa17-1f18-4904-95f2-dbf39d0318fe"
cluster_name = "my-gpu-cluster"
keypair_name = "my-keypair"
instances_count = 1
interface {
type = "external"
type = "external"
}
cluster_metadata = {
my-metadata-key = "my-metadata-value"
}
security_group {
id = "4c74142d-9374-4aa6-b11b-43469b66f746"
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}
```

#### Creating GPU cluster with two interfaces

This example demonstrates how to create a baremetal GPU cluster with two network interfaces: one public and one private.

```terraform
resource "gcore_ai_cluster" "gpu_cluster" {
flavor = "bm3-ai-1xlarge-h100-80-8"
image_id = "37c4fa17-1f18-4904-95f2-dbf39d0318fe"
cluster_name = "my-gpu-cluster"
keypair_name = "my-keypair"
instances_count = 1
interface {
type = "external"
}
cluster_metadata = {
meta = "meta1"
interface {
type = "subnet"
network_id = gcore_network.network.id
subnet_id = gcore_subnet.subnet.id
}
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}
```

Expand All @@ -50,34 +107,34 @@ resource "gcore_ai_cluster" "cluster1" {

### Required

- `cluster_name` (String) AI Cluster Name
- `cluster_name` (String) GPU Cluster Name
- `flavor` (String) Flavor ID (name)
- `image_id` (String) Image ID
- `interface` (Block List, Min: 1) Networks managed by user and associated with the cluster (see [below for nested schema](#nestedblock--interface))

### Optional

- `cluster_metadata` (Map of String) Cluster metadata (simple key-value pairs)
- `cluster_status` (String) AI Cluster status
- `instances_count` (Number) Number of instances to create
- `keypair_name` (String) Ssh keypair name
- `password` (String) A password for baremetal instance. This parameter is used to set a password for the Admin user on a Windows instance, a default user or a new user on a Linux instance
- `project_id` (Number)
- `project_name` (String)
- `region_id` (Number)
- `region_name` (String)
- `cluster_metadata` (Map of String) A map of metadata items. Key-value pairs for GPU cluster metadata. Example: {'environment': 'production', 'owner': 'user'}
- `cluster_status` (String) GPU Cluster status
- `instances_count` (Number) Number of servers in the GPU cluster
- `keypair_name` (String) The name of the SSH keypair to use for the GPU servers
- `password` (String) A password for servers in GPU cluster. This parameter is used to set a password for the Admin user on a Windows instance, a default user or a new user on a Linux instance
- `project_id` (Number) Project ID, only one of project_id or project_name should be set
- `project_name` (String) Project name, only one of project_id or project_name should be set
- `region_id` (Number) Region ID, only one of region_id or region_name should be set
- `region_name` (String) Region name, only one of region_id or region_name should be set
- `security_group` (Block Set) Security groups attached to the cluster (see [below for nested schema](#nestedblock--security_group))
- `user_data` (String) String in base64 format. Must not be passed together with 'username' or 'password'. Examples of the user_data: https://cloudinit.readthedocs.io/en/latest/topics/examples.html
- `user_data` (String) User data string in base64 format. This is passed to the instance at launch. For Linux instances, 'user_data' is ignored when 'password' field is provided. For Windows instances, Admin user password is set by 'password' field and cannot be updated via 'user_data'
- `username` (String) A name of a new user in the Linux instance. It may be passed with a 'password' parameter
- `volume` (Block Set) List of volumes attached to the cluster (see [below for nested schema](#nestedblock--volume))

### Read-Only

- `created_at` (String) Datetime when the cluster was created
- `created_at` (String) Datetime when the GPU cluster was created
- `creator_task_id` (String) Task that created this entity
- `id` (String) The ID of this resource.
- `image_name` (String) Image name
- `poplar_servers` (List of Object) Poplar servers (see [below for nested schema](#nestedatt--poplar_servers))
- `poplar_servers` (List of Object) GPU cluster servers list (see [below for nested schema](#nestedatt--poplar_servers))
- `task_id` (String) Task ID associated with the cluster
- `task_status` (String) Task status

Expand Down Expand Up @@ -193,6 +250,11 @@ Read-Only:
- `delete_on_termination` (Boolean)
- `id` (String)






## Import

Import is supported using the following syntax:
Expand All @@ -201,3 +263,4 @@ Import is supported using the following syntax:
# import using <project_id>:<region_id>:<cluster_id> format
terraform import gcore_ai_cluster.cluster1 1:6:447d2959-8ae0-4ca0-8d47-9f050a3637d7
```

34 changes: 34 additions & 0 deletions examples/resources/gcore_ai_cluster/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
provider gcore {
permanent_api_token = "251$d3361.............1b35f26d8"
}

data "gcore_project" "project" {
name = "Default"
}

data "gcore_region" "region" {
name = "Luxembourg-2"
}

resource "gcore_network" "network" {
name = "my-network"
type = "vlan"
project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}

resource "gcore_subnet" "subnet" {
name = "my-subnet"
cidr = "192.168.10.0/24"
network_id = gcore_network.network.id

project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}

resource "gcore_keypair" "keypair" {
project_id = data.gcore_project.project.id
sshkey_name = "my-keypair"
public_key = "ssh-ed25519 ...your public key... [email protected]"
}

18 changes: 18 additions & 0 deletions examples/resources/gcore_ai_cluster/one-interface-with-meta.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "gcore_ai_cluster" "gpu_cluster" {
flavor = "bm3-ai-1xlarge-h100-80-8"
image_id = "37c4fa17-1f18-4904-95f2-dbf39d0318fe"
cluster_name = "my-gpu-cluster"
keypair_name = "my-keypair"
instances_count = 1

interface {
type = "external"
}

cluster_metadata = {
my-metadata-key = "my-metadata-value"
}

project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}
30 changes: 0 additions & 30 deletions examples/resources/gcore_ai_cluster/resource.tf

This file was deleted.

21 changes: 21 additions & 0 deletions examples/resources/gcore_ai_cluster/two-interface.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "gcore_ai_cluster" "gpu_cluster" {
flavor = "bm3-ai-1xlarge-h100-80-8"
image_id = "37c4fa17-1f18-4904-95f2-dbf39d0318fe"
cluster_name = "my-gpu-cluster"
keypair_name = "my-keypair"
instances_count = 1

interface {
type = "external"
}

interface {
type = "subnet"

network_id = gcore_network.network.id
subnet_id = gcore_subnet.subnet.id
}

project_id = data.gcore_project.project.id
region_id = data.gcore_region.region.id
}
4 changes: 2 additions & 2 deletions gcore/data_source_gcore_ai_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
func dataSourceAICluster() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceAIClusterRead,
Description: "Represent AI Cluster",
Description: "Represent GPU Cluster",
Schema: map[string]*schema.Schema{
"project_id": &schema.Schema{
Type: schema.TypeInt,
Expand Down Expand Up @@ -297,7 +297,7 @@ func dataSourceAICluster() *schema.Resource {
},
"poplar_servers": {
Type: schema.TypeList,
Description: "Poplar servers",
Description: "GPU cluster servers list",
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down
Loading

0 comments on commit 947eda7

Please sign in to comment.