Files
k9s/plugins/node-root-shell.yaml
T
Sławek Piotrowski 33d592deb4 Log in as root to the node. (#3094)
This executes simple container in host IPC, network and PID space.
Then is uses nsenter to switch other namespaces and execute BASH.
2025-02-15 17:02:47 -07:00

35 lines
784 B
YAML

plugins:
node-root-shell:
shortCut: a
description: Run root shell on node
dangerous: true
scopes:
- nodes
command: bash
background: false
confirm: true
args:
- -c
- |
host="$1"
json='
{
"apiVersion": "v1",
"spec": {
"hostIPC": true,
"hostNetwork": true,
"hostPID": true
'
if ! [[ -z "$host" ]]; then
json+=",
\"nodeSelector\" : {
\"kubernetes.io/hostname\" : \"$host\"
}
";
fi
json+='
}
}
'
kubectl run -ti --image alpine:3.8 --rm --privileged --restart=Never --overrides="$json" root --command -- nsenter -t 1 -m -u -n -i -- bash -l