@@ -302,7 +302,7 @@ var _clusterConfigureCmd = &cobra.Command{
302
302
exit .Error (err )
303
303
}
304
304
305
- accessConfig , err := getClusterAccessConfigWithCache ( )
305
+ accessConfig , err := getNewClusterAccessConfig ( clusterConfigFile )
306
306
if err != nil {
307
307
exit .Error (err )
308
308
}
@@ -317,7 +317,7 @@ var _clusterConfigureCmd = &cobra.Command{
317
317
exit .Error (err )
318
318
}
319
319
320
- err = clusterstate .AssertClusterStatus (accessConfig .ClusterName , accessConfig .Region , clusterState .Status , clusterstate .StatusCreateComplete )
320
+ err = clusterstate .AssertClusterStatus (accessConfig .ClusterName , accessConfig .Region , clusterState .Status , clusterstate .StatusCreateComplete , clusterstate . StatusUpdateComplete , clusterstate . StatusUpdateRollbackComplete )
321
321
if err != nil {
322
322
exit .Error (err )
323
323
}
@@ -527,7 +527,7 @@ var _clusterExportCmd = &cobra.Command{
527
527
exit .Error (err )
528
528
}
529
529
530
- err = clusterstate .AssertClusterStatus (accessConfig .ClusterName , accessConfig .Region , clusterState .Status , clusterstate .StatusCreateComplete )
530
+ err = clusterstate .AssertClusterStatus (accessConfig .ClusterName , accessConfig .Region , clusterState .Status , clusterstate .StatusCreateComplete , clusterstate . StatusUpdateComplete , clusterstate . StatusUpdateRollbackComplete )
531
531
if err != nil {
532
532
exit .Error (err )
533
533
}
@@ -668,7 +668,7 @@ func printInfoClusterState(awsClient *aws.Client, accessConfig *clusterconfig.Ac
668
668
fmt .Println ()
669
669
}
670
670
671
- err = clusterstate .AssertClusterStatus (accessConfig .ClusterName , accessConfig .Region , clusterState .Status , clusterstate .StatusCreateComplete )
671
+ err = clusterstate .AssertClusterStatus (accessConfig .ClusterName , accessConfig .Region , clusterState .Status , clusterstate .StatusCreateComplete , clusterstate . StatusUpdateComplete , clusterstate . StatusUpdateRollbackComplete )
672
672
if err != nil {
673
673
return err
674
674
}
@@ -679,6 +679,12 @@ func printInfoClusterState(awsClient *aws.Client, accessConfig *clusterconfig.Ac
679
679
func printInfoOperatorResponse (clusterConfig clusterconfig.Config , operatorEndpoint string ) error {
680
680
fmt .Print ("fetching cluster status ...\n \n " )
681
681
682
+ yamlBytes , err := yaml .Marshal (clusterConfig )
683
+ if err != nil {
684
+ return err
685
+ }
686
+ yamlString := string (yamlBytes )
687
+
682
688
operatorConfig := cluster.OperatorConfig {
683
689
Telemetry : isTelemetryEnabled (),
684
690
ClientID : clientID (),
@@ -688,42 +694,67 @@ func printInfoOperatorResponse(clusterConfig clusterconfig.Config, operatorEndpo
688
694
689
695
infoResponse , err := cluster .Info (operatorConfig )
690
696
if err != nil {
691
- fmt .Println (clusterConfig . UserStr () )
697
+ fmt .Println (yamlString )
692
698
return err
693
699
}
694
700
infoResponse .ClusterConfig .Config = clusterConfig
695
701
696
- printInfoClusterConfig (infoResponse )
702
+ fmt .Println (console .Bold ("metadata:" ))
703
+ fmt .Println (fmt .Sprintf ("aws access key id: %s" , infoResponse .MaskedAWSAccessKeyID ))
704
+ fmt .Println (fmt .Sprintf ("%s: %s" , clusterconfig .APIVersionUserKey , infoResponse .ClusterConfig .APIVersion ))
705
+
706
+ fmt .Println ()
707
+ fmt .Println (console .Bold ("cluster config:" ))
708
+ fmt .Print (yamlString )
709
+
697
710
printInfoPricing (infoResponse , clusterConfig )
698
711
printInfoNodes (infoResponse )
699
712
700
713
return nil
701
714
}
702
715
703
- func printInfoClusterConfig (infoResponse * schema.InfoResponse ) {
704
- var items table.KeyValuePairs
705
- items .Add ("aws access key id" , infoResponse .MaskedAWSAccessKeyID )
706
- items .AddAll (infoResponse .ClusterConfig .UserTable ())
707
- items .Print ()
708
- }
709
-
710
716
func printInfoPricing (infoResponse * schema.InfoResponse , clusterConfig clusterconfig.Config ) {
711
- numAPIInstances := len (infoResponse .NodeInfos )
712
-
713
- var totalAPIInstancePrice float64
714
- for _ , nodeInfo := range infoResponse .NodeInfos {
715
- totalAPIInstancePrice += nodeInfo .Price
716
- }
717
-
718
717
eksPrice := aws .EKSPrices [clusterConfig .Region ]
719
718
operatorInstancePrice := aws .InstanceMetadatas [clusterConfig .Region ]["t3.medium" ].Price
720
719
operatorEBSPrice := aws .EBSMetadatas [clusterConfig .Region ]["gp2" ].PriceGB * 20 / 30 / 24
721
720
metricsEBSPrice := aws .EBSMetadatas [clusterConfig .Region ]["gp2" ].PriceGB * 40 / 30 / 24
722
721
nlbPrice := aws .NLBMetadatas [clusterConfig .Region ].Price
723
722
natUnitPrice := aws .NATMetadatas [clusterConfig .Region ].Price
724
- apiEBSPrice := aws .EBSMetadatas [clusterConfig .Region ][clusterConfig .InstanceVolumeType .String ()].PriceGB * float64 (clusterConfig .InstanceVolumeSize ) / 30 / 24
725
- if clusterConfig .InstanceVolumeType .String () == "io1" && clusterConfig .InstanceVolumeIOPS != nil {
726
- apiEBSPrice += aws .EBSMetadatas [clusterConfig .Region ][clusterConfig .InstanceVolumeType .String ()].PriceIOPS * float64 (* clusterConfig .InstanceVolumeIOPS ) / 30 / 24
723
+
724
+ headers := []table.Header {
725
+ {Title : "aws resource" },
726
+ {Title : "cost per hour" },
727
+ }
728
+
729
+ var rows [][]interface {}
730
+ rows = append (rows , []interface {}{"1 eks cluster" , s .DollarsMaxPrecision (eksPrice )})
731
+
732
+ var totalNodeGroupsPrice float64
733
+ for _ , ng := range clusterConfig .NodeGroups {
734
+ var ngNamePrefix string
735
+ if ng .Spot {
736
+ ngNamePrefix = "cx-ws-"
737
+ } else {
738
+ ngNamePrefix = "cx-wd-"
739
+ }
740
+ nodesInfo := infoResponse .GetNodesWithNodeGroupName (ngNamePrefix + ng .Name )
741
+ numInstances := len (nodesInfo )
742
+
743
+ ebsPrice := aws .EBSMetadatas [clusterConfig .Region ][ng .InstanceVolumeType .String ()].PriceGB * float64 (ng .InstanceVolumeSize ) / 30 / 24
744
+ if ng .InstanceVolumeType .String () == "io1" && ng .InstanceVolumeIOPS != nil {
745
+ ebsPrice += aws .EBSMetadatas [clusterConfig .Region ][ng .InstanceVolumeType .String ()].PriceIOPS * float64 (* ng .InstanceVolumeIOPS ) / 30 / 24
746
+ }
747
+ totalEBSPrice := ebsPrice * float64 (numInstances )
748
+
749
+ totalInstancePrice := float64 (0 )
750
+ for _ , nodeInfo := range nodesInfo {
751
+ totalInstancePrice += nodeInfo .Price
752
+ }
753
+
754
+ rows = append (rows , []interface {}{fmt .Sprintf ("nodegroup %s: %d (out of %d) %s for your apis" , ng .Name , numInstances , ng .MaxInstances , s .PluralS ("instance" , numInstances )), s .DollarsAndTenthsOfCents (totalInstancePrice ) + " total" })
755
+ rows = append (rows , []interface {}{fmt .Sprintf ("nodegroup %s: %d (out of %d) %dgb ebs %s for your apis" , ng .Name , numInstances , ng .MaxInstances , ng .InstanceVolumeSize , s .PluralS ("volume" , numInstances )), s .DollarsAndTenthsOfCents (totalEBSPrice ) + " total" })
756
+
757
+ totalNodeGroupsPrice += totalEBSPrice + totalInstancePrice
727
758
}
728
759
729
760
var natTotalPrice float64
@@ -732,20 +763,9 @@ func printInfoPricing(infoResponse *schema.InfoResponse, clusterConfig clusterco
732
763
} else if clusterConfig .NATGateway == clusterconfig .HighlyAvailableNATGateway {
733
764
natTotalPrice = natUnitPrice * float64 (len (clusterConfig .AvailabilityZones ))
734
765
}
735
-
736
- totalPrice := eksPrice + totalAPIInstancePrice + apiEBSPrice * float64 (numAPIInstances ) +
737
- operatorInstancePrice * 2 + operatorEBSPrice + metricsEBSPrice + nlbPrice * 2 + natTotalPrice
766
+ totalPrice := eksPrice + totalNodeGroupsPrice + operatorInstancePrice * 2 + operatorEBSPrice + metricsEBSPrice + nlbPrice * 2 + natTotalPrice
738
767
fmt .Printf (console .Bold ("\n your cluster currently costs %s per hour\n \n " ), s .DollarsAndCents (totalPrice ))
739
768
740
- headers := []table.Header {
741
- {Title : "aws resource" },
742
- {Title : "cost per hour" },
743
- }
744
-
745
- var rows [][]interface {}
746
- rows = append (rows , []interface {}{"1 eks cluster" , s .DollarsMaxPrecision (eksPrice )})
747
- rows = append (rows , []interface {}{fmt .Sprintf ("%d %s for your apis" , numAPIInstances , s .PluralS ("instance" , numAPIInstances )), s .DollarsAndTenthsOfCents (totalAPIInstancePrice ) + " total" })
748
- rows = append (rows , []interface {}{fmt .Sprintf ("%d %dgb ebs %s for your apis" , numAPIInstances , clusterConfig .InstanceVolumeSize , s .PluralS ("volume" , numAPIInstances )), s .DollarsAndTenthsOfCents (apiEBSPrice * float64 (numAPIInstances )) + " total" })
749
769
rows = append (rows , []interface {}{"2 t3.medium instances for cortex" , s .DollarsMaxPrecision (operatorInstancePrice * 2 )})
750
770
rows = append (rows , []interface {}{"1 20gb ebs volume for the operator" , s .DollarsAndTenthsOfCents (operatorEBSPrice )})
751
771
rows = append (rows , []interface {}{"1 40gb ebs volume for prometheus" , s .DollarsAndTenthsOfCents (metricsEBSPrice )})
0 commit comments