Skip to content

Instantly share code, notes, and snippets.

@aceat64
Last active April 15, 2021 03:56
Show Gist options
  • Save aceat64/de87202f17a9a78f115b5881edefb8b8 to your computer and use it in GitHub Desktop.
Save aceat64/de87202f17a9a78f115b5881edefb8b8 to your computer and use it in GitHub Desktop.
k8s-disk-zapper
!!!!!!!!!!!!!!!!!
!!! DANGEROUS !!!
!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! THESE JOBS WILL WIPE OUT DATA !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
---
apiVersion: batch/v1
kind: Job
metadata:
name: disk-zapper-worker-0
spec:
parallelism: 1
completions: 1
backoffLimit: 1
template:
spec:
containers:
- name: wipe
image: rook/ceph:v1.5.9
volumeMounts:
- mountPath: /rook
name: rook-volume
command:
- /bin/sh
- -c
- |
echo "Zapping /dev/sda"
/usr/sbin/sgdisk --zap-all /dev/sda
echo "Wiping first 100MB of /dev/sda"
dd if=/dev/zero of=/dev/sda bs=1M count=100 oflag=direct,dsync
echo "Deleting data from /var/lib/rook on host"
rm -rf /rook/*
ls -la /rook
echo "NUKE COMPLETE"
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
runAsUser: 0
runAsNonRoot: false
readOnlyRootFilesystem: false
volumes:
- name: rook-volume
hostPath:
path: /var/lib/rook
nodeSelector:
kubernetes.io/hostname: worker-0
restartPolicy: Never
---
apiVersion: batch/v1
kind: Job
metadata:
name: disk-zapper-worker-1
spec:
parallelism: 1
completions: 1
backoffLimit: 1
template:
spec:
containers:
- name: wipe
image: rook/ceph:v1.5.9
volumeMounts:
- mountPath: /rook
name: rook-volume
command:
- /bin/sh
- -c
- |
echo "Zapping /dev/sda"
/usr/sbin/sgdisk --zap-all /dev/sda
echo "Wiping first 100MB of /dev/sda"
dd if=/dev/zero of=/dev/sda bs=1M count=100 oflag=direct,dsync
echo "Deleting data from /var/lib/rook on host"
rm -rf /rook/*
ls -la /rook
echo "NUKE COMPLETE"
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
runAsUser: 0
runAsNonRoot: false
readOnlyRootFilesystem: false
volumes:
- name: rook-volume
hostPath:
path: /var/lib/rook
nodeSelector:
kubernetes.io/hostname: worker-1
restartPolicy: Never
---
apiVersion: batch/v1
kind: Job
metadata:
name: disk-zapper-worker-2
spec:
parallelism: 1
completions: 1
backoffLimit: 1
template:
spec:
containers:
- name: wipe
image: rook/ceph:v1.5.9
volumeMounts:
- mountPath: /rook
name: rook-volume
command:
- /bin/sh
- -c
- |
echo "Zapping /dev/sda"
/usr/sbin/sgdisk --zap-all /dev/sda
echo "Wiping first 100MB of /dev/sda"
dd if=/dev/zero of=/dev/sda bs=1M count=100 oflag=direct,dsync
echo "Deleting data from /var/lib/rook on host"
rm -rf /rook/*
ls -la /rook
echo "NUKE COMPLETE"
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
runAsUser: 0
runAsNonRoot: false
readOnlyRootFilesystem: false
volumes:
- name: rook-volume
hostPath:
path: /var/lib/rook
nodeSelector:
kubernetes.io/hostname: worker-2
restartPolicy: Never
---
apiVersion: batch/v1
kind: Job
metadata:
name: disk-zapper-worker-3
spec:
parallelism: 1
completions: 1
backoffLimit: 1
template:
spec:
containers:
- name: wipe
image: rook/ceph:v1.5.9
volumeMounts:
- mountPath: /rook
name: rook-volume
command:
- /bin/sh
- -c
- |
echo "Zapping /dev/sda"
/usr/sbin/sgdisk --zap-all /dev/sda
echo "Wiping first 100MB of /dev/sda"
dd if=/dev/zero of=/dev/sda bs=1M count=100 oflag=direct,dsync
echo "Deleting data from /var/lib/rook on host"
rm -rf /rook/*
ls -la /rook
echo "NUKE COMPLETE"
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
runAsUser: 0
runAsNonRoot: false
readOnlyRootFilesystem: false
volumes:
- name: rook-volume
hostPath:
path: /var/lib/rook
nodeSelector:
kubernetes.io/hostname: worker-3
restartPolicy: Never
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment