Skip to content

Commit 784abb4

Browse files
committed
Fix Terraform snippets for ACStor
1 parent 3fc5d91 commit 784abb4

2 files changed

Lines changed: 66 additions & 10 deletions

File tree

articles/storage/container-storage/install-container-storage-aks.md

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,24 @@ az account set --subscription <subscription-id>
234234
name = "acstor"
235235
cluster_id = azurerm_kubernetes_cluster.aks.id
236236
extension_type = "microsoft.azurecontainerstoragev2"
237-
238-
configuration_settings = {
239-
enable-azure-container-storage = "true"
240-
}
241237
}
242238
```
243239
244-
To install Elastic SAN during deployment, set `enable-azure-container-storage` to `elasticSan` or a comma-separated list:
240+
To enable storage drivers during deployment, pass the necessary Helm chart settings:
245241
246242
```tf
247-
configuration_settings = {
248-
enable-azure-container-storage = "elasticSan"
243+
resource "azurerm_kubernetes_cluster_extension" "container_storage" {
244+
# NOTE: the `name` parameter must be "acstor" for Azure CLI compatibility
245+
name = "acstor"
246+
cluster_id = azurerm_kubernetes_cluster.aks.id
247+
extension_type = "microsoft.azurecontainerstoragev2"
248+
249+
configuration_settings = {
250+
# Enable local NVMe
251+
"csiDriverConfigs.local-csi-driver.enabled" = "true"
252+
# Enable Azure Elastic SAN
253+
"csiDriverConfigs.azuresan-csi-driver.enabled" = "true"
254+
}
249255
}
250256
```
251257
@@ -291,20 +297,32 @@ data "azurerm_kubernetes_cluster" "existing" {
291297
resource_group_name = "existing-aks-rg"
292298
}
293299
300+
resource "azurerm_kubernetes_cluster_extension" "container_storage" {
301+
# NOTE: the `name` parameter must be "acstor" for Azure CLI compatibility
302+
name = "acstor"
303+
cluster_id = data.azurerm_kubernetes_cluster.existing.id
304+
extension_type = "microsoft.azurecontainerstoragev2"
305+
}
306+
```
307+
308+
To enable storage drivers during deployment, pass the necessary Helm chart settings:
309+
310+
```tf
294311
resource "azurerm_kubernetes_cluster_extension" "container_storage" {
295312
# NOTE: the `name` parameter must be "acstor" for Azure CLI compatibility
296313
name = "acstor"
297314
cluster_id = data.azurerm_kubernetes_cluster.existing.id
298315
extension_type = "microsoft.azurecontainerstoragev2"
299316
300317
configuration_settings = {
301-
enable-azure-container-storage = "true"
318+
# Enable local NVMe
319+
"csiDriverConfigs.local-csi-driver.enabled" = "true"
320+
# Enable Azure Elastic SAN
321+
"csiDriverConfigs.azuresan-csi-driver.enabled" = "true"
302322
}
303323
}
304324
```
305325

306-
To install Elastic SAN or local NVMe during deployment, set `enable-azure-container-storage` to a storage type or comma-separated list (for example, `elasticSan` or `ephemeralDisk,elasticSan`).
307-
308326
Run `terraform init` (if this is a new working directory) followed by `terraform apply` to install Azure Container Storage on the targeted cluster.
309327

310328
::: zone-end

articles/storage/container-storage/use-container-storage-with-elastic-san.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,44 @@ allowVolumeExpansion: true
6262
6363
The default Elastic SAN capacity provisioned with this storage class is 1 TiB.
6464
65+
Alternatively, you can create the storage class using Terraform.
66+
67+
1. Use Terraform to manage the storage class by creating a configuration like the following `main.tf`. Update the provider version or kubeconfig path as needed for your environment.
68+
69+
```tf
70+
terraform {
71+
required_version = ">= 1.5.0"
72+
required_providers {
73+
kubernetes = {
74+
source = "hashicorp/kubernetes"
75+
version = "~> 3.x"
76+
}
77+
}
78+
}
79+
80+
provider "kubernetes" {
81+
config_path = "~/.kube/config"
82+
}
83+
84+
resource "kubernetes_storage_class_v1" "azuresan" {
85+
metadata {
86+
name = "azuresan"
87+
}
88+
89+
storage_provisioner = "san.csi.azure.com"
90+
reclaim_policy = "Delete"
91+
volume_binding_mode = "Immediate"
92+
allow_volume_expansion = true
93+
}
94+
```
95+
96+
1. Initialize and apply the configuration.
97+
98+
```bash
99+
terraform init
100+
terraform apply
101+
```
102+
65103
### Create a storage class with custom Elastic SAN capacity
66104

67105
If you need a different initial capacity than the default 1 TiB, set the `initialStorageTiB` parameter in the storage class.

0 commit comments

Comments
 (0)