-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This executes simple container in host IPC, network and PID space. Then is uses nsenter to switch other namespaces and execute BASH.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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 |