Created
July 29, 2021 17:21
-
-
Save nithu0115/7767dbda79da32e5af6c5bcc7caf2cd4 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 | |
# | |
# The access this gives you is rather terrifing. Use sparingly. | |
# | |
set -e -x | |
node=$1 | |
trap "kubectl delete pod nodesh-$node" EXIT | |
kubectl create -f - <<EOF | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: nodesh-$node | |
spec: | |
nodeName: $node | |
restartPolicy: Never | |
hostPID: true | |
hostIPC: true | |
hostNetwork: true | |
containers: | |
- name: shell | |
image: anguslees/myshell:latest | |
stdin: true | |
tty: true | |
stdinOnce: true | |
securityContext: {privileged: true} | |
volumeMounts: | |
- name: root | |
mountPath: "/target" | |
readOnly: true | |
- name: docksock | |
mountPath: "/var/run/docker.sock" | |
readOnly: true | |
- name: root | |
mountPath: "/root" | |
readOnly: false | |
volumes: | |
- name: root | |
hostPath: | |
path: / | |
type: Directory | |
- name: docksock | |
hostPath: | |
path: "/var/run/docker.sock" | |
EOF | |
# --pod-running-timeout doesn't seem to work reliably | |
while ! kubectl logs -c shell nodesh-$node >/dev/null 2>&1; do | |
sleep 1 | |
done | |
kubectl attach nodesh-$node -c shell -ti --pod-running-timeout=2m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment