Skip to content

Instantly share code, notes, and snippets.

@mulbc
Last active March 12, 2021 12:53
Show Gist options
  • Save mulbc/6a165c7fde30e629fad33fe5406bdc7e to your computer and use it in GitHub Desktop.
Save mulbc/6a165c7fde30e629fad33fe5406bdc7e to your computer and use it in GitHub Desktop.
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: disk-gatherer
namespace: default
labels:
k8s-app: disk-gatherer
spec:
selector:
matchLabels:
name: disk-gatherer
template:
metadata:
labels:
name: disk-gatherer
spec:
nodeSelector:
cluster.ocs.openshift.io/openshift-storage: ''
containers:
- name: collector
image: alpine:latest
imagePullPolicy: IfNotPresent
command: [ "sh", "-c"]
args:
- cd /sys/block/;
echo "# NODE:${MY_NODE_NAME}";
for disk in nvm*; do
if [[ -f ${disk}/wwid ]]; then
echo "# $disk";
echo "- /dev/disk/by-id/nvme-$(cat ${disk}/wwid)";
fi;
done;
for disk in $(find /sys/devices -name wwid | xargs -n1 dirname); do
if [[ -d ${disk}/block ]]; then
echo "# $(ls -1 ${disk}/block)";
echo "- /dev/disk/by-id/wwn-0x$(cat ${disk}/wwid | cut -c5-)";
fi;
done;
sleep '3600';
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment