/
k8s_cli.go
2052 lines (1975 loc) · 63.8 KB
/
k8s_cli.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
package k8s
import (
"context"
"reflect"
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-sdk-go/api/k8s/v1"
"github.com/scaleway/scaleway-sdk-go/scw"
)
// always import dependencies
var (
_ = scw.RegionFrPar
)
func GetGeneratedCommands() *core.Commands {
return core.NewCommands(
k8sRoot(),
k8sCluster(),
k8sPool(),
k8sNode(),
k8sVersion(),
k8sClusterList(),
k8sClusterCreate(),
k8sClusterGet(),
k8sClusterUpdate(),
k8sClusterDelete(),
k8sClusterUpgrade(),
k8sClusterSetType(),
k8sClusterListAvailableVersions(),
k8sClusterResetAdminToken(),
k8sClusterMigrateToPrivateNetwork(),
k8sPoolList(),
k8sPoolCreate(),
k8sPoolGet(),
k8sPoolUpgrade(),
k8sPoolUpdate(),
k8sPoolDelete(),
k8sNodeList(),
k8sNodeGet(),
k8sNodeReplace(),
k8sNodeReboot(),
k8sNodeDelete(),
k8sVersionList(),
k8sVersionGet(),
)
}
func k8sRoot() *core.Command {
return &core.Command{
Short: `Kubernetes API`,
Long: `Kubernetes API.`,
Namespace: "k8s",
}
}
func k8sCluster() *core.Command {
return &core.Command{
Short: `Kapsule cluster management commands`,
Long: `A cluster is a fully managed Kubernetes cluster
It is composed of different pools, each pool containing the same kind of nodes.
`,
Namespace: "k8s",
Resource: "cluster",
}
}
func k8sPool() *core.Command {
return &core.Command{
Short: `Kapsule pool management commands`,
Long: `A pool is a set of identical nodes
A pool has a name, a size (its desired number of nodes), node number limits (min, max), and a Scaleway Instance type. Changing those limits increases/decreases the size of a pool. As a result and depending on its load, the pool will grow or shrink within those limits when autoscaling is enabled. A "default pool" is automatically created with every cluster via the console.
`,
Namespace: "k8s",
Resource: "pool",
}
}
func k8sNode() *core.Command {
return &core.Command{
Short: `Kapsule node management commands`,
Long: `A node (short for worker node) is an abstraction for a Scaleway Instance
A node is always part of a pool. Each of them has the Kubernetes software automatically installed and configured by Scaleway.
`,
Namespace: "k8s",
Resource: "node",
}
}
func k8sVersion() *core.Command {
return &core.Command{
Short: `Available Kubernetes versions commands`,
Long: `A version is a vanilla Kubernetes version like ` + "`" + `x.y.z` + "`" + `
It comprises a major version ` + "`" + `x` + "`" + `, a minor version ` + "`" + `y` + "`" + `, and a patch version ` + "`" + `z` + "`" + `. At the minimum, Kapsule (Scaleway's managed Kubernetes), will support the last patch version for the past three minor releases. Also, each version has a different set of CNIs, eventually container runtimes, feature gates, and admission plugins available. See our [Version Support Policy](https://www.scaleway.com/en/docs/containers/kubernetes/reference-content/version-support-policy/).
`,
Namespace: "k8s",
Resource: "version",
}
}
func k8sClusterList() *core.Command {
return &core.Command{
Short: `List Clusters`,
Long: `List all existing Kubernetes clusters in a specific region.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.ListClustersRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "project-id",
Short: `Project ID on which to filter the returned clusters`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "order-by",
Short: `Sort order of returned clusters`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"created_at_asc", "created_at_desc", "updated_at_asc", "updated_at_desc", "name_asc", "name_desc", "status_asc", "status_desc", "version_asc", "version_desc"},
},
{
Name: "name",
Short: `Name to filter on, only clusters containing this substring in their name will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "status",
Short: `Status to filter on, only clusters with this status will be returned`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown", "creating", "ready", "deleting", "deleted", "updating", "locked", "pool_required"},
},
{
Name: "type",
Short: `Type to filter on, only clusters with this type will be returned`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "organization-id",
Short: `Organization ID on which to filter the returned clusters`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw, scw.Region(core.AllLocalities)),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*k8s.ListClustersRequest)
client := core.ExtractClient(ctx)
api := k8s.NewAPI(client)
opts := []scw.RequestOption{scw.WithAllPages()}
if request.Region == scw.Region(core.AllLocalities) {
opts = append(opts, scw.WithRegions(api.Regions()...))
request.Region = ""
}
resp, err := api.ListClusters(request, opts...)
if err != nil {
return nil, err
}
return resp.Clusters, nil
},
Examples: []*core.Example{
{
Short: "List all clusters on your default region",
Raw: `scw k8s cluster list`,
},
{
Short: "List the ready clusters on your default region",
Raw: `scw k8s cluster list status=ready`,
},
{
Short: "List the clusters that match the given name on fr-par ('cluster1' will return 'cluster100' and 'cluster1' but not 'foo')",
Raw: `scw k8s cluster list region=fr-par name=cluster1`,
},
},
View: &core.View{Fields: []*core.ViewField{
{
FieldName: "ID",
},
{
FieldName: "Name",
},
{
FieldName: "Status",
},
{
FieldName: "Version",
},
{
FieldName: "Region",
},
{
FieldName: "ProjectID",
},
{
FieldName: "Tags",
},
{
FieldName: "Cni",
},
{
FieldName: "Description",
},
{
FieldName: "ClusterURL",
},
{
FieldName: "CreatedAt",
},
{
FieldName: "UpdatedAt",
},
{
FieldName: "Type",
},
}},
}
}
func k8sClusterCreate() *core.Command {
return &core.Command{
Short: `Create a new Cluster`,
Long: `Create a new Kubernetes cluster in a Scaleway region.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.CreateClusterRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
{
Name: "type",
Short: `Type of the cluster (possible values are kapsule, multicloud, kapsule-dedicated-8, kapsule-dedicated-16)`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "name",
Short: `Cluster name`,
Required: true,
Deprecated: false,
Positional: false,
Default: core.RandomValueGenerator("k8s"),
},
{
Name: "description",
Short: `Cluster description`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `Tags associated with the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "version",
Short: `Kubernetes version of the cluster`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "cni",
Short: `Container Network Interface (CNI) plugin running in the cluster`,
Required: true,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_cni", "cilium", "calico", "weave", "flannel", "kilo"},
},
{
Name: "enable-dashboard",
Short: `Defines whether the Kubernetes Dashboard is enabled in the cluster`,
Required: false,
Deprecated: true,
Positional: false,
},
{
Name: "ingress",
Short: `Ingress Controller running in the cluster (deprecated feature)`,
Required: false,
Deprecated: true,
Positional: false,
EnumValues: []string{"unknown_ingress", "none", "nginx", "traefik", "traefik2"},
},
{
Name: "pools.{index}.name",
Short: `Name of the pool`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.node-type",
Short: `Node type is the type of Scaleway Instance wanted for the pool. Nodes with insufficient memory are not eligible (DEV1-S, PLAY2-PICO, STARDUST). 'external' is a special node type used to provision instances from other cloud providers in a Kosmos Cluster`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.placement-group-id",
Short: `Placement group ID in which all the nodes of the pool will be created`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.autoscaling",
Short: `Defines whether the autoscaling feature is enabled for the pool`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.size",
Short: `Size (number of nodes) of the pool`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.min-size",
Short: `Defines the minimum size of the pool. Note that this field is only used when autoscaling is enabled on the pool`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.max-size",
Short: `Defines the maximum size of the pool. Note that this field is only used when autoscaling is enabled on the pool`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.container-runtime",
Short: `Customization of the container runtime is available for each pool. Note that ` + "`" + `docker` + "`" + ` has been deprecated since version 1.20 and will be removed by version 1.24`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_runtime", "docker", "containerd", "crio"},
},
{
Name: "pools.{index}.autohealing",
Short: `Defines whether the autohealing feature is enabled for the pool`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.tags.{index}",
Short: `Tags associated with the pool`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.kubelet-args.{key}",
Short: `Kubelet arguments to be used by this pool. Note that this feature is experimental`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.upgrade-policy.max-unavailable",
Short: `The maximum number of nodes that can be not ready at the same time`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.upgrade-policy.max-surge",
Short: `The maximum number of nodes to be created during the upgrade`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.zone",
Short: `Zone in which the pool's nodes will be spawned`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.root-volume-type",
Short: `Defines the system volume disk type. Two different types of volume (` + "`" + `volume_type` + "`" + `) are provided: ` + "`" + `l_ssd` + "`" + ` is a local block storage which means your system is stored locally on your node's hypervisor. ` + "`" + `b_ssd` + "`" + ` is a remote block storage which means your system is stored on a centralized and resilient cluster`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"default_volume_type", "l_ssd", "b_ssd"},
},
{
Name: "pools.{index}.root-volume-size",
Short: `System volume disk size`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.scale-down-disabled",
Short: `Disable the cluster autoscaler`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.scale-down-delay-after-add",
Short: `How long after scale up that scale down evaluation resumes`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.estimator",
Short: `Type of resource estimator to be used in scale up`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_estimator", "binpacking"},
},
{
Name: "autoscaler-config.expander",
Short: `Type of node group expander to be used in scale up`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_expander", "random", "most_pods", "least_waste", "priority", "price"},
},
{
Name: "autoscaler-config.ignore-daemonsets-utilization",
Short: `Ignore DaemonSet pods when calculating resource utilization for scaling down`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.balance-similar-node-groups",
Short: `Detect similar node groups and balance the number of nodes between them`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.expendable-pods-priority-cutoff",
Short: `Pods with priority below cutoff will be expendable. They can be killed without any consideration during scale down and they won't cause scale up. Pods with null priority (PodPriority disabled) are non expendable`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.scale-down-unneeded-time",
Short: `How long a node should be unneeded before it is eligible to be scaled down`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.scale-down-utilization-threshold",
Short: `Node utilization level, defined as a sum of requested resources divided by capacity, below which a node can be considered for scale down`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.max-graceful-termination-sec",
Short: `Maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "auto-upgrade.enable",
Short: `Defines whether auto upgrade is enabled for the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "auto-upgrade.maintenance-window.start-hour",
Short: `Start time of the two-hour maintenance window`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "auto-upgrade.maintenance-window.day",
Short: `Day of the week for the maintenance window`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"any", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"},
},
{
Name: "feature-gates.{index}",
Short: `List of feature gates to enable`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "admission-plugins.{index}",
Short: `List of admission plugins to enable`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.issuer-url",
Short: `URL of the provider which allows the API server to discover public signing keys. Only URLs using the ` + "`" + `https://` + "`" + ` scheme are accepted. This is typically the provider's discovery URL without a path, for example "https://accounts.google.com" or "https://login.salesforce.com"`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.client-id",
Short: `A client ID that all tokens must be issued for`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.username-claim",
Short: `JWT claim to use as the user name. The default is ` + "`" + `sub` + "`" + `, which is expected to be the end user's unique identifier. Admins can choose other claims, such as ` + "`" + `email` + "`" + ` or ` + "`" + `name` + "`" + `, depending on their provider. However, claims other than ` + "`" + `email` + "`" + ` will be prefixed with the issuer URL to prevent name collision`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.username-prefix",
Short: `Prefix prepended to username claims to prevent name collision (such as ` + "`" + `system:` + "`" + ` users). For example, the value ` + "`" + `oidc:` + "`" + ` will create usernames like ` + "`" + `oidc:jane.doe` + "`" + `. If this flag is not provided and ` + "`" + `username_claim` + "`" + ` is a value other than ` + "`" + `email` + "`" + `, the prefix defaults to ` + "`" + `( Issuer URL )#` + "`" + ` where ` + "`" + `( Issuer URL )` + "`" + ` is the value of ` + "`" + `issuer_url` + "`" + `. The value ` + "`" + `-` + "`" + ` can be used to disable all prefixing`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.groups-claim.{index}",
Short: `JWT claim to use as the user's group`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.groups-prefix",
Short: `Prefix prepended to group claims to prevent name collision (such as ` + "`" + `system:` + "`" + ` groups). For example, the value ` + "`" + `oidc:` + "`" + ` will create group names like ` + "`" + `oidc:engineering` + "`" + ` and ` + "`" + `oidc:infra` + "`" + ``,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.required-claim.{index}",
Short: `Multiple key=value pairs describing a required claim in the ID token. If set, the claims are verified to be present in the ID token with a matching value`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "apiserver-cert-sans.{index}",
Short: `Additional Subject Alternative Names for the Kubernetes API server certificate`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "private-network-id",
Short: `Private network ID for internal cluster communication (cannot be changed later)`,
Required: false,
Deprecated: false,
Positional: false,
},
core.OrganizationIDArgSpec(),
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*k8s.CreateClusterRequest)
client := core.ExtractClient(ctx)
api := k8s.NewAPI(client)
return api.CreateCluster(request)
},
Examples: []*core.Example{
{
Short: "Create a Kubernetes cluster named foo with cilium as CNI, in version 1.27.0 and with a pool named default composed of 3 DEV1-M",
Raw: `scw k8s cluster create name=foo version=1.27.0 pools.0.size=3 pools.0.node-type=DEV1-M pools.0.name=default`,
},
{
Short: "Create a Kubernetes cluster named bar, tagged, calico as CNI, in version 1.27.0 and with a tagged pool named default composed of 2 RENDER-S and autohealing and autoscaling enabled (between 1 and 10 nodes)",
Raw: `scw k8s cluster create name=bar version=1.27.0 tags.0=tag1 tags.1=tag2 cni=calico pools.0.size=2 pools.0.node-type=RENDER-S pools.0.min-size=1 pools.0.max-size=10 pools.0.autohealing=true pools.0.autoscaling=true pools.0.tags.0=pooltag1 pools.0.tags.1=pooltag2 pools.0.name=default`,
},
},
}
}
func k8sClusterGet() *core.Command {
return &core.Command{
Short: `Get a Cluster`,
Long: `Retrieve information about a specific Kubernetes cluster.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "get",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.GetClusterRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "cluster-id",
Short: `ID of the requested cluster`,
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.GetClusterRequest)
client := core.ExtractClient(ctx)
api := k8s.NewAPI(client)
return api.GetCluster(request)
},
Examples: []*core.Example{
{
Short: "Get a cluster information",
Raw: `scw k8s cluster get 11111111-1111-1111-111111111111`,
},
},
}
}
func k8sClusterUpdate() *core.Command {
return &core.Command{
Short: `Update a Cluster`,
Long: `Update information on a specific Kubernetes cluster. You can update details such as its name, description, tags and configuration. To upgrade a cluster, you will need to use the dedicated endpoint.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.UpdateClusterRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "cluster-id",
Short: `ID of the cluster to update`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "name",
Short: `New external name for the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "description",
Short: `New description for the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `New tags associated with the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.scale-down-disabled",
Short: `Disable the cluster autoscaler`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.scale-down-delay-after-add",
Short: `How long after scale up that scale down evaluation resumes`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.estimator",
Short: `Type of resource estimator to be used in scale up`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_estimator", "binpacking"},
},
{
Name: "autoscaler-config.expander",
Short: `Type of node group expander to be used in scale up`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_expander", "random", "most_pods", "least_waste", "priority", "price"},
},
{
Name: "autoscaler-config.ignore-daemonsets-utilization",
Short: `Ignore DaemonSet pods when calculating resource utilization for scaling down`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.balance-similar-node-groups",
Short: `Detect similar node groups and balance the number of nodes between them`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.expendable-pods-priority-cutoff",
Short: `Pods with priority below cutoff will be expendable. They can be killed without any consideration during scale down and they won't cause scale up. Pods with null priority (PodPriority disabled) are non expendable`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.scale-down-unneeded-time",
Short: `How long a node should be unneeded before it is eligible to be scaled down`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.scale-down-utilization-threshold",
Short: `Node utilization level, defined as a sum of requested resources divided by capacity, below which a node can be considered for scale down`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.max-graceful-termination-sec",
Short: `Maximum number of seconds the cluster autoscaler waits for pod termination when trying to scale down a node`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "enable-dashboard",
Short: `New value for the Kubernetes Dashboard enablement`,
Required: false,
Deprecated: true,
Positional: false,
},
{
Name: "ingress",
Short: `New Ingress Controller for the cluster (deprecated feature)`,
Required: false,
Deprecated: true,
Positional: false,
EnumValues: []string{"unknown_ingress", "none", "nginx", "traefik", "traefik2"},
},
{
Name: "auto-upgrade.enable",
Short: `Defines whether auto upgrade is enabled for the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "auto-upgrade.maintenance-window.start-hour",
Short: `Start time of the two-hour maintenance window`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "auto-upgrade.maintenance-window.day",
Short: `Day of the week for the maintenance window`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"any", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"},
},
{
Name: "feature-gates.{index}",
Short: `List of feature gates to enable`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "admission-plugins.{index}",
Short: `List of admission plugins to enable`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.issuer-url",
Short: `URL of the provider which allows the API server to discover public signing keys. Only URLs using the ` + "`" + `https://` + "`" + ` scheme are accepted. This is typically the provider's discovery URL without a path, for example "https://accounts.google.com" or "https://login.salesforce.com"`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.client-id",
Short: `A client ID that all tokens must be issued for`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.username-claim",
Short: `JWT claim to use as the user name. The default is ` + "`" + `sub` + "`" + `, which is expected to be the end user's unique identifier. Admins can choose other claims, such as ` + "`" + `email` + "`" + ` or ` + "`" + `name` + "`" + `, depending on their provider. However, claims other than ` + "`" + `email` + "`" + ` will be prefixed with the issuer URL to prevent name collision`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.username-prefix",
Short: `Prefix prepended to username claims to prevent name collision (such as ` + "`" + `system:` + "`" + ` users). For example, the value ` + "`" + `oidc:` + "`" + ` will create usernames like ` + "`" + `oidc:jane.doe` + "`" + `. If this flag is not provided and ` + "`" + `username_claim` + "`" + ` is a value other than ` + "`" + `email` + "`" + `, the prefix defaults to ` + "`" + `( Issuer URL )#` + "`" + ` where ` + "`" + `( Issuer URL )` + "`" + ` is the value of ` + "`" + `issuer_url` + "`" + `. The value ` + "`" + `-` + "`" + ` can be used to disable all prefixing`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.groups-claim.{index}",
Short: `JWT claim to use as the user's group`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.groups-prefix",
Short: `Prefix prepended to group claims to prevent name collision (such as ` + "`" + `system:` + "`" + ` groups). For example, the value ` + "`" + `oidc:` + "`" + ` will create group names like ` + "`" + `oidc:engineering` + "`" + ` and ` + "`" + `oidc:infra` + "`" + ``,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.required-claim.{index}",
Short: `Multiple key=value pairs describing a required claim in the ID token. If set, the claims are verified to be present in the ID token with a matching value`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "apiserver-cert-sans.{index}",
Short: `Additional Subject Alternative Names for the Kubernetes API server certificate`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*k8s.UpdateClusterRequest)
client := core.ExtractClient(ctx)
api := k8s.NewAPI(client)
return api.UpdateCluster(request)
},
Examples: []*core.Example{
{
Short: "Enable dashboard on a cluster",
Raw: `scw k8s cluster update 11111111-1111-1111-111111111111 enable-dashboard=true`,
},
{
Short: "Add TTLAfterFinished and ServiceNodeExclusion as feature gates on a cluster",
Raw: `scw k8s cluster update 11111111-1111-1111-111111111111 feature-gates.0=TTLAfterFinished feature-gates.1=ServiceNodeExclusion`,
},
},
}
}
func k8sClusterDelete() *core.Command {
return &core.Command{
Short: `Delete a Cluster`,
Long: `Delete a specific Kubernetes cluster and all its associated pools and nodes. Note that this method will not delete any Load Balancer or Block Volume that are associated with the cluster.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "delete",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.DeleteClusterRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "cluster-id",
Short: `ID of the cluster to delete`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "with-additional-resources",
Short: `Defines whether all volumes (including retain volume type), empty Private Networks and Load Balancers with a name starting with the cluster ID will also be deleted`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*k8s.DeleteClusterRequest)
client := core.ExtractClient(ctx)
api := k8s.NewAPI(client)
return api.DeleteCluster(request)
},
Examples: []*core.Example{
{
Short: "Delete a cluster",
Raw: `scw k8s cluster delete 11111111-1111-1111-111111111111`,
},
{
Short: "Delete a cluster with its Block volumes and Load Balancers",
Raw: `scw k8s cluster delete 11111111-1111-1111-111111111111 with-additional-resources=true`,
},
},
}
}
func k8sClusterUpgrade() *core.Command {
return &core.Command{
Short: `Upgrade a Cluster`,
Long: `Upgrade a specific Kubernetes cluster and possibly its associated pools to a specific and supported Kubernetes version.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "upgrade",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.UpgradeClusterRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "cluster-id",
Short: `ID of the cluster to upgrade`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "version",
Short: `New Kubernetes version of the cluster. Note that the version should either be a higher patch version of the same minor version or the direct minor version after the current one`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "upgrade-pools",
Short: `Defines whether pools will also be upgraded once the control plane is upgraded`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*k8s.UpgradeClusterRequest)
client := core.ExtractClient(ctx)
api := k8s.NewAPI(client)
return api.UpgradeCluster(request)
},
Examples: []*core.Example{
{
Short: "Upgrade a cluster version 1.27.0 of Kubernetes (pools *are not* included)",
Raw: `scw k8s cluster upgrade 11111111-1111-1111-111111111111 version=1.27.0`,
},
{
Short: "Upgrade a cluster to version 1.27.0 of Kubernetes (pools *are* included)",
Raw: `scw k8s cluster upgrade 11111111-1111-1111-111111111111 version=1.27.0 upgrade-pools=true`,
},
},
}
}
func k8sClusterSetType() *core.Command {
return &core.Command{
Short: `Change the Cluster type`,
Long: `Change the type of a specific Kubernetes cluster.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "set-type",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.SetClusterTypeRequest{}),
ArgSpecs: core.ArgSpecs{