Skip to content

Commit 3d36b96

Browse files
authored
Example of script usage for custom cleanup (#1243)
Signed-off-by: Alexey Makhov <[email protected]> Signed-off-by: makhov <[email protected]>
1 parent f623352 commit 3d36b96

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

docs/capi-remote.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,4 +281,37 @@ spec:
281281
- "echo 'Custom cleanup completed'"
282282
```
283283

284-
`useSudo` field will be respected for `customCleanUpCommands` to execute the commands with elevated privileges if needed.
284+
`useSudo` field will be respected for `customCleanUpCommands` to execute the commands with elevated privileges if needed.
285+
286+
Another way to provide custom cleanup logic is to create a script on the machine using `files` and then reference that script in `customCleanUpCommands`. For example:
287+
288+
```yaml
289+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
290+
kind: K0sWorkerConfig
291+
metadata:
292+
name: machine-test-config
293+
namespace: default
294+
spec:
295+
version: v1.32.2+k0s.0
296+
files:
297+
- path: /custom-cleanup-script.sh
298+
content: |
299+
#!/bin/bash
300+
echo "Running custom cleanup script"
301+
# Add your custom cleanup logic here
302+
permissions: "0755"
303+
---
304+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
305+
kind: RemoteMachine
306+
metadata:
307+
name: remote-test-0
308+
namespace: default
309+
spec:
310+
address: 1.2.3.4
311+
port: 22
312+
user: root
313+
sshKeyRef:
314+
name: footloose-key
315+
customCleanUpCommands:
316+
- "/custom-cleanup-script.sh"
317+
```

0 commit comments

Comments
 (0)