|
@@ -7,7 +7,6 @@ import (
|
|
|
"github.com/opencost/opencost/pkg/log"
|
|
"github.com/opencost/opencost/pkg/log"
|
|
|
|
|
|
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
|
- autoscaling "k8s.io/api/autoscaling/v2beta1"
|
|
|
|
|
batchv1 "k8s.io/api/batch/v1"
|
|
batchv1 "k8s.io/api/batch/v1"
|
|
|
v1 "k8s.io/api/core/v1"
|
|
v1 "k8s.io/api/core/v1"
|
|
|
"k8s.io/api/policy/v1beta1"
|
|
"k8s.io/api/policy/v1beta1"
|
|
@@ -61,9 +60,6 @@ type ClusterCache interface {
|
|
|
// GetAllJobs returns all the cached jobs
|
|
// GetAllJobs returns all the cached jobs
|
|
|
GetAllJobs() []*batchv1.Job
|
|
GetAllJobs() []*batchv1.Job
|
|
|
|
|
|
|
|
- // GetAllHorizontalPodAutoscalers returns all cached horizontal pod autoscalers
|
|
|
|
|
- GetAllHorizontalPodAutoscalers() []*autoscaling.HorizontalPodAutoscaler
|
|
|
|
|
-
|
|
|
|
|
// GetAllPodDisruptionBudgets returns all cached pod disruption budgets
|
|
// GetAllPodDisruptionBudgets returns all cached pod disruption budgets
|
|
|
GetAllPodDisruptionBudgets() []*v1beta1.PodDisruptionBudget
|
|
GetAllPodDisruptionBudgets() []*v1beta1.PodDisruptionBudget
|
|
|
|
|
|
|
@@ -91,7 +87,6 @@ type KubernetesClusterCache struct {
|
|
|
pvcWatch WatchController
|
|
pvcWatch WatchController
|
|
|
storageClassWatch WatchController
|
|
storageClassWatch WatchController
|
|
|
jobsWatch WatchController
|
|
jobsWatch WatchController
|
|
|
- hpaWatch WatchController
|
|
|
|
|
pdbWatch WatchController
|
|
pdbWatch WatchController
|
|
|
replicationControllerWatch WatchController
|
|
replicationControllerWatch WatchController
|
|
|
stop chan struct{}
|
|
stop chan struct{}
|
|
@@ -107,7 +102,6 @@ func NewKubernetesClusterCache(client kubernetes.Interface) ClusterCache {
|
|
|
appsRestClient := client.AppsV1().RESTClient()
|
|
appsRestClient := client.AppsV1().RESTClient()
|
|
|
storageRestClient := client.StorageV1().RESTClient()
|
|
storageRestClient := client.StorageV1().RESTClient()
|
|
|
batchClient := client.BatchV1().RESTClient()
|
|
batchClient := client.BatchV1().RESTClient()
|
|
|
- autoscalingClient := client.AutoscalingV2beta1().RESTClient()
|
|
|
|
|
pdbClient := client.PolicyV1beta1().RESTClient()
|
|
pdbClient := client.PolicyV1beta1().RESTClient()
|
|
|
|
|
|
|
|
kubecostNamespace := env.GetKubecostNamespace()
|
|
kubecostNamespace := env.GetKubecostNamespace()
|
|
@@ -128,7 +122,6 @@ func NewKubernetesClusterCache(client kubernetes.Interface) ClusterCache {
|
|
|
pvcWatch: NewCachingWatcher(coreRestClient, "persistentvolumeclaims", &v1.PersistentVolumeClaim{}, "", fields.Everything()),
|
|
pvcWatch: NewCachingWatcher(coreRestClient, "persistentvolumeclaims", &v1.PersistentVolumeClaim{}, "", fields.Everything()),
|
|
|
storageClassWatch: NewCachingWatcher(storageRestClient, "storageclasses", &stv1.StorageClass{}, "", fields.Everything()),
|
|
storageClassWatch: NewCachingWatcher(storageRestClient, "storageclasses", &stv1.StorageClass{}, "", fields.Everything()),
|
|
|
jobsWatch: NewCachingWatcher(batchClient, "jobs", &batchv1.Job{}, "", fields.Everything()),
|
|
jobsWatch: NewCachingWatcher(batchClient, "jobs", &batchv1.Job{}, "", fields.Everything()),
|
|
|
- hpaWatch: NewCachingWatcher(autoscalingClient, "horizontalpodautoscalers", &autoscaling.HorizontalPodAutoscaler{}, "", fields.Everything()),
|
|
|
|
|
pdbWatch: NewCachingWatcher(pdbClient, "poddisruptionbudgets", &v1beta1.PodDisruptionBudget{}, "", fields.Everything()),
|
|
pdbWatch: NewCachingWatcher(pdbClient, "poddisruptionbudgets", &v1beta1.PodDisruptionBudget{}, "", fields.Everything()),
|
|
|
replicationControllerWatch: NewCachingWatcher(coreRestClient, "replicationcontrollers", &v1.ReplicationController{}, "", fields.Everything()),
|
|
replicationControllerWatch: NewCachingWatcher(coreRestClient, "replicationcontrollers", &v1.ReplicationController{}, "", fields.Everything()),
|
|
|
}
|
|
}
|
|
@@ -140,7 +133,7 @@ func NewKubernetesClusterCache(client kubernetes.Interface) ClusterCache {
|
|
|
wg.Add(1)
|
|
wg.Add(1)
|
|
|
go initializeCache(kcc.kubecostConfigMapWatch, &wg, cancel)
|
|
go initializeCache(kcc.kubecostConfigMapWatch, &wg, cancel)
|
|
|
} else {
|
|
} else {
|
|
|
- wg.Add(16)
|
|
|
|
|
|
|
+ wg.Add(15)
|
|
|
go initializeCache(kcc.kubecostConfigMapWatch, &wg, cancel)
|
|
go initializeCache(kcc.kubecostConfigMapWatch, &wg, cancel)
|
|
|
go initializeCache(kcc.namespaceWatch, &wg, cancel)
|
|
go initializeCache(kcc.namespaceWatch, &wg, cancel)
|
|
|
go initializeCache(kcc.nodeWatch, &wg, cancel)
|
|
go initializeCache(kcc.nodeWatch, &wg, cancel)
|
|
@@ -154,7 +147,6 @@ func NewKubernetesClusterCache(client kubernetes.Interface) ClusterCache {
|
|
|
go initializeCache(kcc.pvcWatch, &wg, cancel)
|
|
go initializeCache(kcc.pvcWatch, &wg, cancel)
|
|
|
go initializeCache(kcc.storageClassWatch, &wg, cancel)
|
|
go initializeCache(kcc.storageClassWatch, &wg, cancel)
|
|
|
go initializeCache(kcc.jobsWatch, &wg, cancel)
|
|
go initializeCache(kcc.jobsWatch, &wg, cancel)
|
|
|
- go initializeCache(kcc.hpaWatch, &wg, cancel)
|
|
|
|
|
go initializeCache(kcc.podWatch, &wg, cancel)
|
|
go initializeCache(kcc.podWatch, &wg, cancel)
|
|
|
go initializeCache(kcc.replicationControllerWatch, &wg, cancel)
|
|
go initializeCache(kcc.replicationControllerWatch, &wg, cancel)
|
|
|
}
|
|
}
|
|
@@ -185,7 +177,6 @@ func (kcc *KubernetesClusterCache) Run() {
|
|
|
go kcc.pvcWatch.Run(1, stopCh)
|
|
go kcc.pvcWatch.Run(1, stopCh)
|
|
|
go kcc.storageClassWatch.Run(1, stopCh)
|
|
go kcc.storageClassWatch.Run(1, stopCh)
|
|
|
go kcc.jobsWatch.Run(1, stopCh)
|
|
go kcc.jobsWatch.Run(1, stopCh)
|
|
|
- go kcc.hpaWatch.Run(1, stopCh)
|
|
|
|
|
go kcc.pdbWatch.Run(1, stopCh)
|
|
go kcc.pdbWatch.Run(1, stopCh)
|
|
|
go kcc.replicationControllerWatch.Run(1, stopCh)
|
|
go kcc.replicationControllerWatch.Run(1, stopCh)
|
|
|
|
|
|
|
@@ -309,15 +300,6 @@ func (kcc *KubernetesClusterCache) GetAllJobs() []*batchv1.Job {
|
|
|
return jobs
|
|
return jobs
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (kcc *KubernetesClusterCache) GetAllHorizontalPodAutoscalers() []*autoscaling.HorizontalPodAutoscaler {
|
|
|
|
|
- var hpas []*autoscaling.HorizontalPodAutoscaler
|
|
|
|
|
- items := kcc.hpaWatch.GetAll()
|
|
|
|
|
- for _, hpa := range items {
|
|
|
|
|
- hpas = append(hpas, hpa.(*autoscaling.HorizontalPodAutoscaler))
|
|
|
|
|
- }
|
|
|
|
|
- return hpas
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
func (kcc *KubernetesClusterCache) GetAllPodDisruptionBudgets() []*v1beta1.PodDisruptionBudget {
|
|
func (kcc *KubernetesClusterCache) GetAllPodDisruptionBudgets() []*v1beta1.PodDisruptionBudget {
|
|
|
var pdbs []*v1beta1.PodDisruptionBudget
|
|
var pdbs []*v1beta1.PodDisruptionBudget
|
|
|
items := kcc.pdbWatch.GetAll()
|
|
items := kcc.pdbWatch.GetAll()
|