Sfoglia il codice sorgente

Add Pod Name Environment Variable (#1294)

* Add environment variable for pod name used by leader/follower

Signed-off-by: Matt Bolt <mbolt35@gmail.com>

* Update the env var to PodName

Signed-off-by: Matt Bolt <mbolt35@gmail.com>
Matt Bolt 3 anni fa
parent
commit
e89a0df341
1 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 7 0
      pkg/env/costmodelenv.go

+ 7 - 0
pkg/env/costmodelenv.go

@@ -17,6 +17,7 @@ const (
 	AWSClusterIDEnvVar       = "AWS_CLUSTER_ID"
 
 	KubecostNamespaceEnvVar        = "KUBECOST_NAMESPACE"
+	PodNameEnvVar                  = "POD_NAME"
 	ClusterIDEnvVar                = "CLUSTER_ID"
 	ClusterProfileEnvVar           = "CLUSTER_PROFILE"
 	PrometheusServerEndpointEnvVar = "PROMETHEUS_SERVER_ENDPOINT"
@@ -210,6 +211,12 @@ func GetKubecostNamespace() string {
 	return Get(KubecostNamespaceEnvVar, "kubecost")
 }
 
+// GetPodName returns the name of the current running pod. If this environment variable is not set,
+// empty string is returned.
+func GetPodName() string {
+	return Get(PodNameEnvVar, "")
+}
+
 // GetClusterProfile returns the environment variable value for ClusterProfileEnvVar which
 // represents the cluster profile configured for
 func GetClusterProfile() string {