Last active
July 30, 2024 14:19
-
-
Save chrishiestand/79f758cf3971a6fac60855527dd98c94 to your computer and use it in GitHub Desktop.
Jumpjob: Get a psuedo-shell on a kubernetes node via a pod.
This file contains hidden or 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
# 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: / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
node root filesystem available at
/mnt/hostroot
in this configuration. If you want to target which node the job runs on, usenodeAffinity
: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity