Add support for resource recommendations using Robusta KRR (#2399)

* Adding Robusta KRR as a K9s  plugin

* Fixed file extension

* Updated details for simplicity

* Updated Author and dependency details
mine
Pavan Gudiwada 2024-01-02 23:03:11 +05:30 committed by GitHub
parent 39d93223d9
commit a766329083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 10 deletions

View File

@ -4,16 +4,17 @@ K9s plugins extend the tool to provide additional functionality via actions to f
Following is an example of some of plugin files in this directory. Other files are not listed in this table.
| Plugin-Name | Description | Available on Views | Shortcut | Kubectl plugin, external dependencies |
|--------------------|------------------------------------------------------------------|--------------------|----------|---------------------------------------------------------------------------------------|
| debug-container.yml| Add [ephemeral debug container][1]<br>([nicolaka/netshoot][2]) | containers | Shift-d | |
| dive.yml | Dive image layers | containers | d | [Dive](https://github.com/wagoodman/dive) |
| get-all.yml | get all resources in a namespace | all | g | [Krew](https://krew.sigs.k8s.io/), [ketall](https://github.com/corneliusweig/ketall/) |
| job_suspend.yml | Suspends a running cronjob | cronjobs | Ctrl-s | |
| k3d_root_shell.yml | Root shell to k3d container | containers | Shift-s | [jq](https://stedolan.github.io/jq/) |
| log_stern.yml | View resource logs using stern | pods | Ctrl-l | |
| log_jq.yml | View resource logs using jq | pods | Ctrl-j | kubectl-plugins/kubectl-jq |
| log_full.yml | get full logs from pod/container | pods/containers | Ctrl-l | |
| Plugin-Name | Description | Available on Views | Shortcut | Kubectl plugin, external dependencies |
|--------------------|------------------------------------------------------------------|--------------------------|----------|---------------------------------------------------------------------------------------|
| debug-container.yml| Add [ephemeral debug container][1]<br>([nicolaka/netshoot][2]) | containers | Shift-d | |
| dive.yml | Dive image layers | containers | d | [Dive](https://github.com/wagoodman/dive) |
| get-all.yml | get all resources in a namespace | all | g | [Krew](https://krew.sigs.k8s.io/), [ketall](https://github.com/corneliusweig/ketall/) |
| job_suspend.yml | Suspends a running cronjob | cronjobs | Ctrl-s | |
| k3d_root_shell.yml | Root shell to k3d container | containers | Shift-s | [jq](https://stedolan.github.io/jq/) |
| resource-recommendations.yml | View recommendations for CPU/Memory requests based on historical data | deployments/daemonsets/statefulsets | Shift-k | [Robusta KRR](https://github.com/robusta-dev/krr) |
| log_stern.yml | View resource logs using stern | pods | Ctrl-l | |
| log_jq.yml | View resource logs using jq | pods | Ctrl-j | kubectl-plugins/kubectl-jq |
| log_full.yml | get full logs from pod/container | pods/containers | Ctrl-l | |
[1]: https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container
[2]: https://github.com/nicolaka/netshoot

View File

@ -0,0 +1,28 @@
plugins:
# Author: Daniel Rubin
# Get recommendations for CPU/Memory requests and limits using Robusta KRR
# Requires Prometheus in the Cluster and Robusta KRR (https://github.com/robusta-dev/krr) on your system
# Open K9s in deployments/daemonsets/statefulsets view, then:
# Shift-K to get recommendations
krr:
shortCut: Shift-K
description: Get krr
scopes:
- deployments
- daemonsets
- statefulsets
command: bash
background: false
confirm: false
args:
- -c
- |
LABELS=$(kubectl get $RESOURCE_NAME $NAME -n $NAMESPACE --context $CONTEXT --show-labels | awk '{print $NF}' | awk '{if(NR>1)print}')
krr simple --cluster $CONTEXT --selector $LABELS
echo "Press 'q' to exit"
while : ; do
read -n 1 k <&1
if [[ $k = q ]] ; then
break
fi
done