Skip to content

Instantly share code, notes, and snippets.

@alexeldeib
Last active November 8, 2024 19:13
Show Gist options
  • Save alexeldeib/01f2d3efc8fe17cca7625ecb7c1ec707 to your computer and use it in GitHub Desktop.
Save alexeldeib/01f2d3efc8fe17cca7625ecb7c1ec707 to your computer and use it in GitHub Desktop.
Privileged pod with hostNetwork and hostPid
apiVersion: apps/v1
kind: Deployment
metadata:
name: &name debug2
labels:
app: *name
spec:
replicas: 1
selector:
matchLabels:
app: *name
template:
metadata:
labels:
app: *name
spec:
# nodeSelector:
# cloud.google.com/gke-accelerator: nvidia-tesla-a100
# tolerations:
# - key: "node-role.kubernetes.io/master"
# operator: "Exists"
#
# # above OR below needed ONLY, not both
# #
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: node-role.kubernetes.io/master
# operator: Exists
hostNetwork: true
hostPID: true
containers:
- image: docker.io/library/ubuntu:18.04
name: debug
command: ["sleep", "infinity"]
env:
- name: NVIDIA_VISIBLE_DEVICES
value: all
resources:
requests:
nvidia.com/gpu: 1
limits:
nvidia.com/gpu: 1
securityContext:
privileged: true
capabilities:
add: ["SYS_PTRACE", "SYS_RAWIO"]
@alexeldeib
Copy link
Author

Usage:

kubectl apply -f https://gist.githubusercontent.com/alexeldeib/01f2d3efc8fe17cca7625ecb7c1ec707/raw/982459919f6b51975e519bf6aa7b3cd2b224d4fb/deploy.yaml
kubectl exec -it $(kubectl get pod -l app=debug -o jsonpath="{.items[0].metadata.name}") -- bash -c "nsenter -t 1 -m bash"

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