Explorar el Código

ClusterProfile via environment variable. Pass via ClusterInfo

Matt Bolt hace 5 años
padre
commit
e0a6eb15ac
Se han modificado 2 ficheros con 19 adiciones y 4 borrados
  1. 12 4
      pkg/costmodel/router.go
  2. 7 0
      pkg/env/costmodelenv.go

+ 12 - 4
pkg/costmodel/router.go

@@ -46,10 +46,11 @@ const (
 var (
 	// gitCommit is set by the build system
 	gitCommit               string
-	logCollectionEnabled    bool = env.IsLogCollectionEnabled()
-	productAnalyticsEnabled bool = env.IsProductAnalyticsEnabled()
-	errorReportingEnabled   bool = env.IsErrorReportingEnabled()
-	valuesReportingEnabled  bool = env.IsValuesReportingEnabled()
+	logCollectionEnabled    bool   = env.IsLogCollectionEnabled()
+	productAnalyticsEnabled bool   = env.IsProductAnalyticsEnabled()
+	errorReportingEnabled   bool   = env.IsErrorReportingEnabled()
+	valuesReportingEnabled  bool   = env.IsValuesReportingEnabled()
+	clusterProfile          string = env.GetClusterProfile()
 )
 
 var Router = httprouter.New()
@@ -623,6 +624,13 @@ func (p *Accesses) ClusterInfo(w http.ResponseWriter, r *http.Request, ps httpro
 		klog.Infof("Could not get k8s version info: %s", err.Error())
 	}
 
+	// Ensure we create the info object if it doesn't exist
+	if data == nil {
+		data = make(map[string]string)
+	}
+
+	data["clusterProfile"] = clusterProfile
+
 	// Include Product Reporting Flags with Cluster Info
 	writeReportingFlags(data)
 

+ 7 - 0
pkg/env/costmodelenv.go

@@ -7,6 +7,7 @@ const (
 
 	KubecostNamespaceEnvVar        = "KUBECOST_NAMESPACE"
 	ClusterIDEnvVar                = "CLUSTER_ID"
+	ClusterProfileEnvVar           = "CLUSTER_PROFILE"
 	PrometheusServerEndpointEnvVar = "PROMETHEUS_SERVER_ENDPOINT"
 	MaxQueryConcurrencyEnvVar      = "MAX_QUERY_CONCURRENCY"
 	RemoteEnabledEnvVar            = "REMOTE_WRITE_ENABLED"
@@ -52,6 +53,12 @@ func GetKubecostNamespace() string {
 	return Get(KubecostNamespaceEnvVar, "kubecost")
 }
 
+// GetClusterProfile returns the environment variable value for ClusterProfileEnvVar which
+// represents the cluster profile configured for
+func GetClusterProfile() string {
+	return Get(ClusterProfileEnvVar, "development")
+}
+
 // GetClusterID returns the environment variable value for ClusterIDEnvVar which represents the
 // configurable identifier used for multi-cluster metric emission.
 func GetClusterID() string {