|
|
@@ -5,9 +5,11 @@ import (
|
|
|
|
|
|
export "github.com/opencost/opencost/core/pkg/exporter"
|
|
|
"github.com/opencost/opencost/core/pkg/log"
|
|
|
+ "github.com/opencost/opencost/core/pkg/model/kubemodel"
|
|
|
"github.com/opencost/opencost/core/pkg/opencost"
|
|
|
"github.com/opencost/opencost/core/pkg/opencost/exporter/allocation"
|
|
|
"github.com/opencost/opencost/core/pkg/opencost/exporter/asset"
|
|
|
+ exporterkubemodel "github.com/opencost/opencost/core/pkg/opencost/exporter/kubemodel"
|
|
|
"github.com/opencost/opencost/core/pkg/opencost/exporter/networkinsight"
|
|
|
"github.com/opencost/opencost/core/pkg/source"
|
|
|
"github.com/opencost/opencost/core/pkg/storage"
|
|
|
@@ -31,6 +33,7 @@ type PipelinesExportConfig struct {
|
|
|
AllocationPiplineResolutions []time.Duration
|
|
|
AssetPipelineResolutons []time.Duration
|
|
|
NetworkInsightPipelineResolutions []time.Duration
|
|
|
+ KubeModelPipelineResolutions []time.Duration
|
|
|
}
|
|
|
|
|
|
// defaultPipelineExportResolutions returns the default export configuration for the pipeline
|
|
|
@@ -57,6 +60,7 @@ type PipelineExportControllers struct {
|
|
|
AllocationExportController *export.ComputeExportControllerGroup[opencost.AllocationSet]
|
|
|
AssetExportController *export.ComputeExportControllerGroup[opencost.AssetSet]
|
|
|
NetworkInsightExportController *export.ComputeExportControllerGroup[opencost.NetworkInsightSet]
|
|
|
+ KubeModelExportController *export.ComputeExportControllerGroup[kubemodel.KubeModelSet]
|
|
|
}
|
|
|
|
|
|
// NewPipelineExportControllers creates a new PipelineExportControllers instance with the given cluster ID, storage implementation, cost model, and configuration.
|
|
|
@@ -131,10 +135,30 @@ func NewPipelineExportControllers(clusterId string, store storage.Storage, cm Co
|
|
|
networkInsightExportControllers = append(networkInsightExportControllers, networkInsightController)
|
|
|
}
|
|
|
|
|
|
+ // KubeModel sources and exporters
|
|
|
+ kubeModelSource := exporterkubemodel.NewKubeModelComputeSource(nil) // TODO: CREATE AN IMPLEMENTATION OF ComputeSource[kubemodel.KubeModelSet]
|
|
|
+ kubeModelExportControllers := []*export.ComputeExportController[kubemodel.KubeModelSet]{}
|
|
|
+
|
|
|
+ for _, res := range config.KubeModelPipelineResolutions {
|
|
|
+ if res < sourceResolution {
|
|
|
+ log.Warnf("Configured KubeModel pipeline resolution %dm is less than source resolution %dm. Not configuring the exporter for this resolution.", int64(res.Minutes()), int64(sourceResolution.Minutes()))
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ kubeModelController, err := NewComputePipelineExportController(clusterId, store, kubeModelSource, res)
|
|
|
+ if err != nil {
|
|
|
+ log.Errorf("Failed to create KubeModel export controller for resolution: %s - %v", timeutil.DurationString(res), err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ kubeModelExportControllers = append(kubeModelExportControllers, kubeModelController)
|
|
|
+ }
|
|
|
+
|
|
|
return &PipelineExportControllers{
|
|
|
AllocationExportController: export.NewComputeExportControllerGroup(allocExportControllers...),
|
|
|
AssetExportController: export.NewComputeExportControllerGroup(assetExportControllers...),
|
|
|
NetworkInsightExportController: export.NewComputeExportControllerGroup(networkInsightExportControllers...),
|
|
|
+ KubeModelExportController: export.NewComputeExportControllerGroup(kubeModelExportControllers...),
|
|
|
}
|
|
|
}
|
|
|
|