Skip to content

Instantly share code, notes, and snippets.

@ffledgling
Created April 20, 2018 12:14
Show Gist options
  • Save ffledgling/c5cbe1ba079bcd850d8964cbf7b2c8d7 to your computer and use it in GitHub Desktop.
Save ffledgling/c5cbe1ba079bcd850d8964cbf7b2c8d7 to your computer and use it in GitHub Desktop.
Get a rootcontainer on a kubernetes node. Useful for debugging, when you don't have access to or can't install stuff on the actual node. `kubectl apply -f root-container.yaml` and `kubectl exec -it debug-pod /bin/bash` to execute.
apiVersion: v1
kind: Pod
metadata:
name: debug-pod
spec:
hostNetwork: true
nodeSelector:
kubernetes.io/hostname: kubenode.example.com
containers:
- name: myshell
image: "ubuntu:16.04"
command:
- /bin/sleep
- "30000"
securityContext:
privileged: true
capabilities:
add:
- NET_ADMIN
- SYS_ADMIN
volumeMounts:
- mountPath: /host-root
name: test-volume
volumes:
- name: test-volume
hostPath:
# directory location on host
path: /
# this field is optional
type: Directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment