Skip to content
Merged
Changes from all commits
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
44 changes: 44 additions & 0 deletions docs/playbook-reference/actions/remediation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,47 @@ Node
.. robusta-action:: playbooks.robusta_playbooks.node_actions.uncordon on_node_create

.. robusta-action:: playbooks.robusta_playbooks.node_actions.drain on_node_create

Kubectl
*****************

.. robusta-action:: playbooks.robusta_playbooks.kubectl_enrichments.kubectl_command

Use `kubectl_command` to run kubectl with dynamic placeholders:
- `$namespace`: resource namespace
- `$kind`: resource kind (e.g., Pod, Deployment)
- `$name`: resource name

Example: **Scale Down Deployment on Crash Loop**

.. code-block:: yaml

customPlaybooks:
- name: CrashLoopScaleDown
triggers:
- on_pod_crash_loop:
restart_count: 3
actions:
- kubectl_command:
description: "Scale Down Deployment"
command: kubectl scale --replicas=0 deployment/payment-processing-worker -n $namespace

If the pod is in the `production` namespace, the command will be:

.. code-block:: bash

kubectl scale --replicas=0 deployment/payment-processing-worker -n production

Example: **Delete Crashing Resource**

This deletes the crashing resource by kind, name, and namespace:

.. code-block:: bash

kubectl delete $kind $name -n $namespace

For example, deleting a crashing pod named `api-worker-1` in the `staging` namespace:

.. code-block:: bash

kubectl delete Pod api-worker-1 -n staging
Loading