costmodelenv.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. package env
  2. import (
  3. "time"
  4. "github.com/opencost/opencost/core/pkg/env"
  5. "github.com/opencost/opencost/core/pkg/log"
  6. "github.com/opencost/opencost/core/pkg/util/timeutil"
  7. )
  8. const (
  9. APIPortEnvVar = "API_PORT"
  10. NetworkCostsPortEnvVar = "NETWORK_COSTS_PORT"
  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. AzureOfferIDEnvVar = "AZURE_OFFER_ID"
  18. AzureBillingAccountEnvVar = "AZURE_BILLING_ACCOUNT"
  19. AzureDownloadBillingDataToDiskEnvVar = "AZURE_DOWNLOAD_BILLING_DATA_TO_DISK"
  20. ReleaseNameEnvVar = "RELEASE_NAME"
  21. PodNameEnvVar = "POD_NAME"
  22. ClusterIDEnvVar = "CLUSTER_ID"
  23. ClusterProfileEnvVar = "CLUSTER_PROFILE"
  24. RemoteEnabledEnvVar = "REMOTE_WRITE_ENABLED"
  25. RemotePWEnvVar = "REMOTE_WRITE_PASSWORD"
  26. SQLAddressEnvVar = "SQL_ADDRESS"
  27. UseCSVProviderEnvVar = "USE_CSV_PROVIDER"
  28. UseCustomProviderEnvVar = "USE_CUSTOM_PROVIDER"
  29. CSVRegionEnvVar = "CSV_REGION"
  30. CSVEndpointEnvVar = "CSV_ENDPOINT"
  31. CSVPathEnvVar = "CSV_PATH"
  32. ConfigPathEnvVar = "CONFIG_PATH"
  33. CloudProviderAPIKeyEnvVar = "CLOUD_PROVIDER_API_KEY"
  34. PromlessEnvVar = "PROMLESS"
  35. EmitPodAnnotationsMetricEnvVar = "EMIT_POD_ANNOTATIONS_METRIC"
  36. EmitNamespaceAnnotationsMetricEnvVar = "EMIT_NAMESPACE_ANNOTATIONS_METRIC"
  37. EmitDeprecatedMetrics = "EMIT_DEPRECATED_METRICS"
  38. EmitKsmV1MetricsEnvVar = "EMIT_KSM_V1_METRICS"
  39. EmitKsmV1MetricsOnly = "EMIT_KSM_V1_METRICS_ONLY"
  40. PProfEnabledEnvVar = "PPROF_ENABLED"
  41. LogCollectionEnabledEnvVar = "LOG_COLLECTION_ENABLED"
  42. ProductAnalyticsEnabledEnvVar = "PRODUCT_ANALYTICS_ENABLED"
  43. ErrorReportingEnabledEnvVar = "ERROR_REPORTING_ENABLED"
  44. ValuesReportingEnabledEnvVar = "VALUES_REPORTING_ENABLED"
  45. KubeRbacProxyEnabled = "KUBE_RBAC_PROXY_ENABLED"
  46. KubeConfigPathEnvVar = "KUBECONFIG_PATH"
  47. UTCOffsetEnvVar = "UTC_OFFSET"
  48. ETLEnabledEnvVar = "ETL_ENABLED"
  49. ETLResolutionSeconds = "ETL_RESOLUTION_SECONDS"
  50. PricingConfigmapName = "PRICING_CONFIGMAP_NAME"
  51. MetricsConfigmapName = "METRICS_CONFIGMAP_NAME"
  52. ClusterInfoFileEnabledEnvVar = "CLUSTER_INFO_FILE_ENABLED"
  53. ClusterCacheFileEnabledEnvVar = "CLUSTER_CACHE_FILE_ENABLED"
  54. IngestPodUIDEnvVar = "INGEST_POD_UID"
  55. ETLReadOnlyMode = "ETL_READ_ONLY"
  56. AllocationNodeLabelsEnabled = "ALLOCATION_NODE_LABELS_ENABLED"
  57. AssetIncludeLocalDiskCostEnvVar = "ASSET_INCLUDE_LOCAL_DISK_COST"
  58. regionOverrideList = "REGION_OVERRIDE_LIST"
  59. ExportCSVFile = "EXPORT_CSV_FILE"
  60. ExportCSVLabelsList = "EXPORT_CSV_LABELS_LIST"
  61. ExportCSVLabelsAll = "EXPORT_CSV_LABELS_ALL"
  62. ExportCSVMaxDays = "EXPORT_CSV_MAX_DAYS"
  63. ExportBucketConfigFileEnvVar = "EXPORT_BUCKET_CONFIG_FILE"
  64. DataRetentionDailyResolutionDaysEnvVar = "DATA_RETENTION_DAILY_RESOLUTION_DAYS"
  65. DataRetentionHourlyResolutionHoursEnvVar = "DATA_RETENTION_HOURLY_RESOLUTION_HOURS"
  66. // We assume that Kubernetes is enabled if there is a KUBERNETES_PORT environment variable present
  67. KubernetesEnabledEnvVar = "KUBERNETES_PORT"
  68. CloudCostEnabledEnvVar = "CLOUD_COST_ENABLED"
  69. CloudCostConfigPath = "CLOUD_COST_CONFIG_PATH"
  70. CloudCostMonthToDateIntervalVar = "CLOUD_COST_MONTH_TO_DATE_INTERVAL"
  71. CloudCostRefreshRateHoursEnvVar = "CLOUD_COST_REFRESH_RATE_HOURS"
  72. CloudCostQueryWindowDaysEnvVar = "CLOUD_COST_QUERY_WINDOW_DAYS"
  73. CloudCostRunWindowDaysEnvVar = "CLOUD_COST_RUN_WINDOW_DAYS"
  74. CustomCostEnabledEnvVar = "CUSTOM_COST_ENABLED"
  75. CustomCostQueryWindowDaysEnvVar = "CUSTOM_COST_QUERY_WINDOW_DAYS"
  76. CustomCostRefreshRateHoursEnvVar = "CUSTOM_COST_REFRESH_RATE_HOURS"
  77. PluginConfigDirEnvVar = "PLUGIN_CONFIG_DIR"
  78. PluginExecutableDirEnvVar = "PLUGIN_EXECUTABLE_DIR"
  79. OCIPricingURL = "OCI_PRICING_URL"
  80. CarbonEstimatesEnabledEnvVar = "CARBON_ESTIMATES_ENABLED"
  81. UseCacheV1 = "USE_CACHE_V1"
  82. InstallNamespaceEnvVar = "INSTALL_NAMESPACE"
  83. ConfigBucketEnvVar = "CONFIG_BUCKET"
  84. // Node Stats Client Configuration
  85. NodeStatsForceKubeProxyEnvVar = "NODESTATS_FORCE_KUBE_PROXY"
  86. NodeStatsLocalProxyEnvVar = "NODESTATS_LOCAL_PROXY"
  87. NodeStatsInsecureEnvVar = "NODESTATS_INSECURE"
  88. NodeStatsCertFileEnvVar = "NODESTATS_CERT_FILE"
  89. NodeStatsKeyFileEnvVar = "NODESTATS_KEY_FILE"
  90. // Deprecated
  91. KubecostNamespaceEnvVar = "KUBECOST_NAMESPACE"
  92. KubecostConfigBucketEnvVar = "KUBECOST_CONFIG_BUCKET"
  93. )
  94. const DefaultConfigMountPath = "/var/configs"
  95. func IsETLReadOnlyMode() bool {
  96. return env.GetBool(ETLReadOnlyMode, false)
  97. }
  98. func GetExportCSVFile() string {
  99. return env.Get(ExportCSVFile, "")
  100. }
  101. func GetExportCSVLabelsAll() bool {
  102. return env.GetBool(ExportCSVLabelsAll, false)
  103. }
  104. func GetExportCSVLabelsList() []string {
  105. return env.GetList(ExportCSVLabelsList, ",")
  106. }
  107. func IsPProfEnabled() bool {
  108. return env.GetBool(PProfEnabledEnvVar, false)
  109. }
  110. func GetExportCSVMaxDays() int {
  111. return env.GetInt(ExportCSVMaxDays, 90)
  112. }
  113. // GetAPIPort returns the environment variable value for APIPortEnvVar which
  114. // is the port number the API is available on.
  115. func GetAPIPort() int {
  116. return env.GetInt(APIPortEnvVar, 9003)
  117. }
  118. // GetConfigBucketFile returns a file location for a mounted bucket configuration which is used to store
  119. // a subset of configurations that require sharing via remote storage.
  120. func GetConfigBucketFile() string {
  121. return env.Get(ConfigBucketEnvVar, env.Get(KubecostConfigBucketEnvVar, ""))
  122. }
  123. // IsClusterInfoFileEnabled returns true if the cluster info is read from a file or pulled from the local
  124. // cloud provider and kubernetes.
  125. func IsClusterInfoFileEnabled() bool {
  126. return env.GetBool(ClusterInfoFileEnabledEnvVar, false)
  127. }
  128. // IsClusterCacheFileEnabled returns true if the kubernetes cluster data is read from a file or pulled from the local
  129. // kubernetes API.
  130. func IsClusterCacheFileEnabled() bool {
  131. return env.GetBool(ClusterCacheFileEnabledEnvVar, false)
  132. }
  133. func GetPricingConfigmapName() string {
  134. return env.Get(PricingConfigmapName, "pricing-configs")
  135. }
  136. func GetMetricsConfigmapName() string {
  137. return env.Get(MetricsConfigmapName, "metrics-config")
  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 env.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 env.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 env.GetBool(EmitKsmV1MetricsEnvVar, true)
  153. }
  154. func IsEmitKsmV1MetricsOnly() bool {
  155. return env.GetBool(EmitKsmV1MetricsOnly, false)
  156. }
  157. func IsEmitDeprecatedMetrics() bool {
  158. return env.GetBool(EmitDeprecatedMetrics, false)
  159. }
  160. // GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents
  161. // the AWS access key for authentication
  162. func GetAWSAccessKeyID() string {
  163. awsAccessKeyID := env.Get(AWSAccessKeyIDEnvVar, "")
  164. // If the sample nil service key name is set, zero it out so that it is not
  165. // misinterpreted as a real service key.
  166. if awsAccessKeyID == "AKIXXX" {
  167. awsAccessKeyID = ""
  168. }
  169. return awsAccessKeyID
  170. }
  171. // GetAWSAccessKeySecret returns the environment variable value for AWSAccessKeySecretEnvVar which represents
  172. // the AWS access key secret for authentication
  173. func GetAWSAccessKeySecret() string {
  174. return env.Get(AWSAccessKeySecretEnvVar, "")
  175. }
  176. // GetAWSClusterID returns the environment variable value for AWSClusterIDEnvVar which represents
  177. // an AWS specific cluster identifier.
  178. func GetAWSClusterID() string {
  179. return env.Get(AWSClusterIDEnvVar, "")
  180. }
  181. // GetAWSPricingURL returns an optional alternative URL to fetch AWS pricing data from; for use in airgapped environments
  182. func GetAWSPricingURL() string {
  183. return env.Get(AWSPricingURL, "")
  184. }
  185. // GetAlibabaAccessKeyID returns the environment variable value for AlibabaAccessKeyIDEnvVar which represents
  186. // the Alibaba access key for authentication
  187. func GetAlibabaAccessKeyID() string {
  188. return env.Get(AlibabaAccessKeyIDEnvVar, "")
  189. }
  190. // GetAlibabaAccessKeySecret returns the environment variable value for AlibabaAccessKeySecretEnvVar which represents
  191. // the Alibaba access key secret for authentication
  192. func GetAlibabaAccessKeySecret() string {
  193. return env.Get(AlibabaAccessKeySecretEnvVar, "")
  194. }
  195. // GetAzureOfferID returns the environment variable value for AzureOfferIDEnvVar which represents
  196. // the Azure offer ID for determining prices.
  197. func GetAzureOfferID() string {
  198. return env.Get(AzureOfferIDEnvVar, "")
  199. }
  200. // GetAzureBillingAccount returns the environment variable value for
  201. // AzureBillingAccountEnvVar which represents the Azure billing
  202. // account for determining prices. If this is specified
  203. // customer-specific prices will be downloaded from the consumption
  204. // price sheet API.
  205. func GetAzureBillingAccount() string {
  206. return env.Get(AzureBillingAccountEnvVar, "")
  207. }
  208. // IsAzureDownloadBillingDataToDisk returns the environment variable value for
  209. // AzureDownloadBillingDataToDiskEnvVar which indicates whether the Azure
  210. // Billing Data should be held in memory or written to disk.
  211. func IsAzureDownloadBillingDataToDisk() bool {
  212. return env.GetBool(AzureDownloadBillingDataToDiskEnvVar, true)
  213. }
  214. // GetInstallNamespace returns the environment variable value that is set for the kubernetes namespace
  215. // this service is installed in.
  216. func GetInstallNamespace() string {
  217. return env.Get(InstallNamespaceEnvVar, env.Get(KubecostNamespaceEnvVar, "opencost"))
  218. }
  219. // GetPodName returns the name of the current running pod. If this environment variable is not set,
  220. // empty string is returned.
  221. func GetPodName() string {
  222. return env.Get(PodNameEnvVar, "")
  223. }
  224. // GetClusterProfile returns the environment variable value for ClusterProfileEnvVar which
  225. // represents the cluster profile configured for
  226. func GetClusterProfile() string {
  227. return env.Get(ClusterProfileEnvVar, "development")
  228. }
  229. // GetClusterID returns the environment variable value for ClusterIDEnvVar which represents the
  230. // configurable identifier used for multi-cluster metric emission.
  231. func GetClusterID() string {
  232. return env.Get(ClusterIDEnvVar, "")
  233. }
  234. func IsKubeRbacProxyEnabled() bool {
  235. return env.GetBool(KubeRbacProxyEnabled, false)
  236. }
  237. // IsRemoteEnabled returns the environment variable value for RemoteEnabledEnvVar which represents whether
  238. // or not remote write is enabled for prometheus for use with SQL backed persistent storage.
  239. func IsRemoteEnabled() bool {
  240. return env.GetBool(RemoteEnabledEnvVar, false)
  241. }
  242. // GetRemotePW returns the environment variable value for RemotePWEnvVar which represents the remote
  243. // persistent storage password.
  244. func GetRemotePW() string {
  245. return env.Get(RemotePWEnvVar, "")
  246. }
  247. // GetSQLAddress returns the environment variable value for SQLAddressEnvVar which represents the SQL
  248. // database address used with remote persistent storage.
  249. func GetSQLAddress() string {
  250. return env.Get(SQLAddressEnvVar, "")
  251. }
  252. // IsUseCSVProvider returns the environment variable value for UseCSVProviderEnvVar which represents
  253. // whether or not the use of a CSV cost provider is enabled.
  254. func IsUseCSVProvider() bool {
  255. return env.GetBool(UseCSVProviderEnvVar, false)
  256. }
  257. // IsUseCustomProvider returns the environment variable value for UseCustomProviderEnvVar which represents
  258. // whether or not the use of a custom cost provider is enabled.
  259. func IsUseCustomProvider() bool {
  260. return env.GetBool(UseCustomProviderEnvVar, false)
  261. }
  262. // GetCSVRegion returns the environment variable value for CSVRegionEnvVar which represents the
  263. // region configured for a CSV provider.
  264. func GetCSVRegion() string {
  265. return env.Get(CSVRegionEnvVar, "")
  266. }
  267. // GetCSVEndpoint returns the environment variable value for CSVEndpointEnvVar which represents the
  268. // endpoint configured for a S3 CSV provider another than AWS S3.
  269. func GetCSVEndpoint() string {
  270. return env.Get(CSVEndpointEnvVar, "")
  271. }
  272. // GetCSVPath returns the environment variable value for CSVPathEnvVar which represents the key path
  273. // configured for a CSV provider.
  274. func GetCSVPath() string {
  275. return env.Get(CSVPathEnvVar, "")
  276. }
  277. // GetCostAnalyzerVolumeMountPath is an alias of GetConfigPath, which returns the mount path for the
  278. // Cost Analyzer volume, which stores configs, persistent data, etc.
  279. func GetCostAnalyzerVolumeMountPath() string {
  280. return GetConfigPathWithDefault(DefaultConfigMountPath)
  281. }
  282. // GetConfigPath returns the environment variable value for ConfigPathEnvVar which represents the cost
  283. // model configuration path
  284. func GetConfigPathWithDefault(defaultValue string) string {
  285. return env.Get(ConfigPathEnvVar, defaultValue)
  286. }
  287. // GetCloudProviderAPI returns the environment variable value for CloudProviderAPIEnvVar which represents
  288. // the API key provided for the cloud provider.
  289. func GetCloudProviderAPIKey() string {
  290. return env.Get(CloudProviderAPIKeyEnvVar, "")
  291. }
  292. // GetPromless returns the environment variable which enables a source.OpencostDatasource which uses Prometheus
  293. func GetPromless() bool {
  294. return env.GetBool(PromlessEnvVar, false)
  295. }
  296. // IsLogCollectionEnabled returns the environment variable value for LogCollectionEnabledEnvVar which represents
  297. // whether or not log collection has been enabled for kubecost deployments.
  298. func IsLogCollectionEnabled() bool {
  299. return env.GetBool(LogCollectionEnabledEnvVar, true)
  300. }
  301. // IsProductAnalyticsEnabled returns the environment variable value for ProductAnalyticsEnabledEnvVar
  302. func IsProductAnalyticsEnabled() bool {
  303. return env.GetBool(ProductAnalyticsEnabledEnvVar, true)
  304. }
  305. // IsErrorReportingEnabled returns the environment variable value for ErrorReportingEnabledEnvVar
  306. func IsErrorReportingEnabled() bool {
  307. return env.GetBool(ErrorReportingEnabledEnvVar, true)
  308. }
  309. // IsValuesReportingEnabled returns the environment variable value for ValuesReportingEnabledEnvVar
  310. func IsValuesReportingEnabled() bool {
  311. return env.GetBool(ValuesReportingEnabledEnvVar, true)
  312. }
  313. // GetKubeConfigPath returns the environment variable value for KubeConfigPathEnvVar
  314. func GetKubeConfigPath() string {
  315. return env.Get(KubeConfigPathEnvVar, "")
  316. }
  317. // GetUTCOffset returns the environment variable value for UTCOffset
  318. func GetUTCOffset() string {
  319. return env.Get(UTCOffsetEnvVar, "")
  320. }
  321. // GetParsedUTCOffset returns the duration of the configured UTC offset
  322. func GetParsedUTCOffset() time.Duration {
  323. offset, err := timeutil.ParseUTCOffset(GetUTCOffset())
  324. if err != nil {
  325. log.Warnf("Failed to parse UTC offset: %s", err)
  326. return time.Duration(0)
  327. }
  328. return offset
  329. }
  330. func IsETLEnabled() bool {
  331. return env.GetBool(ETLEnabledEnvVar, true)
  332. }
  333. // GetETLResolution determines the resolution of ETL queries. The smaller the
  334. // duration, the higher the resolution; the higher the resolution, the more
  335. // accurate the query results, but the more computationally expensive.
  336. func GetETLResolution() time.Duration {
  337. // Use the configured ETL resolution, or default to
  338. // 5m (i.e. 300s)
  339. secs := time.Duration(env.GetInt64(ETLResolutionSeconds, 300))
  340. return secs * time.Second
  341. }
  342. // IsIngestingPodUID returns the env variable from ingestPodUID, which alters the
  343. // contents of podKeys in Allocation
  344. func IsIngestingPodUID() bool {
  345. return env.GetBool(IngestPodUIDEnvVar, false)
  346. }
  347. func IsAllocationNodeLabelsEnabled() bool {
  348. return env.GetBool(AllocationNodeLabelsEnabled, true)
  349. }
  350. func IsAssetIncludeLocalDiskCost() bool {
  351. return env.GetBool(AssetIncludeLocalDiskCostEnvVar, true)
  352. }
  353. func GetRegionOverrideList() []string {
  354. regionList := env.GetList(regionOverrideList, ",")
  355. if regionList == nil {
  356. return []string{}
  357. }
  358. return regionList
  359. }
  360. func GetDataRetentionDailyResolutionDays() int64 {
  361. return env.GetInt64(DataRetentionDailyResolutionDaysEnvVar, 30)
  362. }
  363. func GetDataRetentionHourlyResolutionHours() int64 {
  364. return env.GetInt64(DataRetentionHourlyResolutionHoursEnvVar, 49)
  365. }
  366. func IsKubernetesEnabled() bool {
  367. return env.Get(KubernetesEnabledEnvVar, "") != ""
  368. }
  369. func IsCloudCostEnabled() bool {
  370. return env.GetBool(CloudCostEnabledEnvVar, false)
  371. }
  372. func IsCustomCostEnabled() bool {
  373. return env.GetBool(CustomCostEnabledEnvVar, false)
  374. }
  375. func GetCloudCostConfigPath() string {
  376. return env.Get(CloudCostConfigPath, "cloud-integration.json")
  377. }
  378. func GetCloudCostMonthToDateInterval() int {
  379. return env.GetInt(CloudCostMonthToDateIntervalVar, 6)
  380. }
  381. func GetCloudCostRefreshRateHours() int64 {
  382. return env.GetInt64(CloudCostRefreshRateHoursEnvVar, 6)
  383. }
  384. func GetCloudCostQueryWindowDays() int64 {
  385. return env.GetInt64(CloudCostQueryWindowDaysEnvVar, 7)
  386. }
  387. func GetCustomCostQueryWindowHours() int64 {
  388. return env.GetInt64(CustomCostQueryWindowDaysEnvVar, 1)
  389. }
  390. func GetCustomCostQueryWindowDays() int64 {
  391. return env.GetInt64(CustomCostQueryWindowDaysEnvVar, 7)
  392. }
  393. func GetCloudCostRunWindowDays() int64 {
  394. return env.GetInt64(CloudCostRunWindowDaysEnvVar, 3)
  395. }
  396. func GetOCIPricingURL() string {
  397. return env.Get(OCIPricingURL, "https://apexapps.oracle.com/pls/apex/cetools/api/v1/products")
  398. }
  399. func GetPluginConfigDir() string {
  400. return env.Get(PluginConfigDirEnvVar, "/opt/opencost/plugin/config")
  401. }
  402. func GetPluginExecutableDir() string {
  403. return env.Get(PluginExecutableDirEnvVar, "/opt/opencost/plugin/bin")
  404. }
  405. func GetCustomCostRefreshRateHours() string {
  406. return env.Get(CustomCostRefreshRateHoursEnvVar, "12h")
  407. }
  408. func IsCarbonEstimatesEnabled() bool {
  409. return env.GetBool(CarbonEstimatesEnabledEnvVar, false)
  410. }
  411. func GetExportBucketConfigFile() string {
  412. return env.Get(ExportBucketConfigFileEnvVar, "")
  413. }
  414. // GetUseCacheV1 is a temporary flag to allow users to opt-in to using the old cache
  415. // Mainly for comparison purposes
  416. func GetUseCacheV1() bool {
  417. return env.GetBool(UseCacheV1, false)
  418. }
  419. func GetReleaseName() string {
  420. return env.Get(ReleaseNameEnvVar, "kubecost")
  421. }
  422. func GetNetworkCostsPort() int {
  423. return env.GetInt(NetworkCostsPortEnvVar, 3001)
  424. }
  425. // IsNodeStatsForceKubeProxy returns true if the node stats client should force the kube proxy direct end
  426. // point formatting
  427. func IsNodeStatsForceKubeProxy() bool {
  428. return env.GetBool(NodeStatsForceKubeProxyEnvVar, false)
  429. }
  430. // GetNodeStatsLocalProxy returns the fully qualified local proxy endpoint for the node stats client IFF the proxyAPI
  431. // is selected.
  432. func GetNodeStatsLocalProxy() string {
  433. return env.Get(NodeStatsLocalProxyEnvVar, "")
  434. }
  435. // IsNodeStatsInsecure returns true if the node stats client should skip TLS verification
  436. func IsNodeStatsInsecure() bool {
  437. return env.GetBool(NodeStatsInsecureEnvVar, false)
  438. }
  439. // GetNodeStatsCertFile returns the path of the cert file
  440. func GetNodeStatsCertFile() string {
  441. return env.Get(NodeStatsCertFileEnvVar, "")
  442. }
  443. // GetNodeStatsKeyFile returns the path of the key file
  444. func GetNodeStatsKeyFile() string {
  445. return env.Get(NodeStatsKeyFileEnvVar, "")
  446. }