-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished structure changes and workload loaders
- Loading branch information
1 parent
7e8f1f4
commit 4c1f5c9
Showing
27 changed files
with
290 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from __future__ import annotations | ||
|
||
import abc | ||
import logging | ||
from typing import Optional, TYPE_CHECKING | ||
|
||
from .workload_loader import BaseWorkloadLoader | ||
|
||
if TYPE_CHECKING: | ||
from robusta_krr.core.integrations.prometheus.connector import PrometheusConnector | ||
|
||
|
||
logger = logging.getLogger("krr") | ||
|
||
|
||
class BaseClusterLoader(abc.ABC): | ||
""" | ||
A class that wraps loading data from multiple clusters. | ||
For example, a centralized prometheus server that can query multiple clusters. | ||
Or one kubeconfig can define connections to multiple clusters. | ||
""" | ||
|
||
@abc.abstractmethod | ||
async def list_clusters(self) -> Optional[list[str]]: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def get_workload_loader(self, cluster: Optional[str]) -> BaseWorkloadLoader: | ||
pass | ||
|
||
def try_get_workload_loader(self, cluster: Optional[str]) -> Optional[BaseWorkloadLoader]: | ||
try: | ||
return self.get_workload_loader(cluster) | ||
except Exception as e: | ||
logger.error(f"Could not connect to cluster {cluster} and will skip it: {e}") | ||
return None | ||
|
||
@abc.abstractmethod | ||
def get_prometheus(self, cluster: Optional[str]) -> PrometheusConnector: | ||
""" | ||
Connect to a Prometheus server and return a PrometheusConnector instance. | ||
Cluster = None means that prometheus is the only one: either centralized or in-cluster. | ||
raise prometrix.PrometheusNotFound if Prometheus is not available. | ||
""" | ||
|
||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import abc | ||
import logging | ||
|
||
from robusta_krr.core.models.objects import K8sWorkload, PodData | ||
|
||
|
||
logger = logging.getLogger("krr") | ||
|
||
|
||
class BaseWorkloadLoader(abc.ABC): | ||
"""A base class for single cluster workload loaders.""" | ||
|
||
@abc.abstractmethod | ||
async def list_workloads(self) -> list[K8sWorkload]: | ||
pass | ||
|
||
|
||
class IListPodsFallback(abc.ABC): | ||
"""This is an interface that a workload loader can implement to have a fallback method to list pods.""" | ||
|
||
@abc.abstractmethod | ||
async def load_pods(self, object: K8sWorkload) -> list[PodData]: | ||
pass |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 0 additions & 13 deletions
13
robusta_krr/core/integrations/kubernetes/workload_loader/__init__.py
This file was deleted.
Oops, something went wrong.
57 changes: 0 additions & 57 deletions
57
robusta_krr/core/integrations/kubernetes/workload_loader/base.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.