Created
September 17, 2024 20:14
-
-
Save jmarhee/f4079532115bba63cd111d48497d6d6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Create a namespace for the benchmark | |
kubectl create namespace storage-benchmark | |
# Deploy Rancher Local Path Provisioner | |
kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml | |
# Deploy DirectPV (assuming you have a YAML file for DirectPV deployment) | |
kubectl apply -f directpv-deployment.yaml | |
# Create a PersistentVolumeClaim for Rancher Local Path Provisioner | |
cat <<EOF | kubectl apply -f - | |
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: local-path-pvc | |
namespace: storage-benchmark | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 10Gi | |
storageClassName: local-path | |
EOF | |
# Create a PersistentVolumeClaim for DirectPV | |
cat <<EOF | kubectl apply -f - | |
apiVersion: v1 | |
kind: PersistentVolumeClaim | |
metadata: | |
name: directpv-pvc | |
namespace: storage-benchmark | |
spec: | |
accessModes: | |
- ReadWriteOnce | |
resources: | |
requests: | |
storage: 10Gi | |
storageClassName: directpv | |
EOF | |
# Create a Pod to run the fio benchmark on Rancher Local Path Provisioner | |
cat <<EOF | kubectl apply -f - | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: fio-local-path | |
namespace: storage-benchmark | |
spec: | |
containers: | |
- name: fio | |
image: alpine:3.12 | |
command: ["sh", "-c", "apk add --no-cache fio && fio --name=randwrite --ioengine=libaio --rw=randwrite --bs=4k --direct=1 --size=1G --numjobs=4 --runtime=60 --group_reporting"] | |
volumeMounts: | |
- mountPath: /data | |
name: local-path-storage | |
volumes: | |
- name: local-path-storage | |
persistentVolumeClaim: | |
claimName: local-path-pvc | |
EOF | |
# Create a Pod to run the fio benchmark on DirectPV | |
cat <<EOF | kubectl apply -f - | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: fio-directpv | |
namespace: storage-benchmark | |
spec: | |
containers: | |
- name: fio | |
image: alpine:3.12 | |
command: ["sh", "-c", "apk add --no-cache fio && fio --name=randwrite --ioengine=libaio --rw=randwrite --bs=4k --direct=1 --size=1G --numjobs=4 --runtime=60 --group_reporting"] | |
volumeMounts: | |
- mountPath: /data | |
name: directpv-storage | |
volumes: | |
- name: directpv-storage | |
persistentVolumeClaim: | |
claimName: directpv-pvc | |
EOF | |
# Wait for the benchmark to complete | |
echo "Waiting for benchmarks to complete..." | |
kubectl wait --for=condition=complete --timeout=300s pod/fio-local-path -n storage-benchmark | |
kubectl wait --for=condition=complete --timeout=300s pod/fio-directpv -n storage-benchmark | |
# Retrieve the results | |
echo "Benchmark results for Rancher Local Path Provisioner:" | |
kubectl logs pod/fio-local-path -n storage-benchmark | |
echo "Benchmark results for DirectPV:" | |
kubectl logs pod/fio-directpv -n storage-benchmark | |
# Clean up | |
kubectl delete namespace storage-benchmark |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment