forked from scaleway/scaleway-cli
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathk8s_cli.go
More file actions
1763 lines (1693 loc) · 50 KB
/
k8s_cli.go
File metadata and controls
1763 lines (1693 loc) · 50 KB
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/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(),
k8sClusterListAvailableVersions(),
k8sClusterResetAdminToken(),
k8sPoolList(),
k8sPoolCreate(),
k8sPoolGet(),
k8sPoolUpgrade(),
k8sPoolUpdate(),
k8sPoolDelete(),
k8sNodeList(),
k8sNodeGet(),
k8sNodeReplace(),
k8sNodeReboot(),
k8sVersionList(),
k8sVersionGet(),
)
}
func k8sRoot() *core.Command {
return &core.Command{
Short: `Kapsule API`,
Long: ``,
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 current number of nodes), nodes number limits (min, max) and a Scaleway instance type.
Changing those limits increases/decreases the size of a pool. Thus, when autoscaling is enabled, the pool will grow or shrink inside those limits, depending on its load.
A "default pool" is automatically created with every cluster.
`,
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.
It is part of a pool and is instantiated by Scaleway, making Kubernetes software installed and configured automatically on it.
Please note that Kubernetes nodes cannot be accessed with ssh.
`,
Namespace: "k8s",
Resource: "node",
}
}
func k8sVersion() *core.Command {
return &core.Command{
Short: `Available Kubernetes version commands`,
Long: `A version is a vanilla Kubernetes version like ` + "`" + `x.y.z` + "`" + `.
It is composed of a major version x, a minor version y and a patch version z.
Scaleway's managed Kubernetes, Kapsule, will at least support the last patch version for the last three minor release.
Also each version have a different set of container runtimes, CNIs, ingresses, feature gates and admission plugins available.
`,
Namespace: "k8s",
Resource: "version",
}
}
func k8sClusterList() *core.Command {
return &core.Command{
Short: `List all the clusters`,
Long: `This method allows to list all the existing Kubernetes clusters in an account.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "list",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.ListClustersRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "project-id",
Short: `The project ID on which to filter the returned clusters`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "order-by",
Short: `The sort order of the 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: `The name on which to filter the returned clusters`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "status",
Short: `The status on which to filter the returned clusters`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown", "creating", "ready", "deleting", "deleted", "updating", "locked", "pool_required"},
},
{
Name: "organization-id",
Short: `The organization ID on which to filter the returned clusters`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*k8s.ListClustersRequest)
client := core.ExtractClient(ctx)
api := k8s.NewAPI(client)
resp, err := api.ListClusters(request, scw.WithAllPages())
if err != nil {
return nil, err
}
return resp.Clusters, nil
},
Examples: []*core.Example{
{
Short: "List all the clusters on your default region",
ArgsJSON: `null`,
},
{
Short: "List the ready clusters on your default region",
ArgsJSON: `{"status":"ready"}`,
},
{
Short: "List the clusters that match the given name on fr-par ('cluster1' will return 'cluster100' and 'cluster1' but not 'foo')",
ArgsJSON: `{"name":"cluster1","region":"fr-par"}`,
},
},
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",
},
}},
}
}
func k8sClusterCreate() *core.Command {
return &core.Command{
Short: `Create a new cluster`,
Long: `This method allows to create a new Kubernetes cluster on an account.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "create",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.CreateClusterRequest{}),
ArgSpecs: core.ArgSpecs{
core.ProjectIDArgSpec(),
{
Name: "name",
Short: `The name of the cluster`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "description",
Short: `The description of the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `The tags associated with the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "version",
Short: `The Kubernetes version of the cluster`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "cni",
Short: `The Container Network Interface (CNI) plugin that will run in the cluster`,
Required: true,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_cni", "cilium", "calico", "weave", "flannel"},
},
{
Name: "enable-dashboard",
Short: `The enablement of the Kubernetes Dashboard in the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ingress",
Short: `The Ingress Controller that will run in the cluster`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_ingress", "none", "nginx", "traefik", "traefik2"},
},
{
Name: "pools.{index}.name",
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.node-type",
Short: `The node type is the type of Scaleway Instance wanted for the pool`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.placement-group-id",
Short: `The 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: `The enablement of the autoscaling feature for the pool`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.size",
Short: `The size (number of nodes) of the pool`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.min-size",
Short: `The minimun size of the pool`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.max-size",
Short: `The maximum size of the pool`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.container-runtime",
Short: `The container runtime for the nodes of the pool`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_runtime", "docker", "containerd", "crio"},
},
{
Name: "pools.{index}.autohealing",
Short: `The enablement of the autohealing feature for the pool`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.tags.{index}",
Short: `The tags associated with the pool`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "pools.{index}.kubelet-args.{key}",
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"},
},
{
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`,
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 for scale down`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.scale-down-utilization-threshold",
Short: `Node utilization level, defined as 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: `Whether or not auto upgrade is enabled for the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "auto-upgrade.maintenance-window.start-hour",
Short: `The start hour of the 2-hour maintenance window`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "auto-upgrade.maintenance-window.day",
Short: `The 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`,
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`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.username-prefix",
Short: `Prefix prepended to username`,
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`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.required-claim.{index}",
Short: `Multiple key=value pairs that describes a required claim in the ID Token`,
Required: false,
Deprecated: false,
Positional: false,
},
core.OrganizationIDArgSpec(),
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
},
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.17.4 and with a pool named default composed of 3 DEV1-M",
Raw: `scw k8s cluster create name=foo version=1.17.4 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.17.4 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.17.4 tags.0=tag1 tags.1=tag2 cni=cilium 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: `This method allows to get details 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: `The ID of the requested cluster`,
Required: true,
Deprecated: false,
Positional: true,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
},
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 given cluster",
Raw: `scw k8s cluster get 11111111-1111-1111-111111111111`,
},
},
}
}
func k8sClusterUpdate() *core.Command {
return &core.Command{
Short: `Update a cluster`,
Long: `This method allows to update a specific Kubernetes cluster. Note that this method is not made to upgrade a Kubernetes cluster.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "update",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.UpdateClusterRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "cluster-id",
Short: `The ID of the cluster to update`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "name",
Short: `The new name of the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "description",
Short: `The new description of the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "tags.{index}",
Short: `The 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"},
},
{
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`,
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 for scale down`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "autoscaler-config.scale-down-utilization-threshold",
Short: `Node utilization level, defined as 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: `The new value of the Kubernetes Dashboard enablement`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "ingress",
Short: `The new Ingress Controller for the cluster`,
Required: false,
Deprecated: false,
Positional: false,
EnumValues: []string{"unknown_ingress", "none", "nginx", "traefik", "traefik2"},
},
{
Name: "auto-upgrade.enable",
Short: `Whether or not auto upgrade is enabled for the cluster`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "auto-upgrade.maintenance-window.start-hour",
Short: `The start hour of the 2-hour maintenance window`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "auto-upgrade.maintenance-window.day",
Short: `The 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`,
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`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.username-prefix",
Short: `Prefix prepended to username`,
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`,
Required: false,
Deprecated: false,
Positional: false,
},
{
Name: "open-id-connect-config.required-claim.{index}",
Short: `Multiple key=value pairs that describes a required claim in the ID Token`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
},
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 given cluster",
Raw: `scw k8s cluster update 11111111-1111-1111-111111111111 enable-dashboard=true`,
},
{
Short: "Add TTLAfterFinished and ServiceNodeExclusion as feature gates on a given 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: `This method allows to delete a specific cluster and all its associated pools and nodes. Note that this method will not delete any Load Balancers or Block Volumes 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: `The ID of the cluster to delete`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "with-additional-resources",
Short: `Set true if you want to delete all volumes (including retain volume type) and loadbalancers whose name start with cluster ID`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
},
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 given cluster",
Raw: `scw k8s cluster delete 11111111-1111-1111-111111111111`,
},
},
}
}
func k8sClusterUpgrade() *core.Command {
return &core.Command{
Short: `Upgrade a cluster`,
Long: `This method allows to upgrade a specific Kubernetes cluster and/or 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: `The ID of the cluster to upgrade`,
Required: true,
Deprecated: false,
Positional: true,
},
{
Name: "version",
Short: `The new Kubernetes version of the cluster`,
Required: true,
Deprecated: false,
Positional: false,
},
{
Name: "upgrade-pools",
Short: `The enablement of the pools upgrade`,
Required: false,
Deprecated: false,
Positional: false,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
},
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 given cluster to Kubernetes version 1.17.4 (without upgrading the pools)",
Raw: `scw k8s cluster upgrade 11111111-1111-1111-111111111111 version=1.17.4`,
},
{
Short: "Upgrade a given cluster to Kubernetes version 1.17.4 (and upgrade the pools)",
Raw: `scw k8s cluster upgrade 11111111-1111-1111-111111111111 version=1.17.4 upgrade-pools=true`,
},
},
}
}
func k8sClusterListAvailableVersions() *core.Command {
return &core.Command{
Short: `List available versions for a cluster`,
Long: `This method allows to list the versions that a specific Kubernetes cluster is allowed to upgrade to. Note that it will be every patch version greater than the actual one as well a one minor version ahead of the actual one. Upgrades skipping a minor version will not work.`,
Namespace: "k8s",
Resource: "cluster",
Verb: "list-available-versions",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.ListClusterAvailableVersionsRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "cluster-id",
Short: `The ID of the cluster which the available Kuberentes versions will be listed from`,
Required: true,
Deprecated: false,
Positional: true,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*k8s.ListClusterAvailableVersionsRequest)
client := core.ExtractClient(ctx)
api := k8s.NewAPI(client)
return api.ListClusterAvailableVersions(request)
},
Examples: []*core.Example{
{
Short: "List all available versions for a given cluster to upgrade to",
Raw: `scw k8s cluster list-available-versions 11111111-1111-1111-111111111111`,
},
},
View: &core.View{Fields: []*core.ViewField{
{
FieldName: "Name",
},
{
FieldName: "Label",
},
{
FieldName: "AvailableIngresses",
},
{
FieldName: "AvailableContainerRuntimes",
},
}},
}
}
func k8sClusterResetAdminToken() *core.Command {
return &core.Command{
Short: `Reset the admin token of a cluster`,
Long: `This method allows to reset the admin token for a specific Kubernetes cluster. This will invalidate the old admin token (which will not be usable after) and create a new one. Note that the redownload of the kubeconfig will be necessary to keep interacting with the cluster (if the old admin token was used).`,
Namespace: "k8s",
Resource: "cluster",
Verb: "reset-admin-token",
// Deprecated: false,
ArgsType: reflect.TypeOf(k8s.ResetClusterAdminTokenRequest{}),
ArgSpecs: core.ArgSpecs{
{
Name: "cluster-id",
Short: `The ID of the cluster of which the admin token will be renewed`,
Required: true,
Deprecated: false,
Positional: true,
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
},
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
request := args.(*k8s.ResetClusterAdminTokenRequest)
client := core.ExtractClient(ctx)
api := k8s.NewAPI(client)
e = api.ResetClusterAdminToken(request)
if e != nil {
return nil, e
}
return &core.SuccessResult{
Resource: "cluster",
Verb: "reset-admin-token",
}, nil
},
Examples: []*core.Example{
{
Short: "Reset the admin token for a given cluster",
Raw: `scw k8s cluster reset-admin-token 11111111-1111-1111-111111111111`,
},
},
}
}
func k8sPoolList() *core.Command {