Skip to content

Commit cd111e2

Browse files
authored
feat(k8s): enable MigrateClusterToSBSCSI in CLI (#4120)
1 parent 269ede4 commit cd111e2

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Enable the latest CSI compatible with Scaleway Block Storage (SBS) and migrate all existing PersistentVolumes/VolumeSnapshotContents to SBS.
4+
5+
USAGE:
6+
scw k8s cluster migrate-to-sbs-csi <cluster-id ...> [arg=value ...]
7+
8+
EXAMPLES:
9+
Migrate a cluster to SBS CSI
10+
scw k8s cluster migrate-to-sbs-csi 11111111-1111-1111-111111111111
11+
12+
ARGS:
13+
cluster-id Cluster ID for which the latest CSI compatible with Scaleway Block Storage will be enabled
14+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
15+
16+
FLAGS:
17+
-h, --help help for migrate-to-sbs-csi
18+
19+
GLOBAL FLAGS:
20+
-c, --config string The path to the config file
21+
-D, --debug Enable debug mode
22+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
23+
-p, --profile string The config profile to use

cmd/scw/testdata/test-all-usage-k8s-cluster-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ AVAILABLE COMMANDS:
1414
list-available-types List available cluster types for a cluster
1515
list-available-versions List available versions for a Cluster
1616
migrate-to-routed-ips Migrate a cluster to Routed IPs
17+
migrate-to-sbs-csi Migrate a cluster to SBS CSI
1718
reset-admin-token Reset the admin token of a Cluster
1819
set-type Change the Cluster type
1920
update Update a Cluster

docs/commands/k8s.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This API allows you to manage Kubernetes Kapsule and Kosmos clusters.
1111
- [List available cluster types for a cluster](#list-available-cluster-types-for-a-cluster)
1212
- [List available versions for a Cluster](#list-available-versions-for-a-cluster)
1313
- [Migrate a cluster to Routed IPs](#migrate-a-cluster-to-routed-ips)
14+
- [Migrate a cluster to SBS CSI](#migrate-a-cluster-to-sbs-csi)
1415
- [Reset the admin token of a Cluster](#reset-the-admin-token-of-a-cluster)
1516
- [Change the Cluster type](#change-the-cluster-type)
1617
- [Update a Cluster](#update-a-cluster)
@@ -347,6 +348,36 @@ scw k8s cluster migrate-to-routed-ips 11111111-1111-1111-111111111111
347348

348349

349350

351+
### Migrate a cluster to SBS CSI
352+
353+
Enable the latest CSI compatible with Scaleway Block Storage (SBS) and migrate all existing PersistentVolumes/VolumeSnapshotContents to SBS.
354+
355+
**Usage:**
356+
357+
```
358+
scw k8s cluster migrate-to-sbs-csi <cluster-id ...> [arg=value ...]
359+
```
360+
361+
362+
**Args:**
363+
364+
| Name | | Description |
365+
|------|---|-------------|
366+
| cluster-id | Required | Cluster ID for which the latest CSI compatible with Scaleway Block Storage will be enabled |
367+
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |
368+
369+
370+
**Examples:**
371+
372+
373+
Migrate a cluster to SBS CSI
374+
```
375+
scw k8s cluster migrate-to-sbs-csi 11111111-1111-1111-111111111111
376+
```
377+
378+
379+
380+
350381
### Reset the admin token of a Cluster
351382

352383
Reset the admin token for a specific Kubernetes cluster. This will revoke the old admin token (which will not be usable afterwards) and create a new one. Note that you will need to download kubeconfig again to keep interacting with the cluster.

internal/namespaces/k8s/v1/k8s_cli.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func GetGeneratedCommands() *core.Commands {
3737
k8sClusterListAvailableTypes(),
3838
k8sClusterResetAdminToken(),
3939
k8sClusterMigrateToRoutedIPs(),
40+
k8sClusterMigrateToSbsCsi(),
4041
k8sPoolList(),
4142
k8sPoolCreate(),
4243
k8sPoolGet(),
@@ -1196,6 +1197,42 @@ func k8sClusterMigrateToRoutedIPs() *core.Command {
11961197
}
11971198
}
11981199

1200+
func k8sClusterMigrateToSbsCsi() *core.Command {
1201+
return &core.Command{
1202+
Short: `Migrate a cluster to SBS CSI`,
1203+
Long: `Enable the latest CSI compatible with Scaleway Block Storage (SBS) and migrate all existing PersistentVolumes/VolumeSnapshotContents to SBS.`,
1204+
Namespace: "k8s",
1205+
Resource: "cluster",
1206+
Verb: "migrate-to-sbs-csi",
1207+
// Deprecated: false,
1208+
ArgsType: reflect.TypeOf(k8s.MigrateClusterToSBSCSIRequest{}),
1209+
ArgSpecs: core.ArgSpecs{
1210+
{
1211+
Name: "cluster-id",
1212+
Short: `Cluster ID for which the latest CSI compatible with Scaleway Block Storage will be enabled`,
1213+
Required: true,
1214+
Deprecated: false,
1215+
Positional: true,
1216+
},
1217+
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
1218+
},
1219+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
1220+
request := args.(*k8s.MigrateClusterToSBSCSIRequest)
1221+
1222+
client := core.ExtractClient(ctx)
1223+
api := k8s.NewAPI(client)
1224+
return api.MigrateClusterToSBSCSI(request)
1225+
1226+
},
1227+
Examples: []*core.Example{
1228+
{
1229+
Short: "Migrate a cluster to SBS CSI",
1230+
Raw: `scw k8s cluster migrate-to-sbs-csi 11111111-1111-1111-111111111111`,
1231+
},
1232+
},
1233+
}
1234+
}
1235+
11991236
func k8sPoolList() *core.Command {
12001237
return &core.Command{
12011238
Short: `List Pools in a Cluster`,

0 commit comments

Comments
 (0)