Skip to content
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

Fallback to K8S API for getting pods, refactor logging for new warnings #150

Merged
merged 6 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ Read more about [how KRR works](#how-it-works) and [KRR vs Kubernetes VPA](#diff

## Installation

### Requirements

LeaveMyYard marked this conversation as resolved.
Show resolved Hide resolved
KRR requires you to have Prometheus, running either on your cluster or centralized.

Additionally to that, [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics) needs to be running on your cluster, as KRR is dependant on next metrics:
LeaveMyYard marked this conversation as resolved.
Show resolved Hide resolved

- `container_cpu_usage_seconds_total`
- `container_memory_working_set_bytes`
- `kube_replicaset_owner`
- `kube_pod_owner`
- `kube_pod_status_phase`

_Note: If one of last three metrics is absent KRR will still work, but will result in potentially worse results and raise a warning_
LeaveMyYard marked this conversation as resolved.
Show resolved Hide resolved

### With brew (MacOS/Linux):

1. Add our tap:
Expand Down Expand Up @@ -193,9 +207,10 @@ krr simple -v
```

Other helpful flags:
* `--cpu-min` Sets the minimum recommended cpu value in millicores
* `--mem-min` Sets the minimum recommended memory value in MB
* `--history_duration` The duration of the prometheus history data to use (in hours)

- `--cpu-min` Sets the minimum recommended cpu value in millicores
- `--mem-min` Sets the minimum recommended memory value in MB
- `--history_duration` The duration of the prometheus history data to use (in hours)

More specific information on Strategy Settings can be found using

Expand All @@ -209,15 +224,14 @@ krr simple --help

With the [free Robusta SaaS platform](https://home.robusta.dev/) you can:

* See why KRR recommends what it does
* Sort and filter recommendations by namespace, priority, and more
* Copy a YAML snippet to fix the problems KRR finds
- See why KRR recommends what it does
- Sort and filter recommendations by namespace, priority, and more
- Copy a YAML snippet to fix the problems KRR finds

![Robusta UI Screen Shot][ui-screenshot]

<p align="right">(<a href="#readme-top">back to top</a>)</p>


## How it works

### Metrics Gathering
Expand Down Expand Up @@ -431,9 +445,10 @@ python krr.py simple -p "https://prom-api.coralogix..." --coralogix_token

## Grafana Cloud managed Prometheus

For Grafana Cloud managed Prometheus you need to specify prometheus link, prometheus user, and an access token of your Grafana Cloud stack. The Prometheus link and user for the stack can be found on the Grafana Cloud Portal. An access token with a `metrics:read` scope can also be created using Access Policies on the same portal.
For Grafana Cloud managed Prometheus you need to specify prometheus link, prometheus user, and an access token of your Grafana Cloud stack. The Prometheus link and user for the stack can be found on the Grafana Cloud Portal. An access token with a `metrics:read` scope can also be created using Access Policies on the same portal.

Next, run the following command, after setting the values of PROM_URL, PROM_USER, and PROM_TOKEN variables with your Grafana Cloud stack's prometheus link, prometheus user, and access token.

```sh
python krr.py simple -p $PROM_URL --prometheus-auth-header "Bearer ${PROM_USER}:${PROM_TOKEN}" --prometheus-ssl-enabled
```
Expand Down
2 changes: 1 addition & 1 deletion robusta_krr/core/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def set_config(config: Config) -> None:

# NOTE: This class is just a proxy for _config.
# Import settings from this module and use it like it is just a config object.
class _Settings(Config):
class _Settings(Config): # Config here is used for type checking
def __init__(self) -> None:
pass

Expand Down
3 changes: 2 additions & 1 deletion robusta_krr/core/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ async def _calculate_object_recommendations(self, object: K8sObjectData) -> RunR
logger.warning(
f"Was not able to load any pods for {object} from Prometheus.\n\t"
"This could mean that Prometheus is missing some required metrics.\n\t"
"Loaded pods from Kubernetes API instead."
"Loaded pods from Kubernetes API instead.\n\t"
"See more info at https://github.com/robusta-dev/krr#requirements "
)

metrics = await prometheus_loader.gather_data(
Expand Down
Loading