/
config.go
1200 lines (1061 loc) · 49 KB
/
config.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 eksconfig defines EKS test configuration.
package eksconfig
import (
"bytes"
"fmt"
"io/ioutil"
"path/filepath"
"sync"
"text/template"
"time"
"github.com/aws/aws-k8s-tester/ec2config"
awseks "github.com/aws/aws-sdk-go/service/eks"
"sigs.k8s.io/yaml"
)
const (
// DefaultNodeInstanceTypeCPU is the default EC2 instance type for CPU worker node.
DefaultNodeInstanceTypeCPU = "c5.xlarge"
// DefaultNodeInstanceTypeGPU is the default EC2 instance type for GPU worker node.
DefaultNodeInstanceTypeGPU = "p3.8xlarge"
// DefaultNodeVolumeSize is the default EC2 instance volume size for a worker node.
DefaultNodeVolumeSize = 40
// NGsMaxLimit is the maximum number of "Node Group"s per a EKS cluster.
NGsMaxLimit = 10
// NGMaxLimit is the maximum number of nodes per a "Node Group".
NGMaxLimit = 100
// MNGsMaxLimit is the maximum number of "Managed Node Group"s per a EKS cluster.
MNGsMaxLimit = 10
// MNGMaxLimit is the maximum number of nodes per a "Managed Node Group".
MNGMaxLimit = 100
)
const (
// AMITypeBottleRocketCPU is the default AMI type for Bottlerocket OS.
// https://github.com/bottlerocket-os/bottlerocket
AMITypeBottleRocketCPU = "BOTTLEROCKET_x86_64"
)
// Config defines EKS configuration.
type Config struct {
mu *sync.RWMutex
// ConfigPath is the configuration file path.
// Deployer is expected to update this file with latest status.
ConfigPath string `json:"config-path,omitempty"`
// KubectlCommandsOutputPath is the output path for kubectl commands.
KubectlCommandsOutputPath string `json:"kubectl-commands-output-path,omitempty"`
// RemoteAccessCommandsOutputPath is the output path for ssh commands.
RemoteAccessCommandsOutputPath string `json:"remote-access-commands-output-path,omitempty"`
// Region is the AWS geographic area for EKS deployment.
// If empty, set default region.
Region string `json:"region,omitempty"`
// Name is the cluster name.
// If empty, deployer auto-populates it.
Name string `json:"name,omitempty"`
// LogLevel configures log level. Only supports debug, info, warn, error, panic, or fatal. Default 'info'.
LogLevel string `json:"log-level"`
// LogOutputs is a list of log outputs. Valid values are 'default', 'stderr', 'stdout', or file names.
// Logs are appended to the existing file, if any.
// Multiple values are accepted. If empty, it sets to 'default', which outputs to stderr.
// See https://pkg.go.dev/go.uber.org/zap#Open and https://pkg.go.dev/go.uber.org/zap#Config for more details.
LogOutputs []string `json:"log-outputs,omitempty"`
// AWSCLIPath is the path for AWS CLI path.
AWSCLIPath string `json:"aws-cli-path,omitempty"`
// KubectlPath is the path to download the "kubectl".
KubectlPath string `json:"kubectl-path,omitempty"`
// KubectlDownloadURL is the download URL to download "kubectl" binary from.
// https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html
KubectlDownloadURL string `json:"kubectl-download-url,omitempty"`
// KubeConfigPath is the file path of KUBECONFIG for the EKS cluster.
// If empty, auto-generate one.
// Deployer is expected to delete this on cluster tear down.
KubeConfigPath string `json:"kubeconfig-path,omitempty"`
// AWSIAMAuthenticatorPath is the path to aws-iam-authenticator.
AWSIAMAuthenticatorPath string `json:"aws-iam-authenticator-path,omitempty"`
// AWSIAMAuthenticatorDownloadURL is the download URL to download "aws-iam-authenticator" binary from.
AWSIAMAuthenticatorDownloadURL string `json:"aws-iam-authenticator-download-url,omitempty"`
// OnFailureDelete is true to delete all resources on creation fail.
OnFailureDelete bool `json:"on-failure-delete"`
// OnFailureDeleteWaitSeconds is the seconds to wait before deleting
// all resources on creation fail.
OnFailureDeleteWaitSeconds uint64 `json:"on-failure-delete-wait-seconds"`
// CommandAfterCreateCluster is the command to execute after creating clusters.
CommandAfterCreateCluster string `json:"command-after-create-cluster,omitempty"`
CommandAfterCreateClusterOutputPath string `json:"command-after-create-cluster-output-path,omitempty" read-only:"true"`
// CommandAfterCreateAddOns is the command to execute after creating clusters and add-ons.
CommandAfterCreateAddOns string `json:"command-after-create-add-ons,omitempty"`
CommandAfterCreateAddOnsOutputPath string `json:"command-after-create-add-ons-output-path,omitempty" read-only:"true"`
// S3BucketName is the name of cluster S3.
S3BucketName string `json:"s3-bucket-name"`
// S3BucketCreate is true to auto-create S3 bucket.
S3BucketCreate bool `json:"s3-bucket-create"`
// S3BucketLifecycleExpirationDays is expiration in days for the lifecycle of the object.
S3BucketLifecycleExpirationDays int64 `json:"s3-bucket-lifecycle-expiration-days"`
// Parameters defines EKS "cluster" creation parameters.
// It's ok to leave any parameters empty.
// If empty, it will use default values.
Parameters *Parameters `json:"parameters,omitempty"`
// RemoteAccessKeyCreate is true to create the remote SSH access private key.
RemoteAccessKeyCreate bool `json:"remote-access-key-create"`
// RemoteAccessKeyName is the key name for node group SSH EC2 key pair.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
RemoteAccessKeyName string `json:"remote-access-key-name,omitempty"`
// RemoteAccessPrivateKeyPath is the file path to store node group key pair private key.
// Thus, deployer must delete the private key right after node group creation.
// MAKE SURE PRIVATE KEY NEVER GETS UPLOADED TO CLOUD STORAGE AND DELETE AFTER USE!!!
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
RemoteAccessPrivateKeyPath string `json:"remote-access-private-key-path,omitempty"`
// AddOnNodeGroups defines EKS "Node Group"
// creation parameters.
AddOnNodeGroups *AddOnNodeGroups `json:"add-on-node-groups,omitempty"`
// AddOnManagedNodeGroups defines EKS "Managed Node Group"
// creation parameters. If empty, it will use default values.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
AddOnManagedNodeGroups *AddOnManagedNodeGroups `json:"add-on-managed-node-groups,omitempty"`
// AddOnNLBHelloWorld defines parameters for EKS cluster
// add-on NLB hello-world service.
AddOnNLBHelloWorld *AddOnNLBHelloWorld `json:"add-on-nlb-hello-world,omitempty"`
// AddOnALB2048 defines parameters for EKS cluster
// add-on ALB 2048 service.
AddOnALB2048 *AddOnALB2048 `json:"add-on-alb-2048,omitempty"`
// AddOnJobPi defines parameters for EKS cluster
// add-on Job with pi Perl command.
AddOnJobPi *AddOnJobPi `json:"add-on-job-pi,omitempty"`
// AddOnJobEcho defines parameters for EKS cluster
// add-on Job with echo.
AddOnJobEcho *AddOnJobEcho `json:"add-on-job-echo,omitempty"`
// AddOnCronJob defines parameters for EKS cluster
// add-on with CronJob.
AddOnCronJob *AddOnCronJob `json:"add-on-cron-job,omitempty"`
// AddOnSecrets defines parameters for EKS cluster
// add-on "Secrets".
AddOnSecrets *AddOnSecrets `json:"add-on-secrets,omitempty"`
// AddOnIRSA defines parameters for EKS cluster
// add-on "IAM Roles for Service Accounts (IRSA)".
AddOnIRSA *AddOnIRSA `json:"add-on-irsa,omitempty"`
// AddOnFargate defines parameters for EKS cluster
// add-on "EKS on Fargate".
AddOnFargate *AddOnFargate `json:"add-on-fargate,omitempty"`
// AddOnAppMesh defines parameters for EKS cluster
// add-on "EKS App Mesh Integration".
AddOnAppMesh *AddOnAppMesh `json:"add-on-app-mesh,omitempty"`
// Status represents the current status of AWS resources.
// Status is read-only.
// Status cannot be configured via environmental variables.
Status *Status `json:"status,omitempty" read-only:"true"`
}
// Parameters defines parameters for EKS "cluster" creation.
type Parameters struct {
// RoleName is the name of cluster role.
RoleName string `json:"role-name"`
// RoleCreate is true to auto-create and delete cluster role.
RoleCreate bool `json:"role-create"`
// RoleARN is the role ARN that EKS uses to create AWS resources for Kubernetes.
// By default, it's empty which triggers tester to create one.
RoleARN string `json:"role-arn"`
// RoleServicePrincipals is the EKS Role Service Principals
RoleServicePrincipals []string `json:"role-service-principals"`
// RoleManagedPolicyARNs is EKS Role managed policy ARNs.
RoleManagedPolicyARNs []string `json:"role-managed-policy-arns"`
RoleCFNStackID string `json:"role-cfn-stack-id" read-only:"true"`
// Tags defines EKS create cluster tags.
Tags map[string]string `json:"tags"`
// RequestHeaderKey defines EKS create cluster request header key.
RequestHeaderKey string `json:"request-header-key"`
// RequestHeaderValue defines EKS create cluster request header value.
RequestHeaderValue string `json:"request-header-value"`
// ResolverURL defines an AWS resolver endpoint for EKS API.
// Must be left empty to use production EKS service.
ResolverURL string `json:"resolver-url"`
// SigningName is the EKS create request signing name.
SigningName string `json:"signing-name"`
// VPCCreate is true to auto-create and delete VPC.
VPCCreate bool `json:"vpc-create"`
// VPCID is the VPC ID for cluster creation.
// If not empty, VPC is reused and not deleted.
// If empty, VPC is created anew and deleted on cluster deletion.
VPCID string `json:"vpc-id"`
VPCCFNStackID string `json:"vpc-cfn-stack-id" read-only:"true"`
// VpcCIDR is the IP range (CIDR notation) for VPC, must be a valid private
// (RFC 1918) CIDR range.
VPCCIDR string `json:"vpc-cidr,omitempty"`
// PublicSubnetCIDR1 is the CIDR Block for subnet 1 within the VPC.
PublicSubnetCIDR1 string `json:"public-subnet-cidr-1,omitempty"`
// PublicSubnetCIDR2 is the CIDR Block for subnet 2 within the VPC.
PublicSubnetCIDR2 string `json:"public-subnet-cidr-2,omitempty"`
// PublicSubnetCIDR3 is the CIDR Block for subnet 3 within the VPC.
PublicSubnetCIDR3 string `json:"public-subnet-cidr-3,omitempty"`
// PrivateSubnetCIDR1 is the CIDR Block for subnet 1 within the VPC.
PrivateSubnetCIDR1 string `json:"private-subnet-cidr-1,omitempty"`
// PrivateSubnetCIDR2 is the CIDR Block for subnet 2 within the VPC.
PrivateSubnetCIDR2 string `json:"private-subnet-cidr-2,omitempty"`
// PublicSubnetIDs is the list of all public subnets in the VPC.
PublicSubnetIDs []string `json:"public-subnet-ids" read-only:"true"`
// PrivateSubnetIDs is the list of all private subnets in the VPC.
PrivateSubnetIDs []string `json:"private-subnet-ids" read-only:"true"`
// ControlPlaneSecurityGroupID is the security group ID for the cluster control
// plane communication with worker nodes.
ControlPlaneSecurityGroupID string `json:"control-plane-security-group-id" read-only:"true"`
// Version is the version of EKS Kubernetes "cluster".
// If empty, set default version.
Version string `json:"version"`
VersionValue float64 `json:"version-value" read-only:"true"`
// EncryptionCMKCreate is true to auto-create and delete KMS CMK
// for encryption feature.
EncryptionCMKCreate bool `json:"encryption-cmk-create"`
// EncryptionCMKARN is the KMS CMK ARN for encryption feature.
// If not empty, the cluster is created with encryption feature
// enabled.
EncryptionCMKARN string `json:"encryption-cmk-arn"`
}
// IsEnabledAddOnNodeGroups returns true if "AddOnNodeGroups" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnNodeGroups() bool {
if cfg.AddOnNodeGroups == nil {
return false
}
if cfg.AddOnNodeGroups.Enable {
return len(cfg.AddOnNodeGroups.ASGs) > 0
}
cfg.AddOnNodeGroups = nil
return false
}
// AddOnNodeGroups defines parameters for EKS "Managed Node Group" creation.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
type AddOnNodeGroups struct {
// Enable is true to auto-create ad node group.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// FetchLogs is true to fetch logs from remote nodes using SSH.
FetchLogs bool `json:"fetch-logs"`
// RoleName is the name of thed node group.
RoleName string `json:"role-name"`
// RoleCreate is true to auto-create and delete role.
RoleCreate bool `json:"role-create"`
// RoleARN is the role ARN that EKS node group uses to create AWS
// resources for Kubernetes.
// By default, it's empty which triggers tester to create one.
RoleARN string `json:"role-arn"`
// RoleServicePrincipals is the node group Service Principals
RoleServicePrincipals []string `json:"role-service-principals"`
// RoleManagedPolicyARNs is node groupd policy ARNs.
RoleManagedPolicyARNs []string `json:"role-managed-policy-arns"`
RoleCFNStackID string `json:"role-cfn-stack-id" read-only:"true"`
// NodeGroupSecurityGroupID is the security group ID for the node group.
NodeGroupSecurityGroupID string `json:"node-group-security-group-id" read-only:"true"`
NodeGroupSecurityGroupCFNStackID string `json:"node-group-security-group-cfn-stack-id" read-only:"true"`
// LogsDir is set to specify the target directory to store all remote log files.
// If empty, it stores in the same directory as "ConfigPath".
LogsDir string `json:"logs-dir,omitempty"`
// ASGs maps from EKS Node Group name to "ASG".
ASGs map[string]ec2config.ASG `json:"asgs,omitempty"`
}
// IsEnabledAddOnManagedNodeGroups returns true if "AddOnManagedNodeGroups" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnManagedNodeGroups() bool {
if cfg.AddOnManagedNodeGroups == nil {
return false
}
if cfg.AddOnManagedNodeGroups.Enable {
return len(cfg.AddOnManagedNodeGroups.MNGs) > 0
}
cfg.AddOnManagedNodeGroups = nil
return false
}
// AddOnManagedNodeGroups defines parameters for EKS "Managed Node Group" creation.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
type AddOnManagedNodeGroups struct {
// Enable is true to auto-create a managed node group.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// FetchLogs is true to fetch logs from remote nodes using SSH.
FetchLogs bool `json:"fetch-logs"`
// RoleName is the name of the managed node group.
RoleName string `json:"role-name"`
// RoleCreate is true to auto-create and delete role.
RoleCreate bool `json:"role-create"`
// RoleARN is the role ARN that EKS managed node group uses to create AWS
// resources for Kubernetes.
// By default, it's empty which triggers tester to create one.
RoleARN string `json:"role-arn"`
// RoleServicePrincipals is the node group Service Principals
RoleServicePrincipals []string `json:"role-service-principals"`
// RoleManagedPolicyARNs is node group managed policy ARNs.
RoleManagedPolicyARNs []string `json:"role-managed-policy-arns"`
RoleCFNStackID string `json:"role-cfn-stack-id" read-only:"true"`
// RequestHeaderKey defines EKS managed node group create cluster request header key.
RequestHeaderKey string `json:"request-header-key,omitempty"`
// RequestHeaderValue defines EKS managed node group create cluster request header value.
RequestHeaderValue string `json:"request-header-value,omitempty"`
// ResolverURL defines an AWS resolver endpoint for EKS API.
// Must be left empty to use production EKS managed node group service.
ResolverURL string `json:"resolver-url"`
// SigningName is the EKS managed node group create request signing name.
SigningName string `json:"signing-name"`
// LogsDir is set to specify the target directory to store all remote log files.
// If empty, it stores in the same directory as "ConfigPath".
LogsDir string `json:"logs-dir,omitempty"`
// MNGs maps from EKS Managed Node Group name to "MNG".
MNGs map[string]MNG `json:"mngs,omitempty"`
}
// MNG represents parameters for one EKS "Managed Node Group".
type MNG struct {
// Name is the name of the managed node group.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
Name string `json:"name,omitempty"`
// RemoteAccessUserName is the user name for managed node group SSH access.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
RemoteAccessUserName string `json:"remote-access-user-name,omitempty"`
// Tags defines EKS managed node group create tags.
Tags map[string]string `json:"tags,omitempty"`
// ReleaseVersion is the AMI version of the Amazon EKS-optimized AMI for the node group.
// The version may differ from EKS "cluster" version.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
ReleaseVersion string `json:"release-version,omitempty"`
// AMIType is the AMI type for the node group.
// Allowed values are AL2_x86_64 and AL2_x86_64_GPU.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
AMIType string `json:"ami-type,omitempty"`
// ASGMinSize is the minimum size of Node Group Auto Scaling Group.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
ASGMinSize int `json:"asg-min-size,omitempty"`
// ASGMaxSize is the maximum size of Node Group Auto Scaling Group.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
ASGMaxSize int `json:"asg-max-size,omitempty"`
// ASGDesiredCapacity is is the desired capacity of Node Group ASG.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
ASGDesiredCapacity int `json:"asg-desired-capacity,omitempty"`
// InstanceTypes is the EC2 instance types for the node instances.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
InstanceTypes []string `json:"instance-types,omitempty"`
// VolumeSize is the node volume size.
// ref. https://docs.aws.amazon.com/eks/latest/userguide/create-managed-node-group.html
// ref. https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-eks-nodegroup.html
VolumeSize int `json:"volume-size,omitempty"`
// CreateRequested is true if "CreateNodegroupRequest" has been sent.
CreateRequested bool `json:"create-requested" read-only:"true"`
// CFNStackID is the CloudFormation stack ID for a managed node group.
CFNStackID string `json:"cfn-stack-id" read-only:"true"`
RemoteAccessSecurityGroupID string `json:"remote-access-security-group-id" read-only:"true"`
// PhysicalID is the Physical ID for the created "AWS::EKS::Nodegroup".
PhysicalID string `json:"physical-id" read-only:"true"`
// Status is the current status of EKS "Managed Node Group".
Status string `json:"status" read-only:"true"`
// Instances maps an instance ID to an EC2 instance object for the node group.
Instances map[string]ec2config.Instance `json:"instances" read-only:"true"`
// Logs maps each instance ID to a list of log file paths fetched via SSH access.
Logs map[string][]string `json:"logs" read-only:"true"`
}
// IsEnabledAddOnNLBHelloWorld returns true if "AddOnNLBHelloWorld" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnNLBHelloWorld() bool {
if cfg.AddOnNLBHelloWorld == nil {
return false
}
if cfg.AddOnNLBHelloWorld.Enable {
return true
}
cfg.AddOnNLBHelloWorld = nil
return false
}
// AddOnNLBHelloWorld defines parameters for EKS cluster
// add-on NLB hello-world service.
type AddOnNLBHelloWorld struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// DeploymentReplicas is the number of replicas to deploy using "Deployment" object.
DeploymentReplicas int32 `json:"deployment-replicas"`
// Namespace is the namespace to create "NLB" objects in.
Namespace string `json:"namespace"`
// NLBARN is the ARN of the NLB created from the service.
NLBARN string `json:"nlb-arn" read-only:"true"`
// NLBName is the name of the NLB created from the service.
NLBName string `json:"nlb-name" read-only:"true"`
// URL is the host name for hello-world service.
URL string `json:"url" read-only:"true"`
}
// IsEnabledAddOnALB2048 returns true if "AddOnALB2048" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnALB2048() bool {
if cfg.AddOnALB2048 == nil {
return false
}
if cfg.AddOnALB2048.Enable {
return true
}
cfg.AddOnALB2048 = nil
return false
}
// AddOnALB2048 defines parameters for EKS cluster
// add-on ALB 2048 service.
type AddOnALB2048 struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// Namespace is the namespace to create "ALB" objects in.
Namespace string `json:"namespace"`
// DeploymentReplicasALB is the number of ALB replicas to deploy using "Deployment" object.
DeploymentReplicasALB int32 `json:"deployment-replicas-alb"`
// DeploymentReplicas2048 is the number of 2048 replicas to deploy using "Deployment" object.
DeploymentReplicas2048 int32 `json:"deployment-replicas-2048"`
// ALBARN is the ARN of the ALB created from the service.
ALBARN string `json:"alb-arn" read-only:"true"`
// ALBName is the name of the ALB created from the service.
ALBName string `json:"alb-name" read-only:"true"`
// URL is the URL for ALB 2048 Service.
URL string `json:"url" read-only:"true"`
}
// IsEnabledAddOnJobPi returns true if "AddOnJobPi" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnJobPi() bool {
if cfg.AddOnJobPi == nil {
return false
}
if cfg.AddOnJobPi.Enable {
return true
}
cfg.AddOnJobPi = nil
return false
}
// AddOnJobPi defines parameters for EKS cluster
// add-on Job with Perl.
type AddOnJobPi struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// Namespace is the namespace to create "Job" objects in.
Namespace string `json:"namespace"`
// Completes is the desired number of successfully finished pods.
Completes int `json:"completes"`
// Parallels is the the maximum desired number of pods the
// job should run at any given time.
Parallels int `json:"parallels"`
}
// IsEnabledAddOnJobEcho returns true if "AddOnJobEcho" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnJobEcho() bool {
if cfg.AddOnJobEcho == nil {
return false
}
if cfg.AddOnJobEcho.Enable {
return true
}
cfg.AddOnJobEcho = nil
return false
}
// AddOnJobEcho defines parameters for EKS cluster
// add-on Job with echo.
type AddOnJobEcho struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// Namespace is the namespace to create "Job" objects in.
Namespace string `json:"namespace"`
// Completes is the desired number of successfully finished pods.
Completes int `json:"completes"`
// Parallels is the the maximum desired number of pods the
// job should run at any given time.
Parallels int `json:"parallels"`
// EchoSize is the job object size in bytes.
// "Request entity too large: limit is 3145728" (3.1 MB).
// "The Job "echo" is invalid: metadata.annotations:
// Too long: must have at most 262144 characters". (0.26 MB)
EchoSize int `json:"echo-size"`
}
// IsEnabledAddOnCronJob returns true if "AddOnCronJob" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnCronJob() bool {
if cfg.AddOnCronJob == nil {
return false
}
if cfg.AddOnCronJob.Enable {
return true
}
cfg.AddOnCronJob = nil
return false
}
// AddOnCronJob defines parameters for EKS cluster
// add-on with CronJob.
type AddOnCronJob struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// Namespace is the namespace to create "Job" objects in.
Namespace string `json:"namespace"`
// Schedule is the cron schedule (e.g. "*/1 * * * *").
Schedule string `json:"schedule"`
// Completes is the desired number of successfully finished pods.
Completes int `json:"completes"`
// Parallels is the the maximum desired number of pods the
// job should run at any given time.
Parallels int `json:"parallels"`
// SuccessfulJobsHistoryLimit is the number of successful finished
// jobs to retain. Defaults to 3.
SuccessfulJobsHistoryLimit int32 `json:"successful-jobs-history-limit"`
// FailedJobsHistoryLimit is the number of failed finished jobs
// to retain. Defaults to 1.
FailedJobsHistoryLimit int32 `json:"failed-jobs-history-limit"`
// EchoSize is the job object size in bytes.
// "Request entity too large: limit is 3145728" (3.1 MB).
// "The Job "echo" is invalid: metadata.annotations:
// Too long: must have at most 262144 characters". (0.26 MB)
EchoSize int `json:"echo-size"`
}
// IsEnabledAddOnSecrets returns true if "AddOnSecrets" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnSecrets() bool {
if cfg.AddOnSecrets == nil {
return false
}
if cfg.AddOnSecrets.Enable {
return true
}
cfg.AddOnSecrets = nil
return false
}
// AddOnSecrets defines parameters for EKS cluster
// add-on "Secrets".
type AddOnSecrets struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// Namespace is the namespace to create "Secret" and "Pod" objects in.
Namespace string `json:"namespace"`
// Objects is the number of "Secret" objects to write/read.
Objects int `json:"objects"`
// Size is the "Secret" value size in bytes.
Size int `json:"size"`
// SecretQPS is the number of "Secret" create requests to send
// per second. Requests may be throttled by kube-apiserver.
// Default rate limits from kube-apiserver are:
// FLAG: --max-mutating-requests-inflight="200"
// FLAG: --max-requests-inflight="400"
SecretQPS uint `json:"secret-qps"`
// SecretBurst is the number of "Secret" create requests that
// a client can make in excess of the rate specified by the limiter.
// Requests may be throttled by kube-apiserver.
// Default rate limits from kube-apiserver are:
// FLAG: --max-mutating-requests-inflight="200"
// FLAG: --max-requests-inflight="400"
SecretBurst uint `json:"secret-burst"`
// CreatedSecretNames is the list of created "Secret" object names.
CreatedSecretNames []string `json:"created-secret-names" read-only:"true"`
// PodQPS is the number of "Pod" create requests to send
// per second. Requests may be throttled by kube-apiserver.
// Default rate limits from kube-apiserver are:
// FLAG: --max-mutating-requests-inflight="200"
// FLAG: --max-requests-inflight="400"
PodQPS uint `json:"pod-qps"`
// PodBurst is the number of "Pod" create requests that
// a client can make in excess of the rate specified by the limiter.
// Requests may be throttled by kube-apiserver.
// Default rate limits from kube-apiserver are:
// FLAG: --max-mutating-requests-inflight="200"
// FLAG: --max-requests-inflight="400"
PodBurst uint `json:"pod-burst"`
// CreatedPodNames is the list of created "Pod" object names.
CreatedPodNames []string `json:"created-pod-names" read-only:"true"`
// WritesResultPath is the CSV file path to output Secret writes test results.
WritesResultPath string `json:"writes-result-path"`
// ReadsResultPath is the CSV file path to output Secret reads test results.
ReadsResultPath string `json:"reads-result-path"`
}
// IsEnabledAddOnIRSA returns true if "AddOnIRSA" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnIRSA() bool {
if cfg.AddOnIRSA == nil {
return false
}
if cfg.AddOnIRSA.Enable {
return true
}
cfg.AddOnIRSA = nil
return false
}
// AddOnIRSA defines parameters for EKS cluster
// add-on "IAM Roles for Service Accounts (IRSA)".
type AddOnIRSA struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// Namespace is the namespace to create "Secret" and "Pod" objects in.
Namespace string `json:"namespace"`
// RoleName is the role name for IRSA.
RoleName string `json:"role-name"`
// RoleARN is the role ARN for IRSA.
RoleARN string `json:"role-arn"`
// RoleManagedPolicyARNs is IRSA role managed policy ARNs.
// ref. https://aws.amazon.com/blogs/opensource/introducing-fine-grained-iam-roles-service-accounts/
RoleManagedPolicyARNs []string `json:"role-managed-policy-arns"`
RoleCFNStackID string `json:"role-cfn-stack-id" read-only:"true"`
// ServiceAccountName is the ServiceAccount name.
ServiceAccountName string `json:"service-account-name"`
// ConfigMapName is the ConfigMap name.
ConfigMapName string `json:"config-map-name"`
// ConfigMapScriptFileName is the ConfigMap script name.
ConfigMapScriptFileName string `json:"config-map-script-file-name"`
// S3Key is the S3 key to write for IRSA tests.
S3Key string `json:"s3-key"`
// DeploymentName is the Deployment name.
DeploymentName string `json:"deployment-name"`
// DeploymentReplicas is the number of Deployment replicas.
DeploymentReplicas int32 `json:"deployment-replicas"`
// DeploymentResultPath is the output of "Deployment" run.
DeploymentResultPath string `json:"deployment-result-path"`
// DeploymentTook is the duration that took for Deployment resource.
DeploymentTook time.Duration `json:"deployment-took,omitempty" read-only:"true"`
// DeploymentTookString is the duration that took for Deployment resource.
DeploymentTookString string `json:"deployment-took-string,omitempty" read-only:"true"`
}
// IsEnabledAddOnFargate returns true if "AddOnFargate" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnFargate() bool {
if cfg.AddOnFargate == nil {
return false
}
if cfg.AddOnFargate.Enable {
return true
}
cfg.AddOnFargate = nil
return false
}
// AddOnFargate defines parameters for EKS cluster
// add-on "EKS on Fargate".
type AddOnFargate struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// Namespace is the namespace to create "Secret" and "Pod" objects in.
Namespace string `json:"namespace"`
// RoleName is the role name for Fargate.
RoleName string `json:"role-name"`
// RoleCreate is true to auto-create and delete role.
RoleCreate bool `json:"role-create"`
// RoleARN is the role ARN for Fargate.
RoleARN string `json:"role-arn"`
// RoleServicePrincipals is the Fargate role Service Principals
RoleServicePrincipals []string `json:"role-service-principals"`
// RoleManagedPolicyARNs is Fargate role managed policy ARNs.
RoleManagedPolicyARNs []string `json:"role-managed-policy-arns"`
RoleCFNStackID string `json:"role-cfn-stack-id" read-only:"true"`
// ProfileName is the profile name for Fargate.
ProfileName string `json:"profile-name"`
// SecretName is the secret name for Fargate.
SecretName string `json:"secret-name"`
// PodName is the name of the Fargate Pod.
PodName string `json:"pod-name"`
// ContainerName is the name of the Fargate container.
ContainerName string `json:"container-name"`
}
// IsEnabledAddOnAppMesh returns true if "AddOnAppMesh" is enabled.
// Otherwise, nil the field for "omitempty".
func (cfg *Config) IsEnabledAddOnAppMesh() bool {
if cfg.AddOnAppMesh == nil {
return false
}
if cfg.AddOnAppMesh.Enable {
return true
}
cfg.AddOnAppMesh = nil
return false
}
// AddOnAppMesh defines parameters for EKS cluster
// add-on "EKS App Mesh Integration".
type AddOnAppMesh struct {
// Enable is 'true' to create this add-on.
Enable bool `json:"enable"`
// Namespace is the namespace to create "AppMesh" controller/injector.
Namespace string `json:"namespace"`
// The image of appMesh controller
ControllerImage string `json:"controller-image"`
// The image of appMesh injector
InjectorImage string `json:"injector-image"`
// Created is true when the resource has been created.
// Used for delete operations.
Created bool `json:"created" read-only:"true"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// AddOnStackARN is the arn of cloudFormation to create the resource.
AddOnCFNStackARN string `json:"add-on-cfn-stack-arn,omitempty" read-only:"true"`
}
// Status represents the current status of AWS resources.
// Read-only. Cannot be configured via environmental variables.
type Status struct {
// Up is true if the cluster is up.
Up bool `json:"up"`
// CreateTook is the duration that took to create the resource.
CreateTook time.Duration `json:"create-took,omitempty" read-only:"true"`
// CreateTookString is the duration that took to create the resource.
CreateTookString string `json:"create-took-string,omitempty" read-only:"true"`
// DeleteTook is the duration that took to create the resource.
DeleteTook time.Duration `json:"delete-took,omitempty" read-only:"true"`
// DeleteTookString is the duration that took to create the resource.
DeleteTookString string `json:"delete-took-string,omitempty" read-only:"true"`
// AWSAccountID is the account ID of the eks tester caller session.
AWSAccountID string `json:"aws-account-id"`
// AWSUserID is the user ID of the eks tester caller session.
AWSUserID string `json:"aws-user-id"`
// AWSIAMRoleARN is the user IAM Role ARN of the eks tester caller session.
AWSIAMRoleARN string `json:"aws-iam-role-arn"`
// AWSCredentialPath is automatically set via AWS SDK Go.
// And to be mounted as a volume as 'Secret' object.
AWSCredentialPath string `json:"aws-credential-path"`
ClusterCFNStackID string `json:"cluster-cfn-stack-id"`
ClusterARN string `json:"cluster-arn"`
// ClusterAPIServerEndpoint is the cluster endpoint of the EKS cluster,
// required for KUBECONFIG write.
ClusterAPIServerEndpoint string `json:"cluster-api-server-endpoint"`
// ClusterOIDCIssuerURL is the issuer URL for the OpenID Connect
// (https://openid.net/connect/) identity provider .
ClusterOIDCIssuerURL string `json:"cluster-oidc-issuer-url"`
// ClusterOIDCIssuerHostPath is the issuer host path.
ClusterOIDCIssuerHostPath string `json:"cluster-oidc-issuer-host-path"`
// ClusterOIDCIssuerARN is the issuer ARN for the OpenID Connect
// (https://openid.net/connect/) identity provider .
ClusterOIDCIssuerARN string `json:"cluster-oidc-issuer-arn"`
// ClusterOIDCIssuerCAThumbprint is the issuer CA thumbprint.
ClusterOIDCIssuerCAThumbprint string `json:"cluster-oidc-issuer-ca-thumbprint"`
// ClusterCA is the EKS cluster CA, required for KUBECONFIG write.
ClusterCA string `json:"cluster-ca"`
// ClusterCADecoded is the decoded EKS cluster CA, required for k8s.io/client-go.
ClusterCADecoded string `json:"cluster-ca-decoded"`
// ClusterStatusCurrent represents the current status of the cluster.
ClusterStatusCurrent string `json:"cluster-status-current"`
// ClusterStatus represents the status of the cluster.
ClusterStatus []ClusterStatus `json:"cluster-status"`
}
// ClusterStatus represents the cluster status.
type ClusterStatus struct {
Time time.Time `json:"time"`
Status string `json:"status"`
}
// ClusterStatusDELETEDORNOTEXIST defines the cluster status when the cluster is not found.
//
// ref. https://docs.aws.amazon.com/eks/latest/APIReference/API_Cluster.html#AmazonEKS-Type-Cluster-status
//
// CREATING
// ACTIVE
// UPDATING
// DELETING
// FAILED
//
const ClusterStatusDELETEDORNOTEXIST = "DELETED/NOT-EXIST"
// RecordStatus records cluster status.
func (cfg *Config) RecordStatus(status string) {
cfg.mu.Lock()
defer cfg.mu.Unlock()
cfg.Status.ClusterStatusCurrent = status
switch status {
case ClusterStatusDELETEDORNOTEXIST:
cfg.Status.Up = false
case awseks.ClusterStatusActive:
cfg.Status.Up = true
}
sv := ClusterStatus{Time: time.Now(), Status: status}
n := len(cfg.Status.ClusterStatus)
if n == 0 {
cfg.Status.ClusterStatus = []ClusterStatus{sv}
cfg.unsafeSync()
return
}
copied := make([]ClusterStatus, n+1)
copy(copied[1:], cfg.Status.ClusterStatus)
copied[0] = sv
cfg.Status.ClusterStatus = copied
cfg.unsafeSync()
}
// Load loads configuration from YAML.
// Useful when injecting shared configuration via ConfigMap.
//
// Example usage:
//
// import "github.com/aws/aws-k8s-tester/eksconfig"
// cfg := eksconfig.Load("test.yaml")
// err := cfg.ValidateAndSetDefaults()
//
// Do not set default values in this function.
// "ValidateAndSetDefaults" must be called separately,
// to prevent overwriting previous data when loaded from disks.
func Load(p string) (cfg *Config, err error) {
var d []byte
d, err = ioutil.ReadFile(p)
if err != nil {