diff options
| author | Pavel Zhukov <33721692+LeaveMyYard@users.noreply.github.com> | 2023-05-15 13:04:12 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-15 13:04:12 +0300 |
| commit | c7ae36f5df4955ab81e992efa70dadf3fdb31dc8 (patch) | |
| tree | 148a3e3e4a1694f17b833de48c543bca0078fdb1 | |
| parent | aa0249cad72f4fe3e33a89a39e44873b21ff5f17 (diff) | |
| parent | 8e19fbf75edfab35d48fee01663ac70058fe2229 (diff) | |
Merge branch 'main' into replace_decimal_to_numpy
| -rw-r--r-- | README.md | 51 | ||||
| -rw-r--r-- | robusta_krr/core/models/config.py | 11 |
2 files changed, 30 insertions, 32 deletions
@@ -139,42 +139,30 @@ More features (like seeing graphs, based on which recommendations were made) com ### Installation -<!-- _Depending on your operating system, select the appropriate installation method._ - -#### Linux - -```sh -sudo apt install robusta-krr -```` - -#### MacOS +#### Installing with brew (MacOS/Linux): +1. Add our tap: ```sh -brew install robusta-krr +brew tap robusta-dev/homebrew-krr ``` -#### Windows - +2. Install KRR: ```sh -choco install robusta-krr +brew install krr ``` -#### Debian - +3. Check that installation was successfull (First launch might take a little longer): ```sh -sudo apt install robusta-krr +krr --help ``` -#### Docker +#### Installing on Windows: -`````sh -docker pull robusta/krr -```` +We will use chocolatey for easier installing on Windows, but currently it is not yet supported. +If you want to still run on Windows, you can do that by installing using brew (see above) on [WSL2](https://docs.brew.sh/Homebrew-on-Linux), or installing manually: #### Manual ---> - 1. Make sure you have [Python 3.9](https://www.python.org/downloads/) (or greater) installed 2. Clone the repo: @@ -195,6 +183,9 @@ pip install -r requirements.txt python krr.py --help ``` +Notice that using source code requires you to run as a python script, when installing with brew allows to run `krr`. +All above examples show running command as `krr ...`, replace it with `python krr.py ...` if you are using a manual installation. + To use krr with [Google Cloud Managed Service for Prometheus](https://cloud.google.com/stackdriver/docs/managed-prometheus) some [additional configuration](./docs/google-cloud-managed-service-for-prometheus.md) is necessary. <p align="right">(<a href="#readme-top">back to top</a>)</p> @@ -206,43 +197,43 @@ To use krr with [Google Cloud Managed Service for Prometheus](https://cloud.goog Straightforward usage, to run the simple strategy: ```sh -python krr.py simple +krr simple ``` If you want only specific namespaces (default and ingress-nginx): ```sh -python krr.py simple -n default -n ingress-nginx +krr simple -n default -n ingress-nginx ``` By default krr will run in the current context. If you want to run it in a different context: ```sh -python krr.py simple -c my-cluster-1 -c my-cluster-2 +krr simple -c my-cluster-1 -c my-cluster-2 ``` If you want to get the output in JSON format (--logtostderr is required so no logs go to the result file): ```sh -python krr.py simple --logtostderr -f json > result.json +krr simple --logtostderr -f json > result.json ``` If you want to get the output in YAML format: ```sh -python krr.py simple --logtostderr -f yaml > result.yaml +krr simple --logtostderr -f yaml > result.yaml ``` If you want to see additional debug logs: ```sh -python krr.py simple -v +krr simple -v ``` More specific information on Strategy Settings can be found using ```sh -python krr.py simple --help +krr simple --help ``` <p align="right">(<a href="#readme-top">back to top</a>)</p> @@ -279,7 +270,7 @@ kubectl port-forward pod/kube-prometheus-st-prometheus-0 9090 Then, open another terminal and run krr in it, giving an explicit prometheus url: ```sh -python krr.py simple -p http://127.0.0.1:9090 +krr simple -p http://127.0.0.1:9090 ``` <p align="right">(<a href="#readme-top">back to top</a>)</p> diff --git a/robusta_krr/core/models/config.py b/robusta_krr/core/models/config.py index fb910a6..75a5403 100644 --- a/robusta_krr/core/models/config.py +++ b/robusta_krr/core/models/config.py @@ -1,5 +1,6 @@ from typing import Any, Literal, Optional, Union +import sys import pydantic as pd from kubernetes import config from kubernetes.config.config_exception import ConfigException @@ -9,10 +10,16 @@ from robusta_krr.core.abstract.strategies import AnyStrategy, BaseStrategy try: config.load_incluster_config() - IN_CLUSTER = True except ConfigException: - config.load_kube_config() + try: + config.load_kube_config() + except ConfigException: + print("[CRITICAL] Could not load kubernetes configuration. Do you have kubeconfig set up?") + sys.exit(1) + IN_CLUSTER = False +else: + IN_CLUSTER = True class Config(pd.BaseSettings): |
