@@ -302,7 +302,7 @@ var _clusterConfigureCmd = &cobra.Command{
302302 exit .Error (err )
303303 }
304304
305- accessConfig , err := getClusterAccessConfigWithCache ( )
305+ accessConfig , err := getNewClusterAccessConfig ( clusterConfigFile )
306306 if err != nil {
307307 exit .Error (err )
308308 }
@@ -317,7 +317,7 @@ var _clusterConfigureCmd = &cobra.Command{
317317 exit .Error (err )
318318 }
319319
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 )
321321 if err != nil {
322322 exit .Error (err )
323323 }
@@ -527,7 +527,7 @@ var _clusterExportCmd = &cobra.Command{
527527 exit .Error (err )
528528 }
529529
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 )
531531 if err != nil {
532532 exit .Error (err )
533533 }
@@ -668,7 +668,7 @@ func printInfoClusterState(awsClient *aws.Client, accessConfig *clusterconfig.Ac
668668 fmt .Println ()
669669 }
670670
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 )
672672 if err != nil {
673673 return err
674674 }
@@ -679,6 +679,12 @@ func printInfoClusterState(awsClient *aws.Client, accessConfig *clusterconfig.Ac
679679func printInfoOperatorResponse (clusterConfig clusterconfig.Config , operatorEndpoint string ) error {
680680 fmt .Print ("fetching cluster status ...\n \n " )
681681
682+ yamlBytes , err := yaml .Marshal (clusterConfig )
683+ if err != nil {
684+ return err
685+ }
686+ yamlString := string (yamlBytes )
687+
682688 operatorConfig := cluster.OperatorConfig {
683689 Telemetry : isTelemetryEnabled (),
684690 ClientID : clientID (),
@@ -688,42 +694,67 @@ func printInfoOperatorResponse(clusterConfig clusterconfig.Config, operatorEndpo
688694
689695 infoResponse , err := cluster .Info (operatorConfig )
690696 if err != nil {
691- fmt .Println (clusterConfig . UserStr () )
697+ fmt .Println (yamlString )
692698 return err
693699 }
694700 infoResponse .ClusterConfig .Config = clusterConfig
695701
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+
697710 printInfoPricing (infoResponse , clusterConfig )
698711 printInfoNodes (infoResponse )
699712
700713 return nil
701714}
702715
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-
710716func 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-
718717 eksPrice := aws .EKSPrices [clusterConfig .Region ]
719718 operatorInstancePrice := aws .InstanceMetadatas [clusterConfig .Region ]["t3.medium" ].Price
720719 operatorEBSPrice := aws .EBSMetadatas [clusterConfig .Region ]["gp2" ].PriceGB * 20 / 30 / 24
721720 metricsEBSPrice := aws .EBSMetadatas [clusterConfig .Region ]["gp2" ].PriceGB * 40 / 30 / 24
722721 nlbPrice := aws .NLBMetadatas [clusterConfig .Region ].Price
723722 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
727758 }
728759
729760 var natTotalPrice float64
@@ -732,20 +763,9 @@ func printInfoPricing(infoResponse *schema.InfoResponse, clusterConfig clusterco
732763 } else if clusterConfig .NATGateway == clusterconfig .HighlyAvailableNATGateway {
733764 natTotalPrice = natUnitPrice * float64 (len (clusterConfig .AvailabilityZones ))
734765 }
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
738767 fmt .Printf (console .Bold ("\n your cluster currently costs %s per hour\n \n " ), s .DollarsAndCents (totalPrice ))
739768
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" })
749769 rows = append (rows , []interface {}{"2 t3.medium instances for cortex" , s .DollarsMaxPrecision (operatorInstancePrice * 2 )})
750770 rows = append (rows , []interface {}{"1 20gb ebs volume for the operator" , s .DollarsAndTenthsOfCents (operatorEBSPrice )})
751771 rows = append (rows , []interface {}{"1 40gb ebs volume for prometheus" , s .DollarsAndTenthsOfCents (metricsEBSPrice )})
0 commit comments