-
Notifications
You must be signed in to change notification settings - Fork 6
/
cluster.go
1895 lines (1690 loc) · 67.1 KB
/
cluster.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
package cmd
import (
"encoding/base64"
"fmt"
"io"
"log"
"net"
"net/http"
"os"
"sort"
"strconv"
"strings"
"time"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/sets"
"github.com/fatih/color"
"github.com/fi-ts/cloud-go/api/client/cluster"
"github.com/gosimple/slug"
"github.com/metal-stack/metal-lib/auth"
"github.com/metal-stack/metal-lib/pkg/pointer"
"github.com/fi-ts/cloud-go/api/models"
"github.com/fi-ts/cloudctl/cmd/completion"
"github.com/fi-ts/cloudctl/cmd/helper"
"github.com/fi-ts/cloudctl/cmd/output"
"github.com/fi-ts/cloudctl/pkg/api"
"github.com/Masterminds/semver/v3"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/gardener/gardener/pkg/apis/core/v1beta1"
"github.com/gardener/gardener/pkg/apis/core/v1beta1/constants"
utiltaints "github.com/gardener/machine-controller-manager/pkg/util/taints"
)
type auditConfigOptionsMap map[string]struct {
Config *models.V1Audit
Description string
}
func (a auditConfigOptionsMap) Names(withDescription bool) []string {
var names []string
for name, opt := range a {
if withDescription {
names = append(names, fmt.Sprintf("%s\t%s", name, opt.Description))
} else {
names = append(names, name)
}
}
return names
}
var (
// options
auditConfigOptions = auditConfigOptionsMap{
"off": {
Description: "turn off the kube-apiserver auditlog",
Config: &models.V1Audit{
ClusterAudit: pointer.Pointer(false),
AuditToSplunk: pointer.Pointer(false),
},
},
"on": {
Description: "turn on the kube-apiserver auditlog, and expose it as container log of the audittailer deployment in the audit namespace",
Config: &models.V1Audit{
ClusterAudit: pointer.Pointer(true),
AuditToSplunk: pointer.Pointer(false),
},
},
"splunk": {
Description: "also forward the auditlog to a splunk HEC endpoint. create a custom splunk config manifest with \"cloudctl cluster splunk-config-manifest\"",
Config: &models.V1Audit{
ClusterAudit: pointer.Pointer(true),
AuditToSplunk: pointer.Pointer(true),
},
},
}
)
func newClusterCmd(c *config) *cobra.Command {
clusterCmd := &cobra.Command{
Use: "cluster",
Short: "manage clusters",
Long: "TODO",
}
clusterCreateCmd := &cobra.Command{
Use: "create",
Short: "create a cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterCreate()
},
PreRun: bindPFlags,
}
clusterListCmd := &cobra.Command{
Use: "list",
Short: "list clusters",
Aliases: []string{"ls"},
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterList()
},
PreRun: bindPFlags,
}
clusterDeleteCmd := &cobra.Command{
Use: "delete <clusterid>",
Short: "delete a cluster",
Aliases: []string{"destroy", "rm", "remove"},
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterDelete(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterDescribeCmd := &cobra.Command{
Use: "describe <clusterid>",
Short: "describe a cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterDescribe(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterKubeconfigCmd := &cobra.Command{
Use: "kubeconfig <clusterid>",
Short: "get cluster kubeconfig",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterKubeconfig(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterReconcileCmd := &cobra.Command{
Use: "reconcile <clusterid>",
Short: "trigger cluster reconciliation",
RunE: func(cmd *cobra.Command, args []string) error {
return c.reconcileCluster(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterUpdateCmd := &cobra.Command{
Use: "update <clusterid>",
Short: "update a cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.updateCluster(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterInputsCmd := &cobra.Command{
Use: "inputs",
Short: "get possible cluster inputs like k8s versions, etc.",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterInputs()
},
PreRun: bindPFlags,
}
clusterMachineCmd := &cobra.Command{
Use: "machine",
Aliases: []string{"machines"},
Short: "list and access machines in the cluster",
}
clusterMachineListCmd := &cobra.Command{
Use: "ls <clusterid>",
Aliases: []string{"list"},
Short: "list machines of the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterMachines(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterIssuesCmd := &cobra.Command{
Use: "issues [<clusterid>]",
Aliases: []string{"problems", "warnings"},
Short: "lists cluster issues, shows required actions explicitly when id argument is given",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterIssues(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterMonitoringSecretCmd := &cobra.Command{
Use: "monitoring-secret <clusterid>",
Short: "returns the endpoint and access credentials to the monitoring of the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterMonitoringSecret(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterMachineSSHCmd := &cobra.Command{
Use: "ssh <clusterid>",
Short: "ssh access a machine/firewall of the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterMachineSSH(args, false)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterMachineConsoleCmd := &cobra.Command{
Use: "console <clusterid>",
Short: "console access a machine/firewall of the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterMachineSSH(args, true)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterMachineResetCmd := &cobra.Command{
Use: "reset <clusterid>",
Short: "hard power reset of a machine/firewall of the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterMachineReset(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterMachineCycleCmd := &cobra.Command{
Use: "cycle <clusterid>",
Short: "soft power cycle of a machine/firewall of the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterMachineCycle(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterMachineReinstallCmd := &cobra.Command{
Use: "reinstall <clusterid>",
Short: "reinstall OS image onto a machine/firewall of the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterMachineReinstall(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterMachinePackagesCmd := &cobra.Command{
Use: "packages <clusterid>",
Short: "show packages of the os image which is installed on this machine",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterMachinePackages(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterLogsCmd := &cobra.Command{
Use: "logs <clusterid>",
Short: "get logs for the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterLogs(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterSplunkConfigManifestCmd := &cobra.Command{
Use: "splunk-config-manifest",
Short: "create a manifest for a custom splunk configuration, overriding the default settings for splunk auditing",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterSplunkConfigManifest()
},
PreRun: bindPFlags,
}
clusterDNSManifestCmd := &cobra.Command{
Use: "dns-manifest <clusterid>",
Short: "create a manifest for an ingress or service type loadbalancer, creating a DNS entry and valid certificate within your cluster domain",
RunE: func(cmd *cobra.Command, args []string) error {
return c.clusterDNSManifest(args)
},
ValidArgsFunction: c.comp.ClusterListCompletion,
PreRun: bindPFlags,
}
clusterCreateCmd.Flags().String("name", "", "name of the cluster, max 10 characters. [required]")
clusterCreateCmd.Flags().String("description", "", "description of the cluster. [optional]")
clusterCreateCmd.Flags().String("project", "", "project where this cluster should belong to. [required]")
clusterCreateCmd.Flags().String("partition", "", "partition of the cluster. [required]")
clusterCreateCmd.Flags().String("seed", "", "name of seed where this cluster should be scheduled. [optional]")
clusterCreateCmd.Flags().String("purpose", "evaluation", fmt.Sprintf("purpose of the cluster, can be one of %s. SLA is only given on production clusters. [optional]", strings.Join(completion.ClusterPurposes, "|")))
clusterCreateCmd.Flags().String("version", "", "kubernetes version of the cluster. defaults to latest available, check cluster inputs for possible values. [optional]")
clusterCreateCmd.Flags().String("machinetype", "", "machine type to use for the nodes. [optional]")
clusterCreateCmd.Flags().String("machineimage", "", "machine image to use for the nodes, must be in the form of <name>-<version> [optional]")
clusterCreateCmd.Flags().String("firewalltype", "", "machine type to use for the firewall. [optional]")
clusterCreateCmd.Flags().String("firewallimage", "", "machine image to use for the firewall. [optional]")
clusterCreateCmd.Flags().String("firewallcontroller", "", "version of the firewall-controller to use. [optional]")
clusterCreateCmd.Flags().BoolP("logacceptedconns", "", false, "also log accepted connections on the cluster firewall [optional]")
clusterCreateCmd.Flags().String("cri", "", "container runtime to use, only docker|containerd supported as alternative actually. [optional]")
clusterCreateCmd.Flags().Int32("minsize", 1, "minimal workers of the cluster.")
clusterCreateCmd.Flags().Int32("maxsize", 1, "maximal workers of the cluster.")
clusterCreateCmd.Flags().String("maxsurge", "1", "max number (e.g. 1) or percentage (e.g. 10%) of workers created during a update of the cluster.")
clusterCreateCmd.Flags().String("maxunavailable", "0", "max number (e.g. 0) or percentage (e.g. 10%) of workers that can be unavailable during a update of the cluster.")
clusterCreateCmd.Flags().StringSlice("labels", []string{}, "labels of the cluster")
clusterCreateCmd.Flags().StringSlice("external-networks", []string{}, "external networks of the cluster")
clusterCreateCmd.Flags().StringSlice("egress", []string{}, "static egress ips per network, must be in the form <network>:<ip>; e.g.: --egress internet:1.2.3.4,extnet:123.1.1.1 --egress internet:1.2.3.5 [optional]")
clusterCreateCmd.Flags().BoolP("allowprivileged", "", false, "allow privileged containers the cluster (this is achieved through pod security policies and has no effect anymore on clusters >= v1.25")
clusterCreateCmd.Flags().String("default-pod-security-standard", "", "sets default pod security standard for clusters >= v1.23.x, defaults to restricted on clusters >= v1.25 (valid values: empty string, privileged, baseline, restricted)")
clusterCreateCmd.Flags().String("audit", "on", "audit logging of cluster API access; can be off, on (default) or splunk (logging to a predefined or custom splunk endpoint). [optional]")
clusterCreateCmd.Flags().Duration("healthtimeout", 0, "period (e.g. \"24h\") after which an unhealthy node is declared failed and will be replaced. [optional]")
clusterCreateCmd.Flags().Duration("draintimeout", 0, "period (e.g. \"3h\") after which a draining node will be forcefully deleted. [optional]")
clusterCreateCmd.Flags().Bool("encrypted-storage-classes", false, "enables the deployment of encrypted duros storage classes into the cluster. please refer to the user manual to properly use volume encryption. [optional]")
clusterCreateCmd.Flags().BoolP("reversed-vpn", "", false, "enables usage of reversed-vpn instead of konnectivity tunnel for worker connectivity. [optional]")
clusterCreateCmd.Flags().BoolP("autoupdate-kubernetes", "", false, "enables automatic updates of the kubernetes patch version of the cluster [optional]")
clusterCreateCmd.Flags().BoolP("autoupdate-machineimages", "", false, "enables automatic updates of the worker node images of the cluster, be aware that this deletes worker nodes! [optional]")
clusterCreateCmd.Flags().String("default-storage-class", "", "set default storage class to given name, must be one of the managed storage classes")
clusterCreateCmd.Flags().String("max-pods-per-node", "", "set number of maximum pods per node (default: 510). Lower numbers allow for more node per cluster. [optional]")
clusterCreateCmd.Flags().String("cni", "", "the network plugin used in this cluster, defaults to calico. please note that cilium support is still Alpha and we are happy to receive feedback. [optional]")
must(clusterCreateCmd.MarkFlagRequired("name"))
must(clusterCreateCmd.MarkFlagRequired("project"))
must(clusterCreateCmd.MarkFlagRequired("partition"))
must(clusterCreateCmd.RegisterFlagCompletionFunc("project", c.comp.ProjectListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("partition", c.comp.PartitionListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("seed", c.comp.SeedListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("external-networks", c.comp.NetworkListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("version", c.comp.VersionListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("machinetype", c.comp.MachineTypeListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("machineimage", c.comp.MachineImageListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("firewalltype", c.comp.FirewallTypeListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("firewallimage", c.comp.FirewallImageListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("firewallcontroller", c.comp.FirewallControllerVersionListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("purpose", c.comp.ClusterPurposeListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("default-pod-security-standard", c.comp.PodSecurityListCompletion))
must(clusterCreateCmd.RegisterFlagCompletionFunc("cri", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{"docker", "containerd"}, cobra.ShellCompDirectiveNoFileComp
}))
must(clusterCreateCmd.RegisterFlagCompletionFunc("cni", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{
"calico\tcalico networking plugin. this is the cluster default.",
"cilium\tcilium networking plugin. please note that cilium support is still Alpha and we are happy to receive feedback.",
}, cobra.ShellCompDirectiveNoFileComp
}))
must(clusterCreateCmd.RegisterFlagCompletionFunc("audit", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return auditConfigOptions.Names(true),
cobra.ShellCompDirectiveNoFileComp
}))
clusterDescribeCmd.Flags().Bool("no-machines", false, "does not return in the output")
// Cluster list --------------------------------------------------------------------
clusterListCmd.Flags().String("id", "", "show clusters of given id")
clusterListCmd.Flags().String("name", "", "show clusters of given name")
clusterListCmd.Flags().String("project", "", "show clusters of given project")
clusterListCmd.Flags().String("partition", "", "show clusters in partition")
clusterListCmd.Flags().String("seed", "", "show clusters in seed")
clusterListCmd.Flags().String("tenant", "", "show clusters of given tenant")
clusterListCmd.Flags().StringSlice("labels", nil, "show clusters of given labels")
clusterListCmd.Flags().String("purpose", "", "show clusters of given purpose")
must(clusterListCmd.RegisterFlagCompletionFunc("id", c.comp.ClusterListCompletion))
must(clusterListCmd.RegisterFlagCompletionFunc("name", c.comp.ClusterNameCompletion))
must(clusterListCmd.RegisterFlagCompletionFunc("project", c.comp.ProjectListCompletion))
must(clusterListCmd.RegisterFlagCompletionFunc("partition", c.comp.PartitionListCompletion))
must(clusterListCmd.RegisterFlagCompletionFunc("seed", c.comp.SeedListCompletion))
must(clusterListCmd.RegisterFlagCompletionFunc("tenant", c.comp.TenantListCompletion))
must(clusterListCmd.RegisterFlagCompletionFunc("purpose", c.comp.ClusterPurposeListCompletion))
// Cluster update --------------------------------------------------------------------
clusterUpdateCmd.Flags().String("workergroup", "", "the name of the worker group to apply updates to, only required when there are multiple worker groups.")
clusterUpdateCmd.Flags().Bool("remove-workergroup", false, "if set, removes the targeted worker group")
clusterUpdateCmd.Flags().StringSlice("workerlabels", []string{}, "labels of the worker group (syncs to kubernetes node resource after some time, too)")
clusterUpdateCmd.Flags().StringSlice("workerannotations", []string{}, "annotations of the worker group (syncs to kubernetes node resource after some time, too)")
clusterUpdateCmd.Flags().StringSlice("workertaints", []string{}, "list of taints to set for nodes of the worker group. (use empty string to remove previous set taints)")
clusterUpdateCmd.Flags().String("workerversion", "", "set custom kubernetes version of the worker group independent of the api server. note that the worker version may only be two minor version older than the api server as stated in the official kubernetes version skew policy. (set to \"\" to remove custom kubernetes version)")
clusterUpdateCmd.Flags().Int32("minsize", 0, "minimal workers of the cluster.")
clusterUpdateCmd.Flags().Int32("maxsize", 0, "maximal workers of the cluster.")
clusterUpdateCmd.Flags().String("version", "", "kubernetes version of the cluster.")
clusterUpdateCmd.Flags().String("seed", "", "name of seed where this cluster should be scheduled.")
clusterUpdateCmd.Flags().String("firewalltype", "", "machine type to use for the firewall.")
clusterUpdateCmd.Flags().String("firewallimage", "", "machine image to use for the firewall.")
clusterUpdateCmd.Flags().String("firewallcontroller", "", "version of the firewall-controller to use.")
clusterUpdateCmd.Flags().BoolP("logacceptedconns", "", false, "enables logging of accepted connections on the cluster firewall")
clusterUpdateCmd.Flags().String("machinetype", "", "machine type to use for the nodes.")
clusterUpdateCmd.Flags().String("machineimage", "", "machine image to use for the nodes, must be in the form of <name>-<version> ")
clusterUpdateCmd.Flags().StringSlice("addlabels", []string{}, "labels to add to the cluster")
clusterUpdateCmd.Flags().StringSlice("removelabels", []string{}, "labels to remove from the cluster")
clusterUpdateCmd.Flags().BoolP("allowprivileged", "", false, "allow privileged containers the cluster (this is achieved through pod security policies and has no effect anymore on clusters >=v1.25")
clusterUpdateCmd.Flags().String("default-pod-security-standard", "", "set default pod security standard for cluster >=v 1.23.x, send empty string explicitly to disable pod security standards (valid values: empty string, privileged, baseline, restricted)")
clusterUpdateCmd.Flags().String("audit", "on", "audit logging of cluster API access; can be off, on or splunk (logging to a predefined or custom splunk endpoint).")
clusterUpdateCmd.Flags().String("purpose", "", fmt.Sprintf("purpose of the cluster, can be one of %s. SLA is only given on production clusters.", strings.Join(completion.ClusterPurposes, "|")))
clusterUpdateCmd.Flags().StringSlice("egress", []string{}, "static egress ips per network, must be in the form <networkid>:<semicolon-separated ips>; e.g.: --egress internet:1.2.3.4;1.2.3.5 --egress extnet:123.1.1.1 [optional]. Use --egress none to remove all egress rules.")
clusterUpdateCmd.Flags().StringSlice("external-networks", []string{}, "external networks of the cluster")
clusterUpdateCmd.Flags().Duration("healthtimeout", 0, "period (e.g. \"24h\") after which an unhealthy node is declared failed and will be replaced. (0 = provider-default)")
clusterUpdateCmd.Flags().Duration("draintimeout", 0, "period (e.g. \"3h\") after which a draining node will be forcefully deleted. (0 = provider-default)")
clusterUpdateCmd.Flags().String("maxsurge", "", "max number (e.g. 1) or percentage (e.g. 10%) of workers created during a update of the cluster.")
clusterUpdateCmd.Flags().String("maxunavailable", "", "max number (e.g. 0) or percentage (e.g. 10%) of workers that can be unavailable during a update of the cluster.")
clusterUpdateCmd.Flags().BoolP("autoupdate-kubernetes", "", false, "enables automatic updates of the kubernetes patch version of the cluster")
clusterUpdateCmd.Flags().BoolP("autoupdate-machineimages", "", false, "enables automatic updates of the worker node images of the cluster, be aware that this deletes worker nodes!")
clusterUpdateCmd.Flags().BoolP("reversed-vpn", "", false, "enables usage of reversed-vpn instead of konnectivity tunnel for worker connectivity.")
clusterUpdateCmd.Flags().Bool("encrypted-storage-classes", false, "enables the deployment of encrypted duros storage classes into the cluster. please refer to the user manual to properly use volume encryption.")
clusterUpdateCmd.Flags().String("default-storage-class", "", "set default storage class to given name, must be one of the managed storage classes")
clusterUpdateCmd.Flags().BoolP("disable-custom-default-storage-class", "", false, "if set to true, no default class is deployed, you have to set one of your storageclasses manually to default")
must(clusterUpdateCmd.RegisterFlagCompletionFunc("version", c.comp.VersionListCompletion))
must(clusterUpdateCmd.RegisterFlagCompletionFunc("workerversion", c.comp.VersionListCompletion))
must(clusterUpdateCmd.RegisterFlagCompletionFunc("firewalltype", c.comp.FirewallTypeListCompletion))
must(clusterUpdateCmd.RegisterFlagCompletionFunc("firewallimage", c.comp.FirewallImageListCompletion))
must(clusterUpdateCmd.RegisterFlagCompletionFunc("seed", c.comp.SeedListCompletion))
must(clusterUpdateCmd.RegisterFlagCompletionFunc("firewallcontroller", c.comp.FirewallControllerVersionListCompletion))
must(clusterUpdateCmd.RegisterFlagCompletionFunc("machinetype", c.comp.MachineTypeListCompletion))
must(clusterUpdateCmd.RegisterFlagCompletionFunc("machineimage", c.comp.MachineImageListCompletion))
must(clusterUpdateCmd.RegisterFlagCompletionFunc("purpose", c.comp.ClusterPurposeListCompletion))
must(clusterUpdateCmd.RegisterFlagCompletionFunc("default-pod-security-standard", c.comp.PodSecurityListCompletion))
must(clusterUpdateCmd.RegisterFlagCompletionFunc("audit", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return auditConfigOptions.Names(true),
cobra.ShellCompDirectiveNoFileComp
}))
clusterInputsCmd.Flags().String("partition", "", "partition of the constraints.")
must(clusterInputsCmd.RegisterFlagCompletionFunc("partition", c.comp.PartitionListCompletion))
// Cluster splunk config manifest --------------------------------------------------------------------
clusterSplunkConfigManifestCmd.Flags().String("token", "", "the hec token to use for this cluster's audit logs")
clusterSplunkConfigManifestCmd.Flags().String("index", "", "the splunk index to use for this cluster's audit logs")
clusterSplunkConfigManifestCmd.Flags().String("hechost", "", "the hostname or IP of the splunk HEC endpoint")
clusterSplunkConfigManifestCmd.Flags().Int("hecport", 0, "port on which the splunk HEC endpoint is listening")
clusterSplunkConfigManifestCmd.Flags().Bool("tls", false, "whether to use TLS encryption. You do need to specify a CA file.")
clusterSplunkConfigManifestCmd.Flags().String("cafile", "", "the path to the file containing the ca certificate (chain) for the splunk HEC endpoint")
clusterSplunkConfigManifestCmd.Flags().String("cabase64", "", "the base64-encoded ca certificate (chain) for the splunk HEC endpoint")
// Cluster dns manifest --------------------------------------------------------------------
clusterDNSManifestCmd.Flags().String("type", "ingress", "either of type ingress or service")
clusterDNSManifestCmd.Flags().String("name", "<name>", "the resource name")
clusterDNSManifestCmd.Flags().String("namespace", "default", "the resource's namespace")
clusterDNSManifestCmd.Flags().Int("ttl", 180, "the ttl set to the created dns entry")
clusterDNSManifestCmd.Flags().Bool("with-certificate", true, "whether to request a let's encrypt certificate for the requested dns entry or not")
clusterDNSManifestCmd.Flags().String("backend-name", "my-backend", "the name of the backend")
clusterDNSManifestCmd.Flags().Int32("backend-port", 443, "the port of the backend")
clusterDNSManifestCmd.Flags().String("ingress-class", "nginx", "the ingress class name")
must(clusterDNSManifestCmd.RegisterFlagCompletionFunc("type", cobra.FixedCompletions([]string{"ingress", "service"}, cobra.ShellCompDirectiveNoFileComp)))
// Cluster machine ... --------------------------------------------------------------------
clusterMachineSSHCmd.Flags().String("machineid", "", "machine to connect to.")
must(clusterMachineSSHCmd.MarkFlagRequired("machineid"))
must(clusterMachineSSHCmd.RegisterFlagCompletionFunc("machineid", c.comp.ClusterFirewallListCompletion))
clusterMachineConsoleCmd.Flags().String("machineid", "", "machine to connect to.")
must(clusterMachineConsoleCmd.MarkFlagRequired("machineid"))
must(clusterMachineConsoleCmd.RegisterFlagCompletionFunc("machineid", c.comp.ClusterMachineListCompletion))
clusterMachineResetCmd.Flags().String("machineid", "", "machine to reset.")
must(clusterMachineResetCmd.MarkFlagRequired("machineid"))
must(clusterMachineResetCmd.RegisterFlagCompletionFunc("machineid", c.comp.ClusterMachineListCompletion))
clusterMachineCycleCmd.Flags().String("machineid", "", "machine to reset.")
must(clusterMachineCycleCmd.MarkFlagRequired("machineid"))
must(clusterMachineCycleCmd.RegisterFlagCompletionFunc("machineid", c.comp.ClusterMachineListCompletion))
clusterMachineReinstallCmd.Flags().String("machineid", "", "machine to reinstall.")
clusterMachineReinstallCmd.Flags().String("machineimage", "", "image to reinstall (optional).")
must(clusterMachineReinstallCmd.MarkFlagRequired("machineid"))
must(clusterMachineReinstallCmd.RegisterFlagCompletionFunc("machineid", c.comp.ClusterMachineListCompletion))
clusterMachinePackagesCmd.Flags().String("machineid", "", "machine to connect to.")
must(clusterMachinePackagesCmd.MarkFlagRequired("machineid"))
must(clusterMachinePackagesCmd.RegisterFlagCompletionFunc("machineid", c.comp.ClusterMachineListCompletion))
clusterMachineCmd.AddCommand(clusterMachineListCmd)
clusterMachineCmd.AddCommand(clusterMachineSSHCmd)
clusterMachineCmd.AddCommand(clusterMachineConsoleCmd)
clusterMachineCmd.AddCommand(clusterMachineResetCmd)
clusterMachineCmd.AddCommand(clusterMachineCycleCmd)
clusterMachineCmd.AddCommand(clusterMachineReinstallCmd)
clusterMachineCmd.AddCommand(clusterMachinePackagesCmd)
clusterReconcileCmd.Flags().String("operation", models.V1ClusterReconcileRequestOperationReconcile, "Executes a cluster \"reconcile\" operation.")
must(clusterReconcileCmd.RegisterFlagCompletionFunc("operation", c.comp.ClusterReconcileOperationCompletion))
clusterIssuesCmd.Flags().String("id", "", "show clusters of given id")
clusterIssuesCmd.Flags().String("name", "", "show clusters of given name")
clusterIssuesCmd.Flags().String("project", "", "show clusters of given project")
clusterIssuesCmd.Flags().String("partition", "", "show clusters in partition")
clusterIssuesCmd.Flags().String("tenant", "", "show clusters of given tenant")
must(clusterIssuesCmd.RegisterFlagCompletionFunc("name", c.comp.ClusterNameCompletion))
must(clusterIssuesCmd.RegisterFlagCompletionFunc("project", c.comp.ProjectListCompletion))
must(clusterIssuesCmd.RegisterFlagCompletionFunc("partition", c.comp.PartitionListCompletion))
must(clusterIssuesCmd.RegisterFlagCompletionFunc("tenant", c.comp.TenantListCompletion))
clusterKubeconfigCmd.Flags().Bool("merge", false, "merges the cluster's kubeconfig into the current active kubeconfig, otherwise an individual kubeconfig is printed to console only")
clusterKubeconfigCmd.Flags().Bool("set-context", false, "when setting the merge parameter to true, immediately activates the cluster's context")
clusterCmd.AddCommand(clusterCreateCmd)
clusterCmd.AddCommand(clusterListCmd)
clusterCmd.AddCommand(clusterKubeconfigCmd)
clusterCmd.AddCommand(clusterDeleteCmd)
clusterCmd.AddCommand(clusterDescribeCmd)
clusterCmd.AddCommand(clusterInputsCmd)
clusterCmd.AddCommand(clusterReconcileCmd)
clusterCmd.AddCommand(clusterUpdateCmd)
clusterCmd.AddCommand(clusterMachineCmd)
clusterCmd.AddCommand(clusterLogsCmd)
clusterCmd.AddCommand(clusterIssuesCmd)
clusterCmd.AddCommand(clusterSplunkConfigManifestCmd)
clusterCmd.AddCommand(clusterDNSManifestCmd)
clusterCmd.AddCommand(clusterMonitoringSecretCmd)
return clusterCmd
}
func (c *config) clusterCreate() error {
name := viper.GetString("name")
desc := viper.GetString("description")
partition := viper.GetString("partition")
seed := viper.GetString("seed")
project := viper.GetString("project")
purpose := viper.GetString("purpose")
machineType := viper.GetString("machinetype")
machineImageAndVersion := viper.GetString("machineimage")
firewallType := viper.GetString("firewalltype")
firewallImage := viper.GetString("firewallimage")
firewallController := viper.GetString("firewallcontroller")
logAcceptedConnections := strconv.FormatBool(viper.GetBool("logacceptedconns"))
encryptedStorageClasses := strconv.FormatBool(viper.GetBool("encrypted-storage-classes"))
cri := viper.GetString("cri")
var cni string
if viper.IsSet("cni") {
cni = viper.GetString("cni")
}
minsize := viper.GetInt32("minsize")
maxsize := viper.GetInt32("maxsize")
maxsurge := viper.GetString("maxsurge")
maxunavailable := viper.GetString("maxunavailable")
healthtimeout := viper.GetDuration("healthtimeout")
draintimeout := viper.GetDuration("draintimeout")
var allowprivileged *bool
if viper.IsSet("allowprivileged") {
allowprivileged = pointer.Pointer(viper.GetBool("allowprivileged"))
}
var defaultPodSecurityStandard *string
if viper.IsSet("default-pod-security-standard") {
defaultPodSecurityStandard = pointer.Pointer(viper.GetString("default-pod-security-standard"))
}
audit := viper.GetString("audit")
labels := viper.GetStringSlice("labels")
// FIXME helper and validation
networks := viper.GetStringSlice("external-networks")
egress := viper.GetStringSlice("egress")
maintenanceBegin := "220000+0100"
maintenanceEnd := "233000+0100"
reversedVPN := strconv.FormatBool(viper.GetBool("reversed-vpn"))
version := viper.GetString("version")
if version == "" {
request := cluster.NewListConstraintsParams()
constraints, err := c.cloud.Cluster.ListConstraints(request, nil)
if err != nil {
return err
}
availableVersions := constraints.Payload.KubernetesVersions
if len(availableVersions) == 0 {
log.Fatalf("no kubernetes versions available to deploy")
}
sortedVersions := make([]*semver.Version, len(availableVersions))
for i, r := range availableVersions {
v, err := semver.NewVersion(r)
if err != nil {
log.Fatalf("Error parsing version: %s", err)
}
sortedVersions[i] = v
}
sort.Sort(semver.Collection(sortedVersions))
version = sortedVersions[len(sortedVersions)-1].String()
}
machineImage := models.V1MachineImage{}
if machineImageAndVersion != "" {
machineImageParts := strings.Split(machineImageAndVersion, "-")
if len(machineImageParts) == 2 {
machineImage = models.V1MachineImage{
Name: &machineImageParts[0],
Version: &machineImageParts[1],
}
} else {
log.Fatalf("given machineimage:%s is invalid must be in the form <name>-<version>", machineImageAndVersion)
}
}
labelMap, err := helper.LabelsToMap(labels)
if err != nil {
log.Fatal(err)
}
switch cri {
case "containerd":
case "docker":
case "":
default:
log.Fatalf("provided cri:%s is not supported, only docker or containerd at the moment", cri)
}
auditConfig, ok := auditConfigOptions[audit]
if !ok {
return fmt.Errorf("audit value %s is not supported; choose one of %v", audit, auditConfigOptions.Names(false))
}
var customDefaultStorageClass *models.V1CustomDefaultStorageClass
if viper.IsSet("default-storage-class") {
class := viper.GetString("default-storage-class")
customDefaultStorageClass = &models.V1CustomDefaultStorageClass{
ClassName: &class,
}
}
scr := &models.V1ClusterCreateRequest{
ProjectID: &project,
Name: &name,
Labels: labelMap,
Description: &desc,
Purpose: &purpose,
Workers: []*models.V1Worker{
{
Minimum: &minsize,
Maximum: &maxsize,
MaxSurge: &maxsurge,
MaxUnavailable: &maxunavailable,
MachineType: &machineType,
MachineImage: &machineImage,
CRI: &cri,
},
},
FirewallSize: &firewallType,
FirewallImage: &firewallImage,
FirewallControllerVersion: &firewallController,
Kubernetes: &models.V1Kubernetes{
AllowPrivilegedContainers: allowprivileged,
Version: &version,
DefaultPodSecurityStandard: defaultPodSecurityStandard,
},
Audit: auditConfig.Config,
Maintenance: &models.V1Maintenance{
TimeWindow: &models.V1MaintenanceTimeWindow{
Begin: &maintenanceBegin,
End: &maintenanceEnd,
},
},
AdditionalNetworks: networks,
PartitionID: &partition,
ClusterFeatures: &models.V1ClusterFeatures{
ReversedVPN: &reversedVPN,
LogAcceptedConnections: &logAcceptedConnections,
DurosStorageEncryption: &encryptedStorageClasses,
},
CustomDefaultStorageClass: customDefaultStorageClass,
Cni: cni,
}
if viper.IsSet("autoupdate-kubernetes") || viper.IsSet("autoupdate-machineimages") || purpose == string(v1beta1.ShootPurposeEvaluation) {
scr.Maintenance.AutoUpdate = &models.V1MaintenanceAutoUpdate{}
// default to true for evaluation clusters
if purpose == string(v1beta1.ShootPurposeEvaluation) {
scr.Maintenance.AutoUpdate.KubernetesVersion = pointer.Pointer(true)
}
if viper.IsSet("autoupdate-kubernetes") {
auto := viper.GetBool("autoupdate-kubernetes")
scr.Maintenance.AutoUpdate.KubernetesVersion = &auto
}
if viper.IsSet("autoupdate-machineimages") {
auto := viper.GetBool("autoupdate-machineimages")
scr.Maintenance.AutoUpdate.MachineImage = &auto
}
}
if viper.IsSet("max-pods-per-node") {
scr.Kubernetes.MaxPodsPerNode = viper.GetInt32("max-pods-per-node")
}
if seed != "" {
scr.SeedName = seed
}
egressRules := makeEgressRules(egress)
if len(egressRules) > 0 {
scr.EgressRules = egressRules
}
if healthtimeout != 0 {
scr.Workers[0].HealthTimeout = int64(healthtimeout)
}
if draintimeout != 0 {
scr.Workers[0].DrainTimeout = int64(draintimeout)
}
request := cluster.NewCreateClusterParams()
request.SetBody(scr)
shoot, err := c.cloud.Cluster.CreateCluster(request, nil)
if err != nil {
return err
}
return output.New().Print(shoot.Payload)
}
func (c *config) clusterList() error {
id := viper.GetString("id")
name := viper.GetString("name")
tenant := viper.GetString("tenant")
partition := viper.GetString("partition")
seed := viper.GetString("seed")
project := viper.GetString("project")
purpose := viper.GetString("purpose")
labels := viper.GetStringSlice("labels")
var cfr *models.V1ClusterFindRequest
if id != "" || name != "" || tenant != "" || partition != "" || seed != "" || project != "" || purpose != "" || len(labels) > 0 {
cfr = &models.V1ClusterFindRequest{}
if id != "" {
cfr.ID = &id
}
if name != "" {
cfr.Name = &name
}
if tenant != "" {
cfr.Tenant = &tenant
}
if project != "" {
cfr.ProjectID = &project
}
if partition != "" {
cfr.PartitionID = &partition
}
if seed != "" {
cfr.SeedName = &seed
}
if purpose != "" {
cfr.Purpose = &purpose
}
if len(labels) > 0 {
labelMap := map[string]string{}
for _, l := range labels {
parts := strings.SplitN(l, "=", 2)
if len(parts) != 2 {
log.Fatalf("provided labels must be in the form <key>=<value>, found: %s", l)
}
labelMap[parts[0]] = parts[1]
}
cfr.Labels = labelMap
}
}
if cfr != nil {
fcp := cluster.NewFindClustersParams()
fcp.SetBody(cfr)
response, err := c.cloud.Cluster.FindClusters(fcp, nil)
if err != nil {
return err
}
return output.New().Print(response.Payload)
}
request := cluster.NewListClustersParams()
shoots, err := c.cloud.Cluster.ListClusters(request, nil)
if err != nil {
return err
}
return output.New().Print(shoots.Payload)
}
func (c *config) clusterKubeconfig(args []string) error {
id, err := c.clusterID("credentials", args)
if err != nil {
return err
}
request := cluster.NewGetClusterKubeconfigTplParams()
request.SetID(id)
credentials, err := c.cloud.Cluster.GetClusterKubeconfigTpl(request, nil)
if err != nil {
return err
}
kubeconfigTpl := *credentials.Payload.Kubeconfig // is a kubeconfig with only a single cluster entry
kubeconfigFile := viper.GetString("kubeconfig")
authContext, err := api.GetAuthContext(kubeconfigFile)
if err != nil {
return err
}
if !authContext.AuthProviderOidc {
return fmt.Errorf("active user %s has no oidc authProvider, check config", authContext.User)
}
if !viper.GetBool("merge") {
mergedKubeconfig, err := helper.EnrichKubeconfigTpl(kubeconfigTpl, authContext)
if err != nil {
return err
}
fmt.Println(string(mergedKubeconfig))
return nil
}
currentCfg, filename, _, err := auth.LoadKubeConfig(kubeconfigFile)
if err != nil {
return err
}
clusterResp, err := c.cloud.Cluster.FindCluster(cluster.NewFindClusterParams().WithID(id), nil)
if err != nil {
return err
}
contextName := slug.Make(*clusterResp.Payload.Name)
if viper.GetBool("set-context") {
auth.SetCurrentContext(currentCfg, contextName)
}
mergedKubeconfig, err := helper.MergeKubeconfigTpl(currentCfg, kubeconfigTpl, contextName, *clusterResp.Payload.Name, authContext)
if err != nil {
return err
}
err = os.WriteFile(filename, mergedKubeconfig, 0600)
if err != nil {
return err
}
fmt.Printf("%s merged context %q into %s\n", color.GreenString("✔"), contextName, filename)
return nil
}
type sshkeypair struct {
privatekey []byte
publickey []byte
vpn *models.V1VPN
}
func (c *config) sshKeyPair(clusterID string) (*sshkeypair, error) {
request := cluster.NewGetSSHKeyPairParams()
request.SetID(clusterID)
credentials, err := c.cloud.Cluster.GetSSHKeyPair(request, nil)
if err != nil {
return nil, err
}
privateKey, err := base64.StdEncoding.DecodeString(*credentials.Payload.SSHKeyPair.PrivateKey)
if err != nil {
return nil, err
}
publicKey, err := base64.StdEncoding.DecodeString(*credentials.Payload.SSHKeyPair.PublicKey)
if err != nil {
return nil, err
}
return &sshkeypair{
privatekey: privateKey,
publickey: publicKey,
vpn: credentials.Payload.VPN,
}, nil
}
func (c *config) reconcileCluster(args []string) error {
ci, err := c.clusterID("reconcile", args)
if err != nil {
return err
}
request := cluster.NewReconcileClusterParams()
request.SetID(ci)
operation := viper.GetString("operation")
request.Body = &models.V1ClusterReconcileRequest{Operation: &operation}
shoot, err := c.cloud.Cluster.ReconcileCluster(request, nil)
if err != nil {
return err
}
return output.New().Print(shoot.Payload)
}
func (c *config) updateCluster(args []string) error {
ci, err := c.clusterID("update", args)
if err != nil {
return err
}
workergroupname := viper.GetString("workergroup")
removeworkergroup := viper.GetBool("remove-workergroup")
workerlabelslice := viper.GetStringSlice("workerlabels")
workerannotationsslice := viper.GetStringSlice("workerannotations")
workertaintsslice := viper.GetStringSlice("workertaints")
minsize := viper.GetInt32("minsize")
maxsize := viper.GetInt32("maxsize")
version := viper.GetString("version")
seed := viper.GetString("seed")
firewallType := viper.GetString("firewalltype")
firewallImage := viper.GetString("firewallimage")
firewallController := viper.GetString("firewallcontroller")
firewallNetworks := viper.GetStringSlice("external-networks")
logAcceptedConnections := strconv.FormatBool(viper.GetBool("logacceptedconns"))
machineType := viper.GetString("machinetype")
machineImageAndVersion := viper.GetString("machineimage")
purpose := viper.GetString("purpose")
addLabels := viper.GetStringSlice("addlabels")
removeLabels := viper.GetStringSlice("removelabels")
egress := viper.GetStringSlice("egress")
maxsurge := viper.GetString("maxsurge")
maxunavailable := viper.GetString("maxunavailable")
defaultStorageClass := viper.GetString("default-storage-class")
disableDefaultStorageClass := viper.GetBool("disable-custom-default-storage-class")
reversedVPN := strconv.FormatBool(viper.GetBool("reversed-vpn"))
encryptedStorageClasses := strconv.FormatBool(viper.GetBool("encrypted-storage-classes"))
workerlabels, err := helper.LabelsToMap(workerlabelslice)
if err != nil {
return err
}
workerannotations, err := helper.LabelsToMap(workerannotationsslice)
if err != nil {
return err
}
coreworkertaints, _, err := utiltaints.ParseTaints(workertaintsslice)
if err != nil {
return fmt.Errorf("specified taints are invalid: %w", err)
}
var workertaints []*models.V1Taint
for _, t := range coreworkertaints {
t := t
workertaints = append(workertaints, &models.V1Taint{
Key: &t.Key,
Value: t.Value,
Effect: (*string)(&t.Effect),
})
}
findRequest := cluster.NewFindClusterParams()
findRequest.SetID(ci)
resp, err := c.cloud.Cluster.FindCluster(findRequest, nil)
if err != nil {
return err
}
current := resp.Payload
healthtimeout := viper.GetDuration("healthtimeout")
draintimeout := viper.GetDuration("draintimeout")
customDefaultStorageClass := current.CustomDefaultStorageClass
if viper.IsSet("default-storage-class") && disableDefaultStorageClass {
return fmt.Errorf("either default-storage-class or disable-custom-default-storage-class may be specified, not both")
}
if disableDefaultStorageClass {
customDefaultStorageClass = nil
}
if viper.IsSet("default-storage-class") {
customDefaultStorageClass = &models.V1CustomDefaultStorageClass{
ClassName: &defaultStorageClass,
}
}
var clusterFeatures models.V1ClusterFeatures
if viper.IsSet("encrypted-storage-classes") {
clusterFeatures.DurosStorageEncryption = &encryptedStorageClasses
}
if viper.IsSet("reversed-vpn") {
clusterFeatures.ReversedVPN = &reversedVPN
}
if viper.IsSet("logacceptedconns") {
clusterFeatures.LogAcceptedConnections = &logAcceptedConnections
}
workergroupKubernetesVersion := viper.GetString("workerversion")
request := cluster.NewUpdateClusterParams()
cur := &models.V1ClusterUpdateRequest{
ID: &ci,
Maintenance: &models.V1Maintenance{
AutoUpdate: &models.V1MaintenanceAutoUpdate{
KubernetesVersion: current.Maintenance.AutoUpdate.KubernetesVersion,
MachineImage: current.Maintenance.AutoUpdate.MachineImage,
},
},
ClusterFeatures: &clusterFeatures,
CustomDefaultStorageClass: customDefaultStorageClass,
}
if workergroupname != "" ||