Skip to content

Commit

Permalink
feat(2896): Add toggle keda plugin (#2897)
Browse files Browse the repository at this point in the history
* feat(2896): Add toggle keda plugin

Also update formating of plugins readme table and fix links

Signed-off-by: SamoKopecky <[email protected]>

* chore: Fix table formating

Signed-off-by: SamoKopecky <[email protected]>

---------

Signed-off-by: SamoKopecky <[email protected]>
  • Loading branch information
SamoKopecky authored Oct 14, 2024
1 parent 42bc8fc commit f139a57
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
28 changes: 16 additions & 12 deletions plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ 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/) |
| 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 | |
| ai-incident-investigation.yaml | Run AI investigation on application issues to find the root cause in seconds | all | Shift-h/o | [HolmesGPT](https://github.com/robusta-dev/holmesgpt) |
| 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 | |
| ai-incident-investigation.yaml | Run AI investigation on application issues to find the root cause in seconds | all | Shift-h/o | [HolmesGPT](https://github.com/robusta-dev/holmesgpt) |
| toggle-keda | Enable/disable [keda](3) ScaledObject autoscaler | scaledobjects | Ctrl-N | |


[1]: https://kubernetes.io/docs/tasks/debug/debug-application/debug-running-pod/#ephemeral-container
[2]: https://github.com/nicolaka/netshoot
[3]: https://keda.sh/
26 changes: 26 additions & 0 deletions plugins/keda-toggle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
plugins:
toggle-keda:
shortCut: Ctrl-N
override: false
overwriteOutput: true
confirm: false
dangerous: true
description: Toggle autoscaling on keda scaledobject
scopes:
- scaledobjects
command: bash
background: true
args:
- -c
- |
ANNOTATION="autoscaling.keda.sh/paused-replicas"
if kubectl get scaledobject $NAME -n $NAMESPACE -o yaml | grep -q "$ANNOTATION: \"0\""; then
# If annotation found, remove it
kubectl annotate scaledobject $NAME "$ANNOTATION"- -n $NAMESPACE --context $CONTEXT >/dev/null && echo "Keda autoscaling for $NAME enabled"
else
# If annotation not found, add it
kubectl annotate scaledobject $NAME "$ANNOTATION"=0 -n $NAMESPACE --context $CONTEXT >/dev/null && echo "Keda autoscaling for $NAME disabled"
fi

0 comments on commit f139a57

Please sign in to comment.