-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prometheus workload loader #266
Open
LeaveMyYard
wants to merge
26
commits into
main
Choose a base branch
from
prometheus-workload-loader
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4fedd82
Add multiple workload loaders, refactor kubeapi workload loader
LeaveMyYard c7ad1cd
Moved the logic from #93 for a new refined structure
LeaveMyYard bf90978
Implement remaining kinds in prometheus workload loader
LeaveMyYard 7cd0c59
Filter Cronjob-created jobs from display
LeaveMyYard 4044b4a
Fix cluster selector
LeaveMyYard b9a62a0
Minor bug fix
LeaveMyYard 7e8f1f4
BaseClusterLoader, class structure change, not finished
LeaveMyYard 4c1f5c9
Finished structure changes and workload loaders
LeaveMyYard 7124c80
PrometeusClusterLoader.list_clusters implementation
LeaveMyYard d1ad17d
Minor additional logging improvements
LeaveMyYard f7d8412
Minor debug comment
LeaveMyYard 09c372b
Merge branch 'main' into prometheus-workload-loader
LeaveMyYard 59cc29d
Fix prometheus auto-discovery
LeaveMyYard d4adcf8
Merge branch 'prometheus-workload-loader' of https://github.com/robus…
LeaveMyYard eb84c95
Logging improvement
LeaveMyYard e350084
Add HPA detection for prometheus mode
LeaveMyYard d4e09b0
Fix tests
LeaveMyYard 7b6be35
Rework ckyster selector for prometheus mode
LeaveMyYard dce207f
Remove test raise
LeaveMyYard 43ffb7f
Fix HPAKey
LeaveMyYard 2403898
One more HPAKey fix
LeaveMyYard 73eb5f3
Deprecate --prometheus-cluster-label
aantn 24af7f5
Bug fix - thank you @deutschj
aantn 9fda8be
add TODO
aantn f71abd1
Fix ArgoRollouts (#308)
aantn 66389e6
Prevent single errors from failing scan (#307)
aantn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aantn I think this requires a change on the robusta-runner as well
see here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arikalon1 it should be fine. I'm not deprecating
--prometheus-label
, just adding another option with a name that makes more sense.I did deprecate
--prometheus-cluster-label
but the runner doesn't pass that by default.