costmodelenv.go 19 KB

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