costmodelenv.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. package env
  2. import (
  3. "regexp"
  4. "strconv"
  5. "time"
  6. "github.com/opencost/opencost/pkg/log"
  7. "github.com/opencost/opencost/pkg/util/timeutil"
  8. )
  9. const (
  10. AppVersionEnvVar = "APP_VERSION"
  11. AWSAccessKeyIDEnvVar = "AWS_ACCESS_KEY_ID"
  12. AWSAccessKeySecretEnvVar = "AWS_SECRET_ACCESS_KEY"
  13. AWSClusterIDEnvVar = "AWS_CLUSTER_ID"
  14. AWSPricingURL = "AWS_PRICING_URL"
  15. AlibabaAccessKeyIDEnvVar = "ALIBABA_ACCESS_KEY_ID"
  16. AlibabaAccessKeySecretEnvVar = "ALIBABA_SECRET_ACCESS_KEY"
  17. KubecostNamespaceEnvVar = "KUBECOST_NAMESPACE"
  18. PodNameEnvVar = "POD_NAME"
  19. ClusterIDEnvVar = "CLUSTER_ID"
  20. ClusterProfileEnvVar = "CLUSTER_PROFILE"
  21. PrometheusServerEndpointEnvVar = "PROMETHEUS_SERVER_ENDPOINT"
  22. MaxQueryConcurrencyEnvVar = "MAX_QUERY_CONCURRENCY"
  23. QueryLoggingFileEnvVar = "QUERY_LOGGING_FILE"
  24. RemoteEnabledEnvVar = "REMOTE_WRITE_ENABLED"
  25. RemotePWEnvVar = "REMOTE_WRITE_PASSWORD"
  26. SQLAddressEnvVar = "SQL_ADDRESS"
  27. UseCSVProviderEnvVar = "USE_CSV_PROVIDER"
  28. CSVRegionEnvVar = "CSV_REGION"
  29. CSVEndpointEnvVar = "CSV_ENDPOINT"
  30. CSVPathEnvVar = "CSV_PATH"
  31. ConfigPathEnvVar = "CONFIG_PATH"
  32. CloudProviderAPIKeyEnvVar = "CLOUD_PROVIDER_API_KEY"
  33. DisableAggregateCostModelCache = "DISABLE_AGGREGATE_COST_MODEL_CACHE"
  34. EmitPodAnnotationsMetricEnvVar = "EMIT_POD_ANNOTATIONS_METRIC"
  35. EmitNamespaceAnnotationsMetricEnvVar = "EMIT_NAMESPACE_ANNOTATIONS_METRIC"
  36. EmitKsmV1MetricsEnvVar = "EMIT_KSM_V1_METRICS"
  37. EmitKsmV1MetricsOnly = "EMIT_KSM_V1_METRICS_ONLY"
  38. ThanosEnabledEnvVar = "THANOS_ENABLED"
  39. ThanosQueryUrlEnvVar = "THANOS_QUERY_URL"
  40. ThanosOffsetEnvVar = "THANOS_QUERY_OFFSET"
  41. ThanosMaxSourceResEnvVar = "THANOS_MAX_SOURCE_RESOLUTION"
  42. LogCollectionEnabledEnvVar = "LOG_COLLECTION_ENABLED"
  43. ProductAnalyticsEnabledEnvVar = "PRODUCT_ANALYTICS_ENABLED"
  44. ErrorReportingEnabledEnvVar = "ERROR_REPORTING_ENABLED"
  45. ValuesReportingEnabledEnvVar = "VALUES_REPORTING_ENABLED"
  46. DBBasicAuthUsername = "DB_BASIC_AUTH_USERNAME"
  47. DBBasicAuthPassword = "DB_BASIC_AUTH_PW"
  48. DBBearerToken = "DB_BEARER_TOKEN"
  49. MultiClusterBasicAuthUsername = "MC_BASIC_AUTH_USERNAME"
  50. MultiClusterBasicAuthPassword = "MC_BASIC_AUTH_PW"
  51. MultiClusterBearerToken = "MC_BEARER_TOKEN"
  52. InsecureSkipVerify = "INSECURE_SKIP_VERIFY"
  53. KubeConfigPathEnvVar = "KUBECONFIG_PATH"
  54. UTCOffsetEnvVar = "UTC_OFFSET"
  55. CacheWarmingEnabledEnvVar = "CACHE_WARMING_ENABLED"
  56. ETLEnabledEnvVar = "ETL_ENABLED"
  57. ETLMaxPrometheusQueryDurationMinutes = "ETL_MAX_PROMETHEUS_QUERY_DURATION_MINUTES"
  58. ETLResolutionSeconds = "ETL_RESOLUTION_SECONDS"
  59. LegacyExternalAPIDisabledVar = "LEGACY_EXTERNAL_API_DISABLED"
  60. PromClusterIDLabelEnvVar = "PROM_CLUSTER_ID_LABEL"
  61. PricingConfigmapName = "PRICING_CONFIGMAP_NAME"
  62. MetricsConfigmapName = "METRICS_CONFIGMAP_NAME"
  63. KubecostJobNameEnvVar = "KUBECOST_JOB_NAME"
  64. KubecostConfigBucketEnvVar = "KUBECOST_CONFIG_BUCKET"
  65. ClusterInfoFileEnabledEnvVar = "CLUSTER_INFO_FILE_ENABLED"
  66. ClusterCacheFileEnabledEnvVar = "CLUSTER_CACHE_FILE_ENABLED"
  67. PrometheusQueryOffsetEnvVar = "PROMETHEUS_QUERY_OFFSET"
  68. PrometheusRetryOnRateLimitResponseEnvVar = "PROMETHEUS_RETRY_ON_RATE_LIMIT"
  69. PrometheusRetryOnRateLimitMaxRetriesEnvVar = "PROMETHEUS_RETRY_ON_RATE_LIMIT_MAX_RETRIES"
  70. PrometheusRetryOnRateLimitDefaultWaitEnvVar = "PROMETHEUS_RETRY_ON_RATE_LIMIT_DEFAULT_WAIT"
  71. IngestPodUIDEnvVar = "INGEST_POD_UID"
  72. ETLReadOnlyMode = "ETL_READ_ONLY"
  73. AllocationNodeLabelsEnabled = "ALLOCATION_NODE_LABELS_ENABLED"
  74. AllocationNodeLabelsIncludeList = "ALLOCATION_NODE_LABELS_INCLUDE_LIST"
  75. )
  76. var offsetRegex = regexp.MustCompile(`^(\+|-)(\d\d):(\d\d)$`)
  77. func IsETLReadOnlyMode() bool {
  78. return GetBool(ETLReadOnlyMode, false)
  79. }
  80. // GetKubecostConfigBucket returns a file location for a mounted bucket configuration which is used to store
  81. // a subset of kubecost configurations that require sharing via remote storage.
  82. func GetKubecostConfigBucket() string {
  83. return Get(KubecostConfigBucketEnvVar, "")
  84. }
  85. // IsClusterInfoFileEnabled returns true if the cluster info is read from a file or pulled from the local
  86. // cloud provider and kubernetes.
  87. func IsClusterInfoFileEnabled() bool {
  88. return GetBool(ClusterInfoFileEnabledEnvVar, false)
  89. }
  90. // IsClusterCacheFileEnabled returns true if the kubernetes cluster data is read from a file or pulled from the local
  91. // kubernetes API.
  92. func IsClusterCacheFileEnabled() bool {
  93. return GetBool(ClusterCacheFileEnabledEnvVar, false)
  94. }
  95. // IsPrometheusRetryOnRateLimitResponse will attempt to retry if a 429 response is received OR a 400 with a body containing
  96. // ThrottleException (common in AWS services like AMP)
  97. func IsPrometheusRetryOnRateLimitResponse() bool {
  98. return GetBool(PrometheusRetryOnRateLimitResponseEnvVar, true)
  99. }
  100. // GetPrometheusRetryOnRateLimitMaxRetries returns the maximum number of retries that should be attempted prior to failing.
  101. // Only used if IsPrometheusRetryOnRateLimitResponse() is true.
  102. func GetPrometheusRetryOnRateLimitMaxRetries() int {
  103. return GetInt(PrometheusRetryOnRateLimitMaxRetriesEnvVar, 5)
  104. }
  105. // GetPrometheusRetryOnRateLimitDefaultWait returns the default wait time for a retriable rate limit response without a
  106. // Retry-After header.
  107. func GetPrometheusRetryOnRateLimitDefaultWait() time.Duration {
  108. return GetDuration(PrometheusRetryOnRateLimitDefaultWaitEnvVar, 100*time.Millisecond)
  109. }
  110. // GetPrometheusQueryOffset returns the time.Duration to offset all prometheus queries by. NOTE: This env var is applied
  111. // to all non-range queries made via our query context. This should only be applied when there is a significant delay in
  112. // data arriving in the target prom db. For example, if supplying a thanos or cortex querier for the prometheus server, using
  113. // a 3h offset will ensure that current time = current time - 3h.
  114. //
  115. // This offset is NOT the same as the GetThanosOffset() option, as that is only applied to queries made specifically targetting
  116. // thanos. This offset is applied globally.
  117. func GetPrometheusQueryOffset() time.Duration {
  118. offset := Get(PrometheusQueryOffsetEnvVar, "")
  119. if offset == "" {
  120. return 0
  121. }
  122. dur, err := timeutil.ParseDuration(offset)
  123. if err != nil {
  124. return 0
  125. }
  126. return dur
  127. }
  128. func GetPricingConfigmapName() string {
  129. return Get(PricingConfigmapName, "pricing-configs")
  130. }
  131. func GetMetricsConfigmapName() string {
  132. return Get(MetricsConfigmapName, "metrics-config")
  133. }
  134. // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
  135. // the AWS access key for authentication
  136. func GetAppVersion() string {
  137. return Get(AppVersionEnvVar, "1.91.0-rc.0")
  138. }
  139. // IsEmitNamespaceAnnotationsMetric returns true if cost-model is configured to emit the kube_namespace_annotations metric
  140. // containing the namespace annotations
  141. func IsEmitNamespaceAnnotationsMetric() bool {
  142. return GetBool(EmitNamespaceAnnotationsMetricEnvVar, false)
  143. }
  144. // IsEmitPodAnnotationsMetric returns true if cost-model is configured to emit the kube_pod_annotations metric containing
  145. // pod annotations.
  146. func IsEmitPodAnnotationsMetric() bool {
  147. return GetBool(EmitPodAnnotationsMetricEnvVar, false)
  148. }
  149. // IsEmitKsmV1Metrics returns true if cost-model is configured to emit all necessary KSM v1
  150. // metrics that were removed in KSM v2
  151. func IsEmitKsmV1Metrics() bool {
  152. return GetBool(EmitKsmV1MetricsEnvVar, true)
  153. }
  154. func IsEmitKsmV1MetricsOnly() bool {
  155. return GetBool(EmitKsmV1MetricsOnly, false)
  156. }
  157. // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
  158. // the AWS access key for authentication
  159. func GetAWSAccessKeyID() string {
  160. return Get(AWSAccessKeyIDEnvVar, "")
  161. }
  162. // GetAWSAccessKeySecret returns the environment variable value for AWSAccessKeySecretEnvVar which represents
  163. // the AWS access key secret for authentication
  164. func GetAWSAccessKeySecret() string {
  165. return Get(AWSAccessKeySecretEnvVar, "")
  166. }
  167. // GetAWSClusterID returns the environment variable value for AWSClusterIDEnvVar which represents
  168. // an AWS specific cluster identifier.
  169. func GetAWSClusterID() string {
  170. return Get(AWSClusterIDEnvVar, "")
  171. }
  172. // GetAWSPricingURL returns an optional alternative URL to fetch AWS pricing data from; for use in airgapped environments
  173. func GetAWSPricingURL() string {
  174. return Get(AWSPricingURL, "")
  175. }
  176. // GetAlibabaAccessKeyID returns the environment variable value for AlibabaAccessKeyIDEnvVar which represents
  177. // the Alibaba access key for authentication
  178. func GetAlibabaAccessKeyID() string {
  179. return Get(AlibabaAccessKeyIDEnvVar, "")
  180. }
  181. // GetAlibabaAccessKeySecret returns the environment variable value for AlibabaAccessKeySecretEnvVar which represents
  182. // the Alibaba access key secret for authentication
  183. func GetAlibabaAccessKeySecret() string {
  184. return Get(AlibabaAccessKeySecretEnvVar, "")
  185. }
  186. // GetKubecostNamespace returns the environment variable value for KubecostNamespaceEnvVar which
  187. // represents the namespace the cost model exists in.
  188. func GetKubecostNamespace() string {
  189. return Get(KubecostNamespaceEnvVar, "kubecost")
  190. }
  191. // GetPodName returns the name of the current running pod. If this environment variable is not set,
  192. // empty string is returned.
  193. func GetPodName() string {
  194. return Get(PodNameEnvVar, "")
  195. }
  196. // GetClusterProfile returns the environment variable value for ClusterProfileEnvVar which
  197. // represents the cluster profile configured for
  198. func GetClusterProfile() string {
  199. return Get(ClusterProfileEnvVar, "development")
  200. }
  201. // GetClusterID returns the environment variable value for ClusterIDEnvVar which represents the
  202. // configurable identifier used for multi-cluster metric emission.
  203. func GetClusterID() string {
  204. return Get(ClusterIDEnvVar, "")
  205. }
  206. // GetPrometheusServerEndpoint returns the environment variable value for PrometheusServerEndpointEnvVar which
  207. // represents the prometheus server endpoint used to execute prometheus queries.
  208. func GetPrometheusServerEndpoint() string {
  209. return Get(PrometheusServerEndpointEnvVar, "")
  210. }
  211. func GetInsecureSkipVerify() bool {
  212. return GetBool(InsecureSkipVerify, false)
  213. }
  214. // IsAggregateCostModelCacheDisabled returns the environment variable value for DisableAggregateCostModelCache which
  215. // will inform the aggregator on whether to load cached data. Defaults to false
  216. func IsAggregateCostModelCacheDisabled() bool {
  217. return GetBool(DisableAggregateCostModelCache, false)
  218. }
  219. // IsRemoteEnabled returns the environment variable value for RemoteEnabledEnvVar which represents whether
  220. // or not remote write is enabled for prometheus for use with SQL backed persistent storage.
  221. func IsRemoteEnabled() bool {
  222. return GetBool(RemoteEnabledEnvVar, false)
  223. }
  224. // GetRemotePW returns the environment variable value for RemotePWEnvVar which represents the remote
  225. // persistent storage password.
  226. func GetRemotePW() string {
  227. return Get(RemotePWEnvVar, "")
  228. }
  229. // GetSQLAddress returns the environment variable value for SQLAddressEnvVar which represents the SQL
  230. // database address used with remote persistent storage.
  231. func GetSQLAddress() string {
  232. return Get(SQLAddressEnvVar, "")
  233. }
  234. // IsUseCSVProvider returns the environment variable value for UseCSVProviderEnvVar which represents
  235. // whether or not the use of a CSV cost provider is enabled.
  236. func IsUseCSVProvider() bool {
  237. return GetBool(UseCSVProviderEnvVar, false)
  238. }
  239. // GetCSVRegion returns the environment variable value for CSVRegionEnvVar which represents the
  240. // region configured for a CSV provider.
  241. func GetCSVRegion() string {
  242. return Get(CSVRegionEnvVar, "")
  243. }
  244. // GetCSVEndpoint returns the environment variable value for CSVEndpointEnvVar which represents the
  245. // endpoint configured for a S3 CSV provider another than AWS S3.
  246. func GetCSVEndpoint() string {
  247. return Get(CSVEndpointEnvVar, "")
  248. }
  249. // GetCSVPath returns the environment variable value for CSVPathEnvVar which represents the key path
  250. // configured for a CSV provider.
  251. func GetCSVPath() string {
  252. return Get(CSVPathEnvVar, "")
  253. }
  254. // GetConfigPath returns the environment variable value for ConfigPathEnvVar which represents the cost
  255. // model configuration path
  256. func GetConfigPath() string {
  257. return Get(ConfigPathEnvVar, "")
  258. }
  259. // GetConfigPath returns the environment variable value for ConfigPathEnvVar which represents the cost
  260. // model configuration path
  261. func GetConfigPathWithDefault(defaultValue string) string {
  262. return Get(ConfigPathEnvVar, defaultValue)
  263. }
  264. // GetCloudProviderAPI returns the environment variable value for CloudProviderAPIEnvVar which represents
  265. // the API key provided for the cloud provider.
  266. func GetCloudProviderAPIKey() string {
  267. return Get(CloudProviderAPIKeyEnvVar, "")
  268. }
  269. // IsThanosEnabled returns the environment variable value for ThanosEnabledEnvVar which represents whether
  270. // or not thanos is enabled.
  271. func IsThanosEnabled() bool {
  272. return GetBool(ThanosEnabledEnvVar, false)
  273. }
  274. // GetThanosQueryUrl returns the environment variable value for ThanosQueryUrlEnvVar which represents the
  275. // target query endpoint for hitting thanos.
  276. func GetThanosQueryUrl() string {
  277. return Get(ThanosQueryUrlEnvVar, "")
  278. }
  279. // GetThanosOffset returns the environment variable value for ThanosOffsetEnvVar which represents the total
  280. // amount of time to offset all queries made to thanos.
  281. func GetThanosOffset() string {
  282. return Get(ThanosOffsetEnvVar, "3h")
  283. }
  284. // GetThanosMaxSourceResolution returns the environment variable value for ThanosMaxSourceResEnvVar which represents
  285. // the max source resolution to use when querying thanos.
  286. func GetThanosMaxSourceResolution() string {
  287. res := Get(ThanosMaxSourceResEnvVar, "raw")
  288. switch res {
  289. case "raw":
  290. return "0s"
  291. case "0s":
  292. fallthrough
  293. case "5m":
  294. fallthrough
  295. case "1h":
  296. return res
  297. default:
  298. return "0s"
  299. }
  300. }
  301. // IsLogCollectionEnabled returns the environment variable value for LogCollectionEnabledEnvVar which represents
  302. // whether or not log collection has been enabled for kubecost deployments.
  303. func IsLogCollectionEnabled() bool {
  304. return GetBool(LogCollectionEnabledEnvVar, true)
  305. }
  306. // IsProductAnalyticsEnabled returns the environment variable value for ProductAnalyticsEnabledEnvVar
  307. func IsProductAnalyticsEnabled() bool {
  308. return GetBool(ProductAnalyticsEnabledEnvVar, true)
  309. }
  310. // IsErrorReportingEnabled returns the environment variable value for ErrorReportingEnabledEnvVar
  311. func IsErrorReportingEnabled() bool {
  312. return GetBool(ErrorReportingEnabledEnvVar, true)
  313. }
  314. // IsValuesReportingEnabled returns the environment variable value for ValuesReportingEnabledEnvVar
  315. func IsValuesReportingEnabled() bool {
  316. return GetBool(ValuesReportingEnabledEnvVar, true)
  317. }
  318. // GetMaxQueryConcurrency returns the environment variable value for MaxQueryConcurrencyEnvVar
  319. func GetMaxQueryConcurrency() int {
  320. return GetInt(MaxQueryConcurrencyEnvVar, 5)
  321. }
  322. // GetQueryLoggingFile returns a file location if query logging is enabled. Otherwise, empty string
  323. func GetQueryLoggingFile() string {
  324. return Get(QueryLoggingFileEnvVar, "")
  325. }
  326. func GetDBBasicAuthUsername() string {
  327. return Get(DBBasicAuthUsername, "")
  328. }
  329. func GetDBBasicAuthUserPassword() string {
  330. return Get(DBBasicAuthPassword, "")
  331. }
  332. func GetDBBearerToken() string {
  333. return Get(DBBearerToken, "")
  334. }
  335. // GetMultiClusterBasicAuthUsername returns the environemnt variable value for MultiClusterBasicAuthUsername
  336. func GetMultiClusterBasicAuthUsername() string {
  337. return Get(MultiClusterBasicAuthUsername, "")
  338. }
  339. // GetMultiClusterBasicAuthPassword returns the environemnt variable value for MultiClusterBasicAuthPassword
  340. func GetMultiClusterBasicAuthPassword() string {
  341. return Get(MultiClusterBasicAuthPassword, "")
  342. }
  343. func GetMultiClusterBearerToken() string {
  344. return Get(MultiClusterBearerToken, "")
  345. }
  346. // GetKubeConfigPath returns the environment variable value for KubeConfigPathEnvVar
  347. func GetKubeConfigPath() string {
  348. return Get(KubeConfigPathEnvVar, "")
  349. }
  350. // GetUTCOffset returns the environemnt variable value for UTCOffset
  351. func GetUTCOffset() string {
  352. return Get(UTCOffsetEnvVar, "")
  353. }
  354. // GetParsedUTCOffset returns the duration of the configured UTC offset
  355. func GetParsedUTCOffset() time.Duration {
  356. offset := time.Duration(0)
  357. if offsetStr := GetUTCOffset(); offsetStr != "" {
  358. match := offsetRegex.FindStringSubmatch(offsetStr)
  359. if match == nil {
  360. log.Warnf("Illegal UTC offset: %s", offsetStr)
  361. return offset
  362. }
  363. sig := 1
  364. if match[1] == "-" {
  365. sig = -1
  366. }
  367. hrs64, _ := strconv.ParseInt(match[2], 10, 64)
  368. hrs := sig * int(hrs64)
  369. mins64, _ := strconv.ParseInt(match[3], 10, 64)
  370. mins := sig * int(mins64)
  371. offset = time.Duration(hrs)*time.Hour + time.Duration(mins)
  372. }
  373. return offset
  374. }
  375. // GetKubecostJobName returns the environment variable value for KubecostJobNameEnvVar
  376. func GetKubecostJobName() string {
  377. return Get(KubecostJobNameEnvVar, "kubecost")
  378. }
  379. func IsCacheWarmingEnabled() bool {
  380. return GetBool(CacheWarmingEnabledEnvVar, true)
  381. }
  382. func IsETLEnabled() bool {
  383. return GetBool(ETLEnabledEnvVar, true)
  384. }
  385. func GetETLMaxPrometheusQueryDuration() time.Duration {
  386. dayMins := 60 * 24
  387. mins := time.Duration(GetInt64(ETLMaxPrometheusQueryDurationMinutes, int64(dayMins)))
  388. return mins * time.Minute
  389. }
  390. // GetETLResolution determines the resolution of ETL queries. The smaller the
  391. // duration, the higher the resolution; the higher the resolution, the more
  392. // accurate the query results, but the more computationally expensive.
  393. func GetETLResolution() time.Duration {
  394. // Use the configured ETL resolution, or default to
  395. // 5m (i.e. 300s)
  396. secs := time.Duration(GetInt64(ETLResolutionSeconds, 300))
  397. return secs * time.Second
  398. }
  399. func LegacyExternalCostsAPIDisabled() bool {
  400. return GetBool(LegacyExternalAPIDisabledVar, false)
  401. }
  402. // GetPromClusterLabel returns the environemnt variable value for PromClusterIDLabel
  403. func GetPromClusterLabel() string {
  404. return Get(PromClusterIDLabelEnvVar, "cluster_id")
  405. }
  406. // IsIngestingPodUID returns the env variable from ingestPodUID, which alters the
  407. // contents of podKeys in Allocation
  408. func IsIngestingPodUID() bool {
  409. return GetBool(IngestPodUIDEnvVar, false)
  410. }
  411. func GetAllocationNodeLabelsEnabled() bool {
  412. return GetBool(AllocationNodeLabelsEnabled, true)
  413. }
  414. var defaultAllocationNodeLabelsIncludeList []string = []string{
  415. "cloud.google.com/gke-nodepool",
  416. "eks.amazonaws.com/nodegroup",
  417. "kubernetes.azure.com/agentpool",
  418. "node.kubernetes.io/instance-type",
  419. "topology.kubernetes.io/region",
  420. "topology.kubernetes.io/zone",
  421. }
  422. func GetAllocationNodeLabelsIncludeList() []string {
  423. // If node labels are not enabled, return an empty list.
  424. if !GetAllocationNodeLabelsEnabled() {
  425. return []string{}
  426. }
  427. list := GetList(AllocationNodeLabelsIncludeList, ",")
  428. // If node labels are enabled, but the white list is empty, use defaults.
  429. if len(list) == 0 {
  430. return defaultAllocationNodeLabelsIncludeList
  431. }
  432. return list
  433. }