Skip to content

Instantly share code, notes, and snippets.

@chrishiestand
Last active July 30, 2024 14:19
Show Gist options
  • Save chrishiestand/79f758cf3971a6fac60855527dd98c94 to your computer and use it in GitHub Desktop.
Save chrishiestand/79f758cf3971a6fac60855527dd98c94 to your computer and use it in GitHub Desktop.
Jumpjob: Get a psuedo-shell on a kubernetes node via a pod.
# Usage:
# kubctl apply -f jumpjob.yaml
# Wait until pod is running and then:
# kubectl exec -it $(kubectl get pod -l job-name=jumpjob -o jsonpath='{.items[0].metadata.name}') /bin/bash
apiVersion: batch/v1
kind: Job
metadata:
name: jumpjob
spec:
template:
spec:
hostNetwork: true
hostPID: true
containers:
- name: jump
image: ubuntu
command: ["/bin/sleep", "12h"]
securityContext:
privileged: true
volumeMounts:
- mountPath: /mnt/hostroot
name: hostroot
restartPolicy: Never
volumes:
- name: hostroot
hostPath:
path: /
@chrishiestand
Copy link
Author

chrishiestand commented Jun 12, 2018

node root filesystem available at /mnt/hostroot in this configuration. If you want to target which node the job runs on, use nodeAffinity: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment