env

package
v1.117.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CloudCostConfigControllerStateFile = "cloud-configurations.json"
	CloudIntegrationConfigFile         = "cloud-integration.json"
	AzureBillingDataDownloadPath       = "db/cloudcost"
)
View Source
const (
	CloudCostEnabledEnvVar          = "CLOUD_COST_ENABLED"
	CloudCostMonthToDateIntervalVar = "CLOUD_COST_MONTH_TO_DATE_INTERVAL"
	CloudCostRefreshRateHoursEnvVar = "CLOUD_COST_REFRESH_RATE_HOURS"
	CloudCostQueryWindowDaysEnvVar  = "CLOUD_COST_QUERY_WINDOW_DAYS"
	CloudCostRunWindowDaysEnvVar    = "CLOUD_COST_RUN_WINDOW_DAYS"

	CustomCostEnabledEnvVar         = "CUSTOM_COST_ENABLED"
	CustomCostQueryWindowDaysEnvVar = "CUSTOM_COST_QUERY_WINDOW_DAYS"

	PluginConfigDirEnvVar     = "PLUGIN_CONFIG_DIR"
	PluginExecutableDirEnvVar = "PLUGIN_EXECUTABLE_DIR"

	AzureDownloadBillingDataToDiskEnvVar = "AZURE_DOWNLOAD_BILLING_DATA_TO_DISK"
)
View Source
const (
	ClusterInfoFile = "cluster-info.json"
	ClusterCacheFile
	GCPAuthSecretFile        = "key.json"
	MetricConfigFile         = "metrics.json"
	DefaultLocalCollectorDir = "collector"
)

FilePaths

View Source
const (

	// We assume that Kubernetes is enabled if there is a KUBERNETES_PORT environment variable present
	KubernetesEnabledEnvVar = "KUBERNETES_PORT"

	// Cloud Provider
	AWSAccessKeyIDEnvVar     = "AWS_ACCESS_KEY_ID"
	AWSAccessKeySecretEnvVar = "AWS_SECRET_ACCESS_KEY"
	AWSClusterIDEnvVar       = "AWS_CLUSTER_ID"
	AWSPricingURL            = "AWS_PRICING_URL"

	AlibabaAccessKeyIDEnvVar     = "ALIBABA_ACCESS_KEY_ID"
	AlibabaAccessKeySecretEnvVar = "ALIBABA_SECRET_ACCESS_KEY"

	AzureOfferIDEnvVar        = "AZURE_OFFER_ID"
	AzureBillingAccountEnvVar = "AZURE_BILLING_ACCOUNT"

	OCIPricingURL = "OCI_PRICING_URL"

	ClusterProfileEnvVar    = "CLUSTER_PROFILE"
	RemoteEnabledEnvVar     = "REMOTE_WRITE_ENABLED"
	RemotePWEnvVar          = "REMOTE_WRITE_PASSWORD"
	SQLAddressEnvVar        = "SQL_ADDRESS"
	UseCSVProviderEnvVar    = "USE_CSV_PROVIDER"
	UseCustomProviderEnvVar = "USE_CUSTOM_PROVIDER"
	CSVRegionEnvVar         = "CSV_REGION"
	CSVEndpointEnvVar       = "CSV_ENDPOINT"
	CSVPathEnvVar           = "CSV_PATH"

	CloudProviderAPIKeyEnvVar        = "CLOUD_PROVIDER_API_KEY"
	CollectorDataSourceEnabledEnvVar = "COLLECTOR_DATA_SOURCE_ENABLED"
	LocalCollectorDirectoryEnvVar    = "LOCAL_COLLECTOR_DIRECTORY"

	EmitPodAnnotationsMetricEnvVar       = "EMIT_POD_ANNOTATIONS_METRIC"
	EmitNamespaceAnnotationsMetricEnvVar = "EMIT_NAMESPACE_ANNOTATIONS_METRIC"
	EmitDeprecatedMetrics                = "EMIT_DEPRECATED_METRICS"

	EmitKsmV1MetricsEnvVar = "EMIT_KSM_V1_METRICS"
	EmitKsmV1MetricsOnly   = "EMIT_KSM_V1_METRICS_ONLY"

	LogCollectionEnabledEnvVar    = "LOG_COLLECTION_ENABLED"
	ProductAnalyticsEnabledEnvVar = "PRODUCT_ANALYTICS_ENABLED"
	ErrorReportingEnabledEnvVar   = "ERROR_REPORTING_ENABLED"
	ValuesReportingEnabledEnvVar  = "VALUES_REPORTING_ENABLED"

	PricingConfigmapName = "PRICING_CONFIGMAP_NAME"
	MetricsConfigmapName = "METRICS_CONFIGMAP_NAME"

	ClusterInfoFileEnabledEnvVar = "CLUSTER_INFO_FILE_ENABLED"

	IngestPodUIDEnvVar = "INGEST_POD_UID"

	AllocationNodeLabelsEnabled = "ALLOCATION_NODE_LABELS_ENABLED"

	AssetIncludeLocalDiskCostEnvVar = "ASSET_INCLUDE_LOCAL_DISK_COST"

	ExportCSVFile       = "EXPORT_CSV_FILE"
	ExportCSVLabelsList = "EXPORT_CSV_LABELS_LIST"
	ExportCSVLabelsAll  = "EXPORT_CSV_LABELS_ALL"
	ExportCSVMaxDays    = "EXPORT_CSV_MAX_DAYS"

	DataRetentionDailyResolutionDaysEnvVar   = "DATA_RETENTION_DAILY_RESOLUTION_DAYS"
	DataRetentionHourlyResolutionHoursEnvVar = "DATA_RETENTION_HOURLY_RESOLUTION_HOURS"

	CarbonEstimatesEnabledEnvVar = "CARBON_ESTIMATES_ENABLED"

	KubernetesResourceAccessEnvVar = "KUBERNETES_RESOURCE_ACCESS"
	UseCacheV1                     = "USE_CACHE_V1"

	// Cloud provider override
	CloudProviderVar = "CLOUD_PROVIDER"
)

Env Variables

View Source
const (
	KubecostMetricsPodEnabledEnvVar = "KUBECOST_METRICS_POD_ENABLED"
	KubecostMetricsPodPortEnvVar    = "KUBECOST_METRICS_PORT"
	ExportClusterCacheEnabledEnvVar = "EXPORT_CLUSTER_CACHE_ENABLED"
	ExportClusterInfoEnabledEnvVar  = "EXPORT_CLUSTER_INFO_ENABLED"
)
View Source
const (
	// Node Stats Client Configuration
	NodeStatsForceKubeProxyEnvVar = "NODESTATS_FORCE_KUBE_PROXY"
	NodeStatsLocalProxyEnvVar     = "NODESTATS_LOCAL_PROXY"
	NodeStatsInsecureEnvVar       = "NODESTATS_INSECURE"
	NodeStatsCertFileEnvVar       = "NODESTATS_CERT_FILE"
	NodeStatsKeyFileEnvVar        = "NODESTATS_KEY_FILE"
)
View Source
const (
	DefaultAPIPort = 9003
)

Environment variables specific to the running of opencost

View Source
const (
	UTCOffsetEnvVar = "UTC_OFFSET"
)

Variables

This section is empty.

Functions

func GetAWSAccessKeyID

func GetAWSAccessKeyID() string

GetAWSAccessKeyID returns the environment variable value for AWSAccessKeyIDEnvVar which represents the AWS access key for authentication

func GetAWSAccessKeySecret

func GetAWSAccessKeySecret() string

GetAWSAccessKeySecret returns the environment variable value for AWSAccessKeySecretEnvVar which represents the AWS access key secret for authentication

func GetAWSClusterID

func GetAWSClusterID() string

GetAWSClusterID returns the environment variable value for AWSClusterIDEnvVar which represents an AWS specific cluster identifier.

func GetAWSPricingURL added in v1.99.0

func GetAWSPricingURL() string

GetAWSPricingURL returns an optional alternative URL to fetch AWS pricing data from; for use in airgapped environments

func GetAlibabaAccessKeyID added in v1.99.0

func GetAlibabaAccessKeyID() string

GetAlibabaAccessKeyID returns the environment variable value for AlibabaAccessKeyIDEnvVar which represents the Alibaba access key for authentication

func GetAlibabaAccessKeySecret added in v1.99.0

func GetAlibabaAccessKeySecret() string

GetAlibabaAccessKeySecret returns the environment variable value for AlibabaAccessKeySecretEnvVar which represents the Alibaba access key secret for authentication

func GetAzureBillingAccount added in v1.103.0

func GetAzureBillingAccount() string

GetAzureBillingAccount returns the environment variable value for AzureBillingAccountEnvVar which represents the Azure billing account for determining prices. If this is specified customer-specific prices will be downloaded from the consumption price sheet API.

func GetAzureDownloadBillingDataPath added in v1.116.0

func GetAzureDownloadBillingDataPath() string

func GetAzureOfferID added in v1.103.0

func GetAzureOfferID() string

GetAzureOfferID returns the environment variable value for AzureOfferIDEnvVar which represents the Azure offer ID for determining prices.

func GetCSVEndpoint

func GetCSVEndpoint() string

GetCSVEndpoint returns the environment variable value for CSVEndpointEnvVar which represents the endpoint configured for a S3 CSV provider another than AWS S3.

func GetCSVPath

func GetCSVPath() string

GetCSVPath returns the environment variable value for CSVPathEnvVar which represents the key path configured for a CSV provider.

func GetCSVRegion

func GetCSVRegion() string

GetCSVRegion returns the environment variable value for CSVRegionEnvVar which represents the region configured for a CSV provider.

func GetCloudCostConfigControllerStateFile added in v1.116.0

func GetCloudCostConfigControllerStateFile() string

func GetCloudCostConfigPath added in v1.109.0

func GetCloudCostConfigPath() string

func GetCloudCostMonthToDateInterval added in v1.108.0

func GetCloudCostMonthToDateInterval() int

func GetCloudCostQueryWindowDays added in v1.108.0

func GetCloudCostQueryWindowDays() int64

func GetCloudCostRefreshRateHours added in v1.108.0

func GetCloudCostRefreshRateHours() int64

func GetCloudCostRunWindowDays added in v1.108.0

func GetCloudCostRunWindowDays() int64

func GetCloudProvider added in v1.116.0

func GetCloudProvider() string

GetCloudProvider returns the explicitly set cloud provider from environment variable

func GetCloudProviderAPIKey

func GetCloudProviderAPIKey() string

GetCloudProviderAPI returns the environment variable value for CloudProviderAPIEnvVar which represents the API key provided for the cloud provider.

func GetClusterCacheFilePath added in v1.116.0

func GetClusterCacheFilePath() string

func GetClusterInfoFilePath added in v1.116.0

func GetClusterInfoFilePath() string

func GetClusterProfile

func GetClusterProfile() string

GetClusterProfile returns the environment variable value for ClusterProfileEnvVar which represents the cluster profile configured for

func GetCustomCostQueryWindowDays added in v1.111.0

func GetCustomCostQueryWindowDays() int64

func GetCustomCostQueryWindowHours added in v1.111.0

func GetCustomCostQueryWindowHours() int64

func GetDataRetentionDailyResolutionDays added in v1.108.0

func GetDataRetentionDailyResolutionDays() int64

func GetDataRetentionHourlyResolutionHours added in v1.111.0

func GetDataRetentionHourlyResolutionHours() int64

func GetExportCSVFile added in v1.104.0

func GetExportCSVFile() string

func GetExportCSVLabelsAll added in v1.104.0

func GetExportCSVLabelsAll() bool

func GetExportCSVLabelsList added in v1.104.0

func GetExportCSVLabelsList() []string

func GetExportCSVMaxDays added in v1.107.0

func GetExportCSVMaxDays() int

func GetGCPAuthSecretFilePath added in v1.116.0

func GetGCPAuthSecretFilePath() string

func GetKubecostMetricsPort

func GetKubecostMetricsPort() int

func GetLocalCollectorDirectory added in v1.117.1

func GetLocalCollectorDirectory() string

func GetMetricConfigFile added in v1.116.0

func GetMetricConfigFile() string

func GetMetricsConfigmapName

func GetMetricsConfigmapName() string

func GetNodeStatsCertFile added in v1.115.0

func GetNodeStatsCertFile() string

GetNodeStatsCertFile returns the path of the cert file

func GetNodeStatsKeyFile added in v1.115.0

func GetNodeStatsKeyFile() string

GetNodeStatsKeyFile returns the path of the key file

func GetNodeStatsLocalProxy added in v1.115.0

func GetNodeStatsLocalProxy() string

GetNodeStatsLocalProxy returns the fully qualified local proxy endpoint for the node stats client IFF the proxyAPI is selected.

func GetOCIPricingURL added in v1.109.0

func GetOCIPricingURL() string

func GetOpencostAPIPort added in v1.116.0

func GetOpencostAPIPort() int

func GetOpencostNamespace added in v1.116.0

func GetOpencostNamespace() string

GetOpencostNamespace returns the environment variable value that is set for the kubernetes namespace this service is installed in.

func GetParsedUTCOffset

func GetParsedUTCOffset() time.Duration

GetParsedUTCOffset returns the duration of the configured UTC offset

func GetPluginConfigDir added in v1.111.0

func GetPluginConfigDir() string

func GetPluginExecutableDir added in v1.111.0

func GetPluginExecutableDir() string

func GetPricingConfigmapName

func GetPricingConfigmapName() string

func GetRegionOverrideList added in v1.101.0

func GetRegionOverrideList() []string

func GetRemotePW

func GetRemotePW() string

GetRemotePW returns the environment variable value for RemotePWEnvVar which represents the remote persistent storage password.

func GetSQLAddress

func GetSQLAddress() string

GetSQLAddress returns the environment variable value for SQLAddressEnvVar which represents the SQL database address used with remote persistent storage.

func GetUTCOffset

func GetUTCOffset() string

GetUTCOffset returns the environment variable value for UTCOffset

func GetUseCacheV1 added in v1.114.0

func GetUseCacheV1() bool

GetUseCacheV1 is a temporary flag to allow users to opt-in to using the old cache Mainly for comparison purposes

func HasKubernetesResourceAccess added in v1.116.0

func HasKubernetesResourceAccess() bool

HasKubernetesResourceAccess can be set to false if Opencost is run without access to the kubernetes resources

func IsAllocationNodeLabelsEnabled added in v1.115.0

func IsAllocationNodeLabelsEnabled() bool

func IsAssetIncludeLocalDiskCost added in v1.115.0

func IsAssetIncludeLocalDiskCost() bool

func IsAzureDownloadBillingDataToDisk added in v1.111.0

func IsAzureDownloadBillingDataToDisk() bool

IsAzureDownloadBillingDataToDisk returns the environment variable value for AzureDownloadBillingDataToDiskEnvVar which indicates whether the Azure Billing Data should be held in memory or written to disk.

func IsCarbonEstimatesEnabled added in v1.111.0

func IsCarbonEstimatesEnabled() bool

func IsCloudCostEnabled added in v1.108.0

func IsCloudCostEnabled() bool

func IsClusterInfoFileEnabled

func IsClusterInfoFileEnabled() bool

IsClusterInfoFileEnabled returns true if the cluster info is read from a file or pulled from the local cloud provider and kubernetes.

func IsCollectorDataSourceEnabled added in v1.116.0

func IsCollectorDataSourceEnabled() bool

IsCollectorDataSourceEnabeled returns the environment variable which enables a source.OpencostDatasource which does not use uses Prometheus

func IsCustomCostEnabled added in v1.111.0

func IsCustomCostEnabled() bool

func IsEmitDeprecatedMetrics added in v1.109.0

func IsEmitDeprecatedMetrics() bool

func IsEmitKsmV1Metrics

func IsEmitKsmV1Metrics() bool

IsEmitKsmV1Metrics returns true if cost-model is configured to emit all necessary KSM v1 metrics that were removed in KSM v2

func IsEmitKsmV1MetricsOnly

func IsEmitKsmV1MetricsOnly() bool

func IsEmitNamespaceAnnotationsMetric

func IsEmitNamespaceAnnotationsMetric() bool

IsEmitNamespaceAnnotationsMetric returns true if cost-model is configured to emit the kube_namespace_annotations metric containing the namespace annotations

func IsEmitPodAnnotationsMetric

func IsEmitPodAnnotationsMetric() bool

IsEmitPodAnnotationsMetric returns true if cost-model is configured to emit the kube_pod_annotations metric containing pod annotations.

func IsErrorReportingEnabled

func IsErrorReportingEnabled() bool

IsErrorReportingEnabled returns the environment variable value for ErrorReportingEnabledEnvVar

func IsExportClusterCacheEnabled

func IsExportClusterCacheEnabled() bool

IsExportClusterCacheEnabled is set to true if the metrics pod should export the cluster cache data to a target file location

func IsExportClusterInfoEnabled

func IsExportClusterInfoEnabled() bool

IsExportClusterInfoEnabled is set to true if the metrics pod should export its own cluster info data to a target file location

func IsIngestingPodUID

func IsIngestingPodUID() bool

IsIngestingPodUID returns the env variable from ingestPodUID, which alters the contents of podKeys in Allocation

func IsKubecostMetricsPodEnabled

func IsKubecostMetricsPodEnabled() bool

IsKubecostMetricsPodEnabled returns true if the kubecost metrics pod is deployed

func IsKubernetesEnabled added in v1.109.0

func IsKubernetesEnabled() bool

func IsLogCollectionEnabled

func IsLogCollectionEnabled() bool

IsLogCollectionEnabled returns the environment variable value for LogCollectionEnabledEnvVar which represents whether or not log collection has been enabled for kubecost deployments.

func IsNodeStatsForceKubeProxy added in v1.115.0

func IsNodeStatsForceKubeProxy() bool

IsNodeStatsForceKubeProxy returns true if the node stats client should force the kube proxy direct end point formatting

func IsNodeStatsInsecure added in v1.115.0

func IsNodeStatsInsecure() bool

IsNodeStatsInsecure returns true if the node stats client should skip TLS verification

func IsProductAnalyticsEnabled

func IsProductAnalyticsEnabled() bool

IsProductAnalyticsEnabled returns the environment variable value for ProductAnalyticsEnabledEnvVar

func IsRemoteEnabled

func IsRemoteEnabled() bool

IsRemoteEnabled returns the environment variable value for RemoteEnabledEnvVar which represents whether or not remote write is enabled for prometheus for use with SQL backed persistent storage.

func IsUseCSVProvider

func IsUseCSVProvider() bool

IsUseCSVProvider returns the environment variable value for UseCSVProviderEnvVar which represents whether or not the use of a CSV cost provider is enabled.

func IsUseCustomProvider added in v1.111.0

func IsUseCustomProvider() bool

IsUseCustomProvider returns the environment variable value for UseCustomProviderEnvVar which represents whether or not the use of a custom cost provider is enabled.

func IsValuesReportingEnabled

func IsValuesReportingEnabled() bool

IsValuesReportingEnabled returns the environment variable value for ValuesReportingEnabledEnvVar

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL