diff --git a/docs/run_fio.sh b/docs/run_fio.sh deleted file mode 100755 index 0a9db2c..0000000 --- a/docs/run_fio.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash - -# COLOR CONSTANTS -GREEN='\033[0;32m' -LIGHT_BLUE='\033[1;34m' -RED='\033[0;31m' -NC='\033[0m' - -print_heading() { - printf "${LIGHT_BLUE}$1${NC}\n" -} - -print_error(){ - printf "${RED}$1${NC}\n" -} - -print_success(){ - printf "${GREEN}$1${NC}\n" -} - -readonly -a REQUIRED_TOOLS=( - kubectl -) - -DEFAULT_IMAGE_TAG="0.2.0" -DEFAULT_PV_SIZE="100" -DEFAULT_JOB_NAME="kubestr-fio" - -helpFunction() -{ - echo "" - echo "This scripts runs Kubestr FIO tests as a Job in a cluster" - echo "Usage: $0 -i image -n namespace -s storageclass -z sizeInGiB -f fioConfigFile" - echo -e "\t-i The Kubestr FIO image" - echo -e "\t-n The kubernetes namespace where the job will run" - echo -e "\t-s The Storage Class to use when running FIO tests. (Required)" - echo -e "\t-z The Size of the Persistent Volume in GiB. Default: 1000." - echo -e "\t-f An FIO config file" - exit 1 # Exit script after printing help -} - -while getopts "i:n:s:z:f:" opt -do - case "$opt" in - i ) image="$OPTARG" ;; - n ) namespace="$OPTARG" ;; - s ) storageclass="$OPTARG" ;; - z ) size="$OPTARG" ;; - f ) fioconfig="$OPTARG" ;; - ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent - esac -done - -if [ -z "$namespace" ] -then - echo "Namespace option not provided, using default namespace"; - namespace="default" -fi - -if [ -z "$storageclass" ] -then - print_error "The Storage Class option (-s) is required." - helpFunction - exit 1 -fi - -if [ -z "$size" ] -then - echo "Size option not provided, using default size ${DEFAULT_PV_SIZE}Gi" - size=${DEFAULT_PV_SIZE} -fi - -check_tools() { - print_heading "Checking for tools" - for tool in "${REQUIRED_TOOLS[@]}" - do - if ! command -v "${tool}" > /dev/null 2>&1 - then - print_error " --> Unable to find ${tool}" - failed=1 - else - print_success " --> Found ${tool}" - fi - done -} - -check_image() { - print_heading "Kubestr image" - if [ -z "$image" ] - then - # need to change this to public dockerhub - image=ghcr.io/kastenhq/kubestr:${DEFAULT_IMAGE_TAG} - fi - print_success " --> ${image}" -} - - -failed=0 -check_tools && check_image -if [[ ${failed} != 0 ]]; then - print_error "Pre-checks failed" - exit 1 -fi - -print_heading "Running Kubestr FIO Job in ${namespace} namspace" - -cat > kuberstr-fio.yaml << EOF -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: ${DEFAULT_JOB_NAME}-pv-claim - namespace: ${namespace} -spec: - storageClassName: ${storageclass} - accessModes: - - ReadWriteOnce - resources: - requests: - storage: ${size}Gi ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: ${DEFAULT_JOB_NAME} - namespace: ${namespace} -spec: - template: - spec: - containers: - - name: ${DEFAULT_JOB_NAME} - image: ${image} - command: [ "/fio.sh" ] - args: [ "fio" ] - imagePullPolicy: Always - env: - - name: DBENCH_MOUNTPOINT - value: /data - volumeMounts: - - name: ${DEFAULT_JOB_NAME}-pv - mountPath: /data - restartPolicy: Never - volumes: - - name: ${DEFAULT_JOB_NAME}-pv - persistentVolumeClaim: - claimName: ${DEFAULT_JOB_NAME}-pv-claim - backoffLimit: 4 -EOF - -kubectl apply -f kuberstr-fio.yaml - -trap "kubectl delete -f kuberstr-fio.yaml" EXIT - -while [[ $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" && $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} -o 'jsonpath={..phase}') != "Succeeded" ]]; -do echo "Waiting for pod $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} --output=jsonpath='{.items[*].metadata.name}') to be ready - $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} -o 'jsonpath={..status.containerStatuses[0].state.waiting.reason}')" && sleep 1; -done -echo "Pod Ready!" -echo "" -pod=$(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} --output=jsonpath='{.items[*].metadata.name}') -kubectl logs -n ${namespace} ${pod} -f -echo "" diff --git a/docs/run_fio2.sh b/docs/run_fio2.sh deleted file mode 100755 index ba2b921..0000000 --- a/docs/run_fio2.sh +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env bash - -# COLOR CONSTANTS -GREEN='\033[0;32m' -LIGHT_BLUE='\033[1;34m' -RED='\033[0;31m' -NC='\033[0m' - -readonly -a REQUIRED_TOOLS=( - kubectl -) - -DEFAULT_IMAGE_TAG="latest" -DEFAULT_JOB_NAME="kubestr" - -helpFunction() -{ - echo "" - echo "This scripts runs Kubestr as a Job in a cluster" - echo "Usage: $0 -i image -n namespace" - echo -e "\t-i The Kubestr image" - echo -e "\t-n The kubernetes namespace where the job will run" - echo -e "\t-s The storageclass to run the fio test against" - echo -e "\t-z The size of volume to run the fio test against" - echo -e "\t-f An FIO file to run the fio test against" - exit 1 # Exit script after printing help -} - -while getopts "i:n:s:z:f:" opt -do - case "$opt" in - i ) image="$OPTARG" ;; - n ) namespace="$OPTARG" ;; - s ) storageclass="$OPTARG" ;; - z ) size="$OPTARG" ;; - f ) file="$OPTARG" ;; - ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent - esac -done - -if [ -z "$namespace" ] -then - echo "Namespace option not provided, using default namespace"; - namespace="default" -fi - -if [ -z "$storageclass" ] -then - echo "storageclass is needed" - exit 1 -fi - -print_heading() { - printf "${LIGHT_BLUE}$1${NC}\n" -} - -print_error(){ - printf "${RED}$1${NC}\n" -} - -print_success(){ - printf "${GREEN}$1${NC}\n" -} - -check_tools() { - print_heading "Checking for tools" - for tool in "${REQUIRED_TOOLS[@]}" - do - if ! command -v "${tool}" > /dev/null 2>&1 - then - print_error " --> Unable to find ${tool}" - failed=1 - else - print_success " --> Found ${tool}" - fi - done -} - -check_kubectl_access() { - print_heading "Checking access to the Kubernetes context $(kubectl config current-context)" - if [[ $(kubectl get ns ${namespace}) ]]; then - print_success " --> Able to access the ${namespace} Kubernetes namespace" - else - print_error " --> Unable to access the ${namespace} Kubernetes namespace" - failed=1 - fi -} - -check_image() { - print_heading "Kubestr image" - if [ -z "$image" ] - then - # need to change this to public dockerhub - image=ghcr.io/kastenhq/kubestr:${DEFAULT_IMAGE_TAG} - fi - print_success " --> ${image}" -} - -failed=0 -check_tools && check_image && check_kubectl_access -if [[ ${failed} != 0 ]]; then - print_error "Pre-checks failed" - exit 1 -fi - -additional_cm_cmd="" -if [ -n "$file" ] -then - additional_cm_cmd="${additional_cm_cmd} --from-file=${file}" -fi - -if [ -n "$size" ] -then - additional_cm_cmd="${additional_cm_cmd} --from-literal=pvcsize=${size}" -fi - -if [ -n "$storageclass" ] -then - additional_cm_cmd="${additional_cm_cmd} --from-literal=storageclass=${storageclass}" -fi - - -kubectl create configmap --namespace ${namespace} fio-config ${additional_cm_cmd} -kubectl label configmap --namespace ${namespace} fio-config createdbyfio=true - -printf "\n" -print_heading "Running Kubestr Job in ${namespace} namspace" -cat > kubestr.yaml << EOF -apiVersion: v1 -kind: ServiceAccount -metadata: - name: ${DEFAULT_JOB_NAME} - namespace: ${namespace} ---- -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: ${DEFAULT_JOB_NAME} -subjects: - - kind: ServiceAccount - name: ${DEFAULT_JOB_NAME} - namespace: ${namespace} -roleRef: - kind: ClusterRole - name: cluster-admin - apiGroup: rbac.authorization.k8s.io ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: ${DEFAULT_JOB_NAME} - namespace: ${namespace} -spec: - template: - spec: - containers: - - image: ${image} - imagePullPolicy: Always - name: ${DEFAULT_JOB_NAME} - command: [ "/kubestr" ] - args: ["fio", "-c", "fio-config"] - env: - - name: POD_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - restartPolicy: Never - serviceAccount: ${DEFAULT_JOB_NAME} - backoffLimit: 4 -EOF - -kubectl apply -f kubestr.yaml - -trap "kubectl delete -f kubestr.yaml" EXIT - -while [[ $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" && $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} -o 'jsonpath={..phase}') != "Succeeded" ]]; -do echo "Waiting for pod $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} --output=jsonpath='{.items[*].metadata.name}') to be ready - $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} -o 'jsonpath={..status.containerStatuses[0].state.waiting.reason}')" && sleep 1; -done -echo "Pod Ready!" -echo "" -pod=$(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} --output=jsonpath='{.items[*].metadata.name}') -kubectl logs -n ${namespace} ${pod} -f -echo "" diff --git a/docs/run_kubestr.sh b/docs/run_kubestr.sh deleted file mode 100755 index d05c9d3..0000000 --- a/docs/run_kubestr.sh +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env bash - -# COLOR CONSTANTS -GREEN='\033[0;32m' -LIGHT_BLUE='\033[1;34m' -RED='\033[0;31m' -NC='\033[0m' - -readonly -a REQUIRED_TOOLS=( - kubectl -) - -DEFAULT_IMAGE_TAG="latest" -DEFAULT_JOB_NAME="kubestr" - -helpFunction() -{ - echo "" - echo "This scripts runs Kubestr as a Job in a cluster" - echo "Usage: $0 -i image -n namespace" - echo -e "\t-i The Kubestr image" - echo -e "\t-n The kubernetes namespace where the job will run" - exit 1 # Exit script after printing help -} - -while getopts "i:n:" opt -do - case "$opt" in - i ) image="$OPTARG" ;; - n ) namespace="$OPTARG" ;; - ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent - esac -done - -if [ -z "$namespace" ] -then - echo "Namespace option not provided, using default namespace"; - namespace="default" -fi - -print_heading() { - printf "${LIGHT_BLUE}$1${NC}\n" -} - -print_error(){ - printf "${RED}$1${NC}\n" -} - -print_success(){ - printf "${GREEN}$1${NC}\n" -} - -check_tools() { - print_heading "Checking for tools" - for tool in "${REQUIRED_TOOLS[@]}" - do - if ! command -v "${tool}" > /dev/null 2>&1 - then - print_error " --> Unable to find ${tool}" - failed=1 - else - print_success " --> Found ${tool}" - fi - done -} - -check_kubectl_access() { - print_heading "Checking access to the Kubernetes context $(kubectl config current-context)" - if [[ $(kubectl get ns ${namespace}) ]]; then - print_success " --> Able to access the ${namespace} Kubernetes namespace" - else - print_error " --> Unable to access the ${namespace} Kubernetes namespace" - failed=1 - fi -} - -check_image() { - print_heading "Kubestr image" - if [ -z "$image" ] - then - # need to change this to public dockerhub - image=ghcr.io/kastenhq/kubestr:${DEFAULT_IMAGE_TAG} - fi - print_success " --> ${image}" -} - -failed=0 -check_tools && check_image && check_kubectl_access -if [[ ${failed} != 0 ]]; then - print_error "Pre-checks failed" - exit 1 -fi - -printf "\n" -print_heading "Running Kubestr Job in ${namespace} namspace" -cat > kubestr.yaml << EOF -apiVersion: v1 -kind: ServiceAccount -metadata: - name: ${DEFAULT_JOB_NAME} - namespace: ${namespace} ---- -kind: ClusterRoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: ${DEFAULT_JOB_NAME} -subjects: - - kind: ServiceAccount - name: ${DEFAULT_JOB_NAME} - namespace: ${namespace} -roleRef: - kind: ClusterRole - name: cluster-admin - apiGroup: rbac.authorization.k8s.io ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: ${DEFAULT_JOB_NAME} - namespace: ${namespace} -spec: - template: - spec: - containers: - - image: ${image} - imagePullPolicy: Always - name: ${DEFAULT_JOB_NAME} - command: [ "/kubestr" ] - env: - - name: POD_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - restartPolicy: Never - serviceAccount: ${DEFAULT_JOB_NAME} - backoffLimit: 4 -EOF - -kubectl apply -f kubestr.yaml - -trap "kubectl delete -f kubestr.yaml" EXIT - -while [[ $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" && $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} -o 'jsonpath={..phase}') != "Succeeded" ]]; -do echo "Waiting for pod $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} --output=jsonpath='{.items[*].metadata.name}') to be ready - $(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} -o 'jsonpath={..status.containerStatuses[0].state.waiting.reason}')" && sleep 1; -done -echo "Pod Ready!" -echo "" -pod=$(kubectl -n ${namespace} get pods --selector=job-name=${DEFAULT_JOB_NAME} --output=jsonpath='{.items[*].metadata.name}') -kubectl logs -n ${namespace} ${pod} -f -echo "" diff --git a/pkg/fio/fio.sh b/pkg/fio/fio.sh deleted file mode 100644 index 65cc5c1..0000000 --- a/pkg/fio/fio.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env sh -set -e - -if [ -z $DBENCH_MOUNTPOINT ]; then - DBENCH_MOUNTPOINT=/tmp -fi - -if [ -z $FIO_SIZE ]; then - FIO_SIZE=2G -fi - -if [ -z $FIO_OFFSET_INCREMENT ]; then - FIO_OFFSET_INCREMENT=500M -fi - -if [ -z $FIO_DIRECT ]; then - FIO_DIRECT=1 -fi - -echo Working dir: $DBENCH_MOUNTPOINT -echo - -if [ "$1" = 'fio' ]; then - - echo Testing Read IOPS... - READ_IOPS=$(fio --randrepeat=0 --verify=0 --ioengine=libaio --direct=$FIO_DIRECT --gtod_reduce=1 --name=read_iops --filename=$DBENCH_MOUNTPOINT/fiotest --bs=4K --iodepth=64 --size=$FIO_SIZE --readwrite=randread --time_based --ramp_time=2s --runtime=15s) - echo "$READ_IOPS" - READ_IOPS_VAL=$(echo "$READ_IOPS"|grep -E 'read ?:'|grep -Eoi 'IOPS=[0-9k.]+'|cut -d'=' -f2) - echo - echo - - echo Testing Write IOPS... - WRITE_IOPS=$(fio --randrepeat=0 --verify=0 --ioengine=libaio --direct=$FIO_DIRECT --gtod_reduce=1 --name=write_iops --filename=$DBENCH_MOUNTPOINT/fiotest --bs=4K --iodepth=64 --size=$FIO_SIZE --readwrite=randwrite --time_based --ramp_time=2s --runtime=15s) - echo "$WRITE_IOPS" - WRITE_IOPS_VAL=$(echo "$WRITE_IOPS"|grep -E 'write:'|grep -Eoi 'IOPS=[0-9k.]+'|cut -d'=' -f2) - echo - echo - - echo Testing Read Bandwidth... - READ_BW=$(fio --randrepeat=0 --verify=0 --ioengine=libaio --direct=$FIO_DIRECT --gtod_reduce=1 --name=read_bw --filename=$DBENCH_MOUNTPOINT/fiotest --bs=128K --iodepth=64 --size=$FIO_SIZE --readwrite=randread --time_based --ramp_time=2s --runtime=15s) - echo "$READ_BW" - READ_BW_VAL=$(echo "$READ_BW"|grep -E 'read ?:'|grep -Eoi 'BW=[0-9GMKiBs/.]+'|cut -d'=' -f2) - echo - echo - - echo Testing Write Bandwidth... - WRITE_BW=$(fio --randrepeat=0 --verify=0 --ioengine=libaio --direct=$FIO_DIRECT --gtod_reduce=1 --name=write_bw --filename=$DBENCH_MOUNTPOINT/fiotest --bs=128K --iodepth=64 --size=$FIO_SIZE --readwrite=randwrite --time_based --ramp_time=2s --runtime=15s) - echo "$WRITE_BW" - WRITE_BW_VAL=$(echo "$WRITE_BW"|grep -E 'write:'|grep -Eoi 'BW=[0-9GMKiBs/.]+'|cut -d'=' -f2) - echo - echo - - if [ "$DBENCH_QUICK" == "" ] || [ "$DBENCH_QUICK" == "no" ]; then - echo Testing Read Latency... - READ_LATENCY=$(fio --randrepeat=0 --verify=0 --ioengine=libaio --direct=$FIO_DIRECT --name=read_latency --filename=$DBENCH_MOUNTPOINT/fiotest --bs=4K --iodepth=4 --size=$FIO_SIZE --readwrite=randread --time_based --ramp_time=2s --runtime=15s) - echo "$READ_LATENCY" - READ_LATENCY_VAL=$(echo "$READ_LATENCY"|grep ' lat.*avg'|grep -Eoi 'avg=[0-9.]+'|cut -d'=' -f2) - echo - echo - - echo Testing Write Latency... - WRITE_LATENCY=$(fio --randrepeat=0 --verify=0 --ioengine=libaio --direct=$FIO_DIRECT --name=write_latency --filename=$DBENCH_MOUNTPOINT/fiotest --bs=4K --iodepth=4 --size=$FIO_SIZE --readwrite=randwrite --time_based --ramp_time=2s --runtime=15s) - echo "$WRITE_LATENCY" - WRITE_LATENCY_VAL=$(echo "$WRITE_LATENCY"|grep ' lat.*avg'|grep -Eoi 'avg=[0-9.]+'|cut -d'=' -f2) - echo - echo - - echo Testing Read Sequential Speed... - READ_SEQ=$(fio --randrepeat=0 --verify=0 --ioengine=libaio --direct=$FIO_DIRECT --gtod_reduce=1 --name=read_seq --filename=$DBENCH_MOUNTPOINT/fiotest --bs=1M --iodepth=16 --size=$FIO_SIZE --readwrite=read --time_based --ramp_time=2s --runtime=15s --thread --numjobs=4 --offset_increment=$FIO_OFFSET_INCREMENT) - echo "$READ_SEQ" - READ_SEQ_VAL=$(echo "$READ_SEQ"|grep -E 'READ:'|grep -Eoi '(aggrb|bw)=[0-9GMKiBs/.]+'|cut -d'=' -f2) - echo - echo - - echo Testing Write Sequential Speed... - WRITE_SEQ=$(fio --randrepeat=0 --verify=0 --ioengine=libaio --direct=$FIO_DIRECT --gtod_reduce=1 --name=write_seq --filename=$DBENCH_MOUNTPOINT/fiotest --bs=1M --iodepth=16 --size=$FIO_SIZE --readwrite=write --time_based --ramp_time=2s --runtime=15s --thread --numjobs=4 --offset_increment=$FIO_OFFSET_INCREMENT) - echo "$WRITE_SEQ" - WRITE_SEQ_VAL=$(echo "$WRITE_SEQ"|grep -E 'WRITE:'|grep -Eoi '(aggrb|bw)=[0-9GMKiBs/.]+'|cut -d'=' -f2) - echo - echo - - echo Testing Read/Write Mixed... - RW_MIX=$(fio --randrepeat=0 --verify=0 --ioengine=libaio --direct=$FIO_DIRECT --gtod_reduce=1 --name=rw_mix --filename=$DBENCH_MOUNTPOINT/fiotest --bs=4k --iodepth=64 --size=$FIO_SIZE --readwrite=randrw --rwmixread=75 --time_based --ramp_time=2s --runtime=15s) - echo "$RW_MIX" - RW_MIX_R_IOPS=$(echo "$RW_MIX"|grep -E 'read ?:'|grep -Eoi 'IOPS=[0-9k.]+'|cut -d'=' -f2) - RW_MIX_W_IOPS=$(echo "$RW_MIX"|grep -E 'write:'|grep -Eoi 'IOPS=[0-9k.]+'|cut -d'=' -f2) - echo - echo - fi - - echo All tests complete. - echo - echo ================== - echo = Dbench Summary = - echo ================== - echo "Random Read/Write IOPS: $READ_IOPS_VAL/$WRITE_IOPS_VAL. BW: $READ_BW_VAL / $WRITE_BW_VAL" - if [ -z $DBENCH_QUICK ] || [ "$DBENCH_QUICK" == "no" ]; then - echo "Average Latency (usec) Read/Write: $READ_LATENCY_VAL/$WRITE_LATENCY_VAL" - echo "Sequential Read/Write: $READ_SEQ_VAL / $WRITE_SEQ_VAL" - echo "Mixed Random Read/Write IOPS: $RW_MIX_R_IOPS/$RW_MIX_W_IOPS" - fi - - rm $DBENCH_MOUNTPOINT/fiotest - exit 0 -fi - -exec "$@"