-
-
Save Alevsk/e4e8b0a37832e1ad0bcaa212ab2fc00d to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
node=${1} | |
if [ -n "${node}" ]; then | |
nodeSelector='"nodeSelector": { "kubernetes.io/hostname": "'${node:?}'" },' | |
else | |
nodeSelector="" | |
fi | |
set -x | |
kubectl run ${USER+${USER}-}sudo --restart=Never -it \ | |
--image overriden --overrides ' | |
{ | |
"spec": { | |
"hostPID": true, | |
"hostNetwork": true, | |
'"${nodeSelector?}"' | |
"containers": [ | |
{ | |
"name": "busybox", | |
"image": "alpine:3.7", | |
"command": ["nsenter", "--mount=/proc/1/ns/mnt", "--", "sh", "-c", "hostname sudo--$(cat /etc/hostname); exec /bin/bash"], | |
"stdin": true, | |
"tty": true, | |
"resources": {"requests": {"cpu": "10m"}}, | |
"securityContext": { | |
"privileged": true | |
} | |
} | |
] | |
} | |
}' --rm --attach |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment