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

[AV-71279] Support autoexpansion for Azure cluster(s) #143

Merged
merged 5 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 238 additions & 0 deletions examples/cluster/azure/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
# Azure Cluster Example

This example shows how to create a Cluster on Azure, with autoexpansion enabled.

For autoexpansion it requires this disk variable in `terraform.template.tfvars`:

```
disk = {
type = "P6"
autoexpansion = true
}
```

It should be added to `variables.tf`:

```
type = object({
size = optional(number)
type = string
iops = optional(number)
autoexpansion = optional(bool)
})
```

and referenced in `create_cluster.tf`:

```
disk = {
type = var.disk.type
autoexpansion = var.disk.autoexpansion
}
```

Sample Output:

```
terraform apply -var-file terraform.template.tfvars

Terraform will perform the following actions:

# couchbase-capella_cluster.new_cluster will be created
+ resource "couchbase-capella_cluster" "new_cluster" {
+ app_service_id = (known after apply)
+ audit = (known after apply)
+ availability = {
+ type = "single"
}
+ cloud_provider = {
+ cidr = "10.0.6.0/23"
+ region = "eastus"
+ type = "azure"
}
+ configuration_type = (known after apply)
+ couchbase_server = (known after apply)
+ current_state = (known after apply)
+ description = "My first test cluster for multiple services."
+ etag = (known after apply)
+ id = (known after apply)
+ name = "New Terraform Azure Cluster 6"
+ organization_id = "7dc36559-a544-4ce6-a132-5da412f350e9"
+ project_id = "693f1cb1-982b-4c52-8119-3f5dc6828489"
+ service_groups = [
+ {
+ node = {
+ compute = {
+ cpu = 4
+ ram = 16
}
+ disk = {
+ autoexpansion = true
+ iops = (known after apply)
+ storage = (known after apply)
+ type = "P6"
}
}
+ num_of_nodes = 3
+ services = [
+ "data",
]
},
]
+ support = {
+ plan = "basic"
+ timezone = "PT"
}
}

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
+ cluster_id = (known after apply)
+ new_cluster = {
+ app_service_id = (known after apply)
+ audit = (known after apply)
+ availability = {
+ type = "single"
}
+ cloud_provider = {
+ cidr = "10.0.6.0/23"
+ region = "eastus"
+ type = "azure"
}
+ configuration_type = (known after apply)
+ couchbase_server = (known after apply)
+ current_state = (known after apply)
+ description = "My first test cluster for multiple services."
+ etag = (known after apply)
+ id = (known after apply)
+ if_match = null
+ name = "New Terraform Azure Cluster 6"
+ organization_id = "7dc36559-a544-4ce6-a132-5da412f350e9"
+ project_id = "693f1cb1-982b-4c52-8119-3f5dc6828489"
+ service_groups = [
+ {
+ node = {
+ compute = {
+ cpu = 4
+ ram = 16
}
+ disk = {
+ autoexpansion = true
+ iops = (known after apply)
+ storage = (known after apply)
+ type = "P6"
}
}
+ num_of_nodes = 3
+ services = [
+ "data",
]
},
]
+ support = {
+ plan = "basic"
+ timezone = "PT"
}
}

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes


couchbase-capella_cluster.new_cluster: Creating...
couchbase-capella_cluster.new_cluster: Still creating... [10s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [20s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [30s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [40s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [50s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [1m0s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [1m10s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [1m20s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [1m30s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [1m40s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [1m50s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [2m0s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [2m10s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [2m20s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [2m30s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [2m40s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [2m50s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [3m0s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [3m10s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [3m20s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [3m30s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [3m40s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [3m50s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [4m0s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [4m10s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [4m20s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [4m30s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [4m40s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [4m50s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [5m0s elapsed]
couchbase-capella_cluster.new_cluster: Still creating... [5m10s elapsed]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

cluster_id = "10d5c496-502f-430e-99fb-25fa8bd7285a"
new_cluster = {
"app_service_id" = tostring(null)
"audit" = {
"created_at" = "2024-01-18 20:48:53.703590843 +0000 UTC"
"created_by" = "GGZjZ6bOhAiuFJoJ0M1NoFHwm6RHZvkv"
"modified_at" = "2024-01-18 20:54:04.672833562 +0000 UTC"
"modified_by" = "GGZjZ6bOhAiuFJoJ0M1NoFHwm6RHZvkv"
"version" = 3
}
"availability" = {
"type" = "single"
}
"cloud_provider" = {
"cidr" = "10.0.6.0/23"
"region" = "eastus"
"type" = "azure"
}
"configuration_type" = "multiNode"
"couchbase_server" = {
"version" = "7.2"
}
"current_state" = "healthy"
"description" = "My first test cluster for multiple services."
"etag" = "Version: 3"
"id" = "10d5c496-502f-430e-99fb-25fa8bd7285a"
"if_match" = tostring(null)
"name" = "New Terraform Azure Cluster 6"
"organization_id" = "7dc36559-a544-4ce6-a132-5da412f350e9"
"project_id" = "693f1cb1-982b-4c52-8119-3f5dc6828489"
"service_groups" = toset([
{
"node" = {
"compute" = {
"cpu" = 4
"ram" = 16
}
"disk" = {
"autoexpansion" = true
"iops" = 240
"storage" = 64
"type" = "P6"
}
}
"num_of_nodes" = 3
"services" = toset([
"data",
])
},
])
"support" = {
"plan" = "basic"
"timezone" = "PT"
}
}
```
43 changes: 43 additions & 0 deletions examples/cluster/azure/create_cluster.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
output "new_cluster" {
value = couchbase-capella_cluster.new_cluster
}

output "cluster_id" {
value = couchbase-capella_cluster.new_cluster.id
}

resource "couchbase-capella_cluster" "new_cluster" {
organization_id = var.organization_id
project_id = var.project_id
name = var.cluster.name
description = "My first test cluster for multiple services."
cloud_provider = {
type = var.cloud_provider.name
region = var.cloud_provider.region
cidr = var.cluster.cidr
}
service_groups = [
{
node = {
compute = {
cpu = var.compute.cpu
ram = var.compute.ram
}
disk = {
type = var.disk.type
autoexpansion = var.disk.autoexpansion
}
}
num_of_nodes = var.cluster.node_count
services = var.cluster.couchbase_services
}
]
availability = {
"type" : var.cluster.availability_zone
}
support = {
plan = var.support.plan
timezone = var.support.timezone
}
}

12 changes: 12 additions & 0 deletions examples/cluster/azure/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_providers {
couchbase-capella = {
source = "couchbasecloud/couchbase-capella"
}
}
}

provider "couchbase-capella" {
authentication_token = var.auth_token
}

31 changes: 31 additions & 0 deletions examples/cluster/azure/terraform.template.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
auth_token = "<v4-api-key-secret>"
organization_id = "<organization_id>"
project_id = "<project_id>"

cloud_provider = {
name = "azure",
region = "eastus"
}

cluster = {
name = "New Terraform Azure Cluster 6"
cidr = "10.0.6.0/23"
node_count = 3
couchbase_services = ["data"]
availability_zone = "single"
}

compute = {
cpu = 4
ram = 16
}

disk = {
type = "P6"
autoexpansion = true
}

support = {
plan = "basic"
timezone = "PT"
}
62 changes: 62 additions & 0 deletions examples/cluster/azure/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
variable "auth_token" {
description = "Authentication API Key"
sensitive = true
}

variable "organization_id" {
description = "Capella Organization ID"
}

variable "project_id" {
description = "Project Name for Project Created via Terraform"
}

variable "cloud_provider" {
description = "Cloud Provider details useful for cluster creation"

type = object({
name = string
region = string
})
}

variable "cluster" {
description = "Cluster configuration details useful for creation"

type = object({
name = string
cidr = string
node_count = number
couchbase_services = list(string)
availability_zone = string
})
}

variable "compute" {
description = "All cluster node compute configuration"

type = object({
cpu = number
ram = number
})
}

variable "disk" {
description = "All nodes' disk configuration"

type = object({
size = optional(number)
type = string
iops = optional(number)
autoexpansion = optional(bool)
})
}

variable "support" {
description = "Support configuration applicable to the cluster during creation"

type = object({
plan = string
timezone = string
})
}
Loading
Loading