Skip to content

Commit c1dcd24

Browse files
feat(k8s): enable support for MigrateClusterToRoutedIPsRequest (#4083)
Co-authored-by: Rémy Léone <[email protected]>
1 parent 453ca2d commit c1dcd24

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+
Migrate the nodes of an existing cluster to Routed IPs and enable Routed IPs for all future nodes.
4+
5+
USAGE:
6+
scw k8s cluster migrate-to-routed-ips <cluster-id ...> [arg=value ...]
7+
8+
EXAMPLES:
9+
Migrate a cluster to Routed IPs
10+
scw k8s cluster migrate-to-routed-ips 11111111-1111-1111-111111111111
11+
12+
ARGS:
13+
cluster-id Cluster ID for which the routed ip will be enabled for the nodes
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-routed-ips
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
@@ -13,6 +13,7 @@ AVAILABLE COMMANDS:
1313
list List Clusters
1414
list-available-types List available cluster types for a cluster
1515
list-available-versions List available versions for a Cluster
16+
migrate-to-routed-ips Migrate a cluster to Routed IPs
1617
reset-admin-token Reset the admin token of a Cluster
1718
set-type Change the Cluster type
1819
update Update a Cluster

docs/commands/k8s.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This API allows you to manage Kubernetes Kapsule and Kosmos clusters.
1010
- [List Clusters](#list-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)
13+
- [Migrate a cluster to Routed IPs](#migrate-a-cluster-to-routed-ips)
1314
- [Reset the admin token of a Cluster](#reset-the-admin-token-of-a-cluster)
1415
- [Change the Cluster type](#change-the-cluster-type)
1516
- [Update a Cluster](#update-a-cluster)
@@ -316,6 +317,36 @@ scw k8s cluster list-available-versions 11111111-1111-1111-111111111111
316317

317318

318319

320+
### Migrate a cluster to Routed IPs
321+
322+
Migrate the nodes of an existing cluster to Routed IPs and enable Routed IPs for all future nodes.
323+
324+
**Usage:**
325+
326+
```
327+
scw k8s cluster migrate-to-routed-ips <cluster-id ...> [arg=value ...]
328+
```
329+
330+
331+
**Args:**
332+
333+
| Name | | Description |
334+
|------|---|-------------|
335+
| cluster-id | Required | Cluster ID for which the routed ip will be enabled for the nodes |
336+
| 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 |
337+
338+
339+
**Examples:**
340+
341+
342+
Migrate a cluster to Routed IPs
343+
```
344+
scw k8s cluster migrate-to-routed-ips 11111111-1111-1111-111111111111
345+
```
346+
347+
348+
349+
319350
### Reset the admin token of a Cluster
320351

321352
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
@@ -36,6 +36,7 @@ func GetGeneratedCommands() *core.Commands {
3636
k8sClusterListAvailableVersions(),
3737
k8sClusterListAvailableTypes(),
3838
k8sClusterResetAdminToken(),
39+
k8sClusterMigrateToRoutedIPs(),
3940
k8sPoolList(),
4041
k8sPoolCreate(),
4142
k8sPoolGet(),
@@ -1159,6 +1160,42 @@ func k8sClusterResetAdminToken() *core.Command {
11591160
}
11601161
}
11611162

1163+
func k8sClusterMigrateToRoutedIPs() *core.Command {
1164+
return &core.Command{
1165+
Short: `Migrate a cluster to Routed IPs`,
1166+
Long: `Migrate the nodes of an existing cluster to Routed IPs and enable Routed IPs for all future nodes.`,
1167+
Namespace: "k8s",
1168+
Resource: "cluster",
1169+
Verb: "migrate-to-routed-ips",
1170+
// Deprecated: false,
1171+
ArgsType: reflect.TypeOf(k8s.MigrateClusterToRoutedIPsRequest{}),
1172+
ArgSpecs: core.ArgSpecs{
1173+
{
1174+
Name: "cluster-id",
1175+
Short: `Cluster ID for which the routed ip will be enabled for the nodes`,
1176+
Required: true,
1177+
Deprecated: false,
1178+
Positional: true,
1179+
},
1180+
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
1181+
},
1182+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
1183+
request := args.(*k8s.MigrateClusterToRoutedIPsRequest)
1184+
1185+
client := core.ExtractClient(ctx)
1186+
api := k8s.NewAPI(client)
1187+
return api.MigrateClusterToRoutedIPs(request)
1188+
1189+
},
1190+
Examples: []*core.Example{
1191+
{
1192+
Short: "Migrate a cluster to Routed IPs",
1193+
Raw: `scw k8s cluster migrate-to-routed-ips 11111111-1111-1111-111111111111`,
1194+
},
1195+
},
1196+
}
1197+
}
1198+
11621199
func k8sPoolList() *core.Command {
11631200
return &core.Command{
11641201
Short: `List Pools in a Cluster`,

0 commit comments

Comments
 (0)