Skip to content

Commit b238ac3

Browse files
authored
feat(k8s): add resiliency and sla to cluster types (#3264)
1 parent bca34a9 commit b238ac3

File tree

6 files changed

+100
-3
lines changed

6 files changed

+100
-3
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+
List the cluster types that a specific Kubernetes cluster is allowed to switch to.
4+
5+
USAGE:
6+
scw k8s cluster list-available-types <cluster-id ...> [arg=value ...]
7+
8+
EXAMPLES:
9+
List all cluster types that a cluster can upgrade to
10+
scw k8s cluster list-available-types 11111111-1111-1111-111111111111
11+
12+
ARGS:
13+
cluster-id Cluster ID for which the available Kubernetes types will be listed
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 list-available-types
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
@@ -11,6 +11,7 @@ AVAILABLE COMMANDS:
1111
delete Delete a Cluster
1212
get Get a Cluster
1313
list List Clusters
14+
list-available-types List available cluster types for a cluster
1415
list-available-versions List available versions for a Cluster
1516
migrate-to-private-network Migrate an existing cluster to a Private Network cluster
1617
reset-admin-token Reset the admin token of a Cluster

docs/commands/k8s.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Kubernetes API.
77
- [Delete a Cluster](#delete-a-cluster)
88
- [Get a Cluster](#get-a-cluster)
99
- [List Clusters](#list-clusters)
10+
- [List available cluster types for a cluster](#list-available-cluster-types-for-a-cluster)
1011
- [List available versions for a Cluster](#list-available-versions-for-a-cluster)
1112
- [Migrate an existing cluster to a Private Network cluster](#migrate-an-existing-cluster-to-a-private-network-cluster)
1213
- [Reset the admin token of a Cluster](#reset-the-admin-token-of-a-cluster)
@@ -242,6 +243,36 @@ scw k8s cluster list region=fr-par name=cluster1
242243

243244

244245

246+
### List available cluster types for a cluster
247+
248+
List the cluster types that a specific Kubernetes cluster is allowed to switch to.
249+
250+
**Usage:**
251+
252+
```
253+
scw k8s cluster list-available-types <cluster-id ...> [arg=value ...]
254+
```
255+
256+
257+
**Args:**
258+
259+
| Name | | Description |
260+
|------|---|-------------|
261+
| cluster-id | Required | Cluster ID for which the available Kubernetes types will be listed |
262+
| 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 |
263+
264+
265+
**Examples:**
266+
267+
268+
List all cluster types that a cluster can upgrade to
269+
```
270+
scw k8s cluster list-available-types 11111111-1111-1111-111111111111
271+
```
272+
273+
274+
275+
245276
### List available versions for a Cluster
246277

247278
List the versions that a specific Kubernetes cluster is allowed to upgrade to. Results will include every patch version greater than the current patch, as well as one minor version ahead of the current version. Any upgrade skipping a minor version will not work.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require (
2424
github.com/moby/buildkit v0.11.6
2525
github.com/opencontainers/go-digest v1.0.0
2626
github.com/pkg/errors v0.9.1
27-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18
27+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18.0.20230705084246-74eb7cf1a708
2828
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2929
github.com/spf13/cobra v1.7.0
3030
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj
497497
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
498498
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
499499
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
500-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18 h1:LIrryugt9WeLL2efANvAgnGnFIhoN3lX05PptCng/vQ=
501-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
500+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18.0.20230705084246-74eb7cf1a708 h1:2Et0Li+UBOluBBdBonMTB1rqwiW17UAcloghjGTOCDY=
501+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.18.0.20230705084246-74eb7cf1a708/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
502502
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
503503
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
504504
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=

internal/namespaces/k8s/v1/k8s_cli.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func GetGeneratedCommands() *core.Commands {
3333
k8sClusterUpgrade(),
3434
k8sClusterSetType(),
3535
k8sClusterListAvailableVersions(),
36+
k8sClusterListAvailableTypes(),
3637
k8sClusterResetAdminToken(),
3738
k8sClusterMigrateToPrivateNetwork(),
3839
k8sPoolList(),
@@ -1094,6 +1095,47 @@ func k8sClusterListAvailableVersions() *core.Command {
10941095
}
10951096
}
10961097

1098+
func k8sClusterListAvailableTypes() *core.Command {
1099+
return &core.Command{
1100+
Short: `List available cluster types for a cluster`,
1101+
Long: `List the cluster types that a specific Kubernetes cluster is allowed to switch to.`,
1102+
Namespace: "k8s",
1103+
Resource: "cluster",
1104+
Verb: "list-available-types",
1105+
// Deprecated: false,
1106+
ArgsType: reflect.TypeOf(k8s.ListClusterAvailableTypesRequest{}),
1107+
ArgSpecs: core.ArgSpecs{
1108+
{
1109+
Name: "cluster-id",
1110+
Short: `Cluster ID for which the available Kubernetes types will be listed`,
1111+
Required: true,
1112+
Deprecated: false,
1113+
Positional: true,
1114+
},
1115+
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
1116+
},
1117+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
1118+
request := args.(*k8s.ListClusterAvailableTypesRequest)
1119+
1120+
client := core.ExtractClient(ctx)
1121+
api := k8s.NewAPI(client)
1122+
return api.ListClusterAvailableTypes(request)
1123+
1124+
},
1125+
Examples: []*core.Example{
1126+
{
1127+
Short: "List all cluster types that a cluster can upgrade to",
1128+
Raw: `scw k8s cluster list-available-types 11111111-1111-1111-111111111111`,
1129+
},
1130+
},
1131+
View: &core.View{Fields: []*core.ViewField{
1132+
{
1133+
FieldName: "Name",
1134+
},
1135+
}},
1136+
}
1137+
}
1138+
10971139
func k8sClusterResetAdminToken() *core.Command {
10981140
return &core.Command{
10991141
Short: `Reset the admin token of a Cluster`,

0 commit comments

Comments
 (0)