Skip to content

Commit f70816a

Browse files
committed
kubectl docs
1 parent 04282fa commit f70816a

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

docs/playbook-reference/actions/remediation.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,47 @@ Node
2626
.. robusta-action:: playbooks.robusta_playbooks.node_actions.uncordon on_node_create
2727

2828
.. robusta-action:: playbooks.robusta_playbooks.node_actions.drain on_node_create
29+
30+
Kubectl
31+
*****************
32+
33+
.. robusta-action:: playbooks.robusta_playbooks.kubectl_enrichments.kubectl_command
34+
35+
Use `kubectl_command` to run kubectl with dynamic placeholders:
36+
- `$namespace`: resource namespace
37+
- `$kind`: resource kind (e.g., Pod, Deployment)
38+
- `$name`: resource name
39+
40+
Example: **Scale Down Deployment on Crash Loop**
41+
42+
.. code-block:: yaml
43+
44+
customPlaybooks:
45+
- name: CrashLoopScaleDown
46+
triggers:
47+
- on_pod_crash_loop:
48+
restart_count: 3
49+
actions:
50+
- kubectl_command:
51+
description: "Scale Down Deployment"
52+
command: kubectl scale --replicas=0 deployment/payment-processing-worker -n $namespace
53+
54+
If the pod is in the `production` namespace, the command will be:
55+
56+
.. code-block:: bash
57+
58+
kubectl scale --replicas=0 deployment/payment-processing-worker -n production
59+
60+
Example: **Delete Crashing Resource**
61+
62+
This deletes the crashing resource by kind, name, and namespace:
63+
64+
.. code-block:: bash
65+
66+
kubectl delete $kind $name -n $namespace
67+
68+
For example, deleting a crashing pod named `api-worker-1` in the `staging` namespace:
69+
70+
.. code-block:: bash
71+
72+
kubectl delete Pod api-worker-1 -n staging

0 commit comments

Comments
 (0)