Created
November 4, 2022 21:01
-
-
Save echo-devnull/f9d1ed316a810e6d0635fda219f7a533 to your computer and use it in GitHub Desktop.
Creating a container thas has access to the node it's running on
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
r00t() { | |
if [ -n "$1" ] | |
then | |
kubectl run r00t --restart=Never -it --rm --image f00 --overrides "{\"spec\":{\"hostNetwork\": true, \"hostPID\": true, \"containers\": [{\"name\":\"1\",\"image\":\"alpine\",\"command\":[\"nsenter\",\"--mount=/proc/1/ns/mnt\",\"--\",\"/bin/sh\"],\"stdin\":true, \"tty\":true,\"securityContext\":{\"privileged\":true}}],\"nodeSelector\":{\"kubernetes.io/hostname\":\"$1\"},\"tolerations\":[{\"key\":\"node-role.kubernetes.io/etcd\",\"operator\":\"Exists\",\"effect\":\"NoExecute\"},{\"key\":\"node-role.kubernetes.io/controlplane\",\"operator\":\"Exists\",\"effect\":\"NoSchedule\"}]}}" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment