Skip to content

Commit 27b2a0c

Browse files
authored
feat(k8s): add support for configurable root volume (#1364)
1 parent c59e0c9 commit 27b2a0c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

docs/resources/k8s_pool.md

+4
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ The following arguments are supported:
7474

7575
- `max_unavailable` - (Defaults to `1`) The maximum number of nodes that can be not ready at the same time
7676

77+
- `root_volume_type` - (Optional) System volume type of the nodes composing the pool
78+
79+
- `root_volume_size_in_gb` - (Optional) The size of the system volume of the nodes in gigabyte
80+
7781
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#regions) in which the pool should be created.
7882
~> **Important:** Updates to this field will recreate a new resource.
7983

scaleway/resource_k8s_pool.go

+25
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,22 @@ func resourceScalewayK8SPool() *schema.Resource {
139139
},
140140
},
141141
},
142+
"root_volume_type": {
143+
Type: schema.TypeString,
144+
Optional: true,
145+
ForceNew: true,
146+
Description: "System volume type of the nodes composing the pool",
147+
ValidateFunc: validation.StringInSlice([]string{
148+
k8s.PoolVolumeTypeBSSD.String(),
149+
k8s.PoolVolumeTypeLSSD.String(),
150+
}, false),
151+
},
152+
"root_volume_size_in_gb": {
153+
Type: schema.TypeInt,
154+
Optional: true,
155+
ForceNew: true,
156+
Description: "The size of the system volume of the nodes in gigabyte",
157+
},
142158
"zone": zoneSchema(),
143159
"region": regionSchema(),
144160
// Computed elements
@@ -253,6 +269,15 @@ func resourceScalewayK8SPoolCreate(ctx context.Context, d *schema.ResourceData,
253269
upgradePolicyReq.MaxUnavailable = scw.Uint32Ptr(uint32(maxUnavailable.(int)))
254270
}
255271

272+
if volumeType, ok := d.GetOk("root_volume_type"); ok {
273+
req.RootVolumeType = k8s.PoolVolumeType(volumeType.(string))
274+
}
275+
276+
if volumeSize, ok := d.GetOk("root_volume_size_in_gb"); ok {
277+
volumeSizeInBytes := scw.Size(uint64(volumeSize.(int)) * gb)
278+
req.RootVolumeSize = &volumeSizeInBytes
279+
}
280+
256281
// check if the cluster is waiting for a pool
257282
cluster, err := k8sAPI.GetCluster(&k8s.GetClusterRequest{
258283
ClusterID: expandID(d.Get("cluster_id")),

0 commit comments

Comments
 (0)