Skip to content

Commit

Permalink
feat(k8s): enable MigrateClusterToSBSCSI in CLI (#4120)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Sep 13, 2024
1 parent 269ede4 commit cd111e2
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
Enable the latest CSI compatible with Scaleway Block Storage (SBS) and migrate all existing PersistentVolumes/VolumeSnapshotContents to SBS.

USAGE:
scw k8s cluster migrate-to-sbs-csi <cluster-id ...> [arg=value ...]

EXAMPLES:
Migrate a cluster to SBS CSI
scw k8s cluster migrate-to-sbs-csi 11111111-1111-1111-111111111111

ARGS:
cluster-id Cluster ID for which the latest CSI compatible with Scaleway Block Storage will be enabled
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)

FLAGS:
-h, --help help for migrate-to-sbs-csi

GLOBAL FLAGS:
-c, --config string The path to the config file
-D, --debug Enable debug mode
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
-p, --profile string The config profile to use
1 change: 1 addition & 0 deletions cmd/scw/testdata/test-all-usage-k8s-cluster-usage.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ AVAILABLE COMMANDS:
list-available-types List available cluster types for a cluster
list-available-versions List available versions for a Cluster
migrate-to-routed-ips Migrate a cluster to Routed IPs
migrate-to-sbs-csi Migrate a cluster to SBS CSI
reset-admin-token Reset the admin token of a Cluster
set-type Change the Cluster type
update Update a Cluster
Expand Down
31 changes: 31 additions & 0 deletions docs/commands/k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This API allows you to manage Kubernetes Kapsule and Kosmos clusters.
- [List available cluster types for a cluster](#list-available-cluster-types-for-a-cluster)
- [List available versions for a Cluster](#list-available-versions-for-a-cluster)
- [Migrate a cluster to Routed IPs](#migrate-a-cluster-to-routed-ips)
- [Migrate a cluster to SBS CSI](#migrate-a-cluster-to-sbs-csi)
- [Reset the admin token of a Cluster](#reset-the-admin-token-of-a-cluster)
- [Change the Cluster type](#change-the-cluster-type)
- [Update a Cluster](#update-a-cluster)
Expand Down Expand Up @@ -347,6 +348,36 @@ scw k8s cluster migrate-to-routed-ips 11111111-1111-1111-111111111111



### Migrate a cluster to SBS CSI

Enable the latest CSI compatible with Scaleway Block Storage (SBS) and migrate all existing PersistentVolumes/VolumeSnapshotContents to SBS.

**Usage:**

```
scw k8s cluster migrate-to-sbs-csi <cluster-id ...> [arg=value ...]
```


**Args:**

| Name | | Description |
|------|---|-------------|
| cluster-id | Required | Cluster ID for which the latest CSI compatible with Scaleway Block Storage will be enabled |
| 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 |


**Examples:**


Migrate a cluster to SBS CSI
```
scw k8s cluster migrate-to-sbs-csi 11111111-1111-1111-111111111111
```




### Reset the admin token of a Cluster

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.
Expand Down
37 changes: 37 additions & 0 deletions internal/namespaces/k8s/v1/k8s_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func GetGeneratedCommands() *core.Commands {
k8sClusterListAvailableTypes(),
k8sClusterResetAdminToken(),
k8sClusterMigrateToRoutedIPs(),
k8sClusterMigrateToSbsCsi(),
k8sPoolList(),
k8sPoolCreate(),
k8sPoolGet(),
Expand Down Expand Up @@ -1196,6 +1197,42 @@ func k8sClusterMigrateToRoutedIPs() *core.Command {
}
}

func k8sClusterMigrateToSbsCsi() *core.Command {
return &core.Command{
Short: `Migrate a cluster to SBS CSI`,
Long: `Enable the latest CSI compatible with Scaleway Block Storage (SBS) and migrate all existing PersistentVolumes/VolumeSnapshotContents to SBS.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "migrate-to-sbs-csi",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.MigrateClusterToSBSCSIRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "cluster-id",
Short: `Cluster ID for which the latest CSI compatible with Scaleway Block Storage will be enabled`,
Required: true,
Deprecated: false,
Positional: true,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*k8s.MigrateClusterToSBSCSIRequest)

client := core.ExtractClient(ctx)
api := k8s.NewAPI(client)
return api.MigrateClusterToSBSCSI(request)

},
Examples: []*core.Example{
{
Short: "Migrate a cluster to SBS CSI",
Raw: `scw k8s cluster migrate-to-sbs-csi 11111111-1111-1111-111111111111`,
},
},
}
}

func k8sPoolList() *core.Command {
return &core.Command{
Short: `List Pools in a Cluster`,
Expand Down

0 comments on commit cd111e2

Please sign in to comment.