11#! /usr/bin/env bash
22
3- set -eEuo pipefail
3+ set -xeEo pipefail
44
5+ # ############
6+ # VARIABLES #
7+ # ############
58: " ${FUNCTION:= ${1} } "
9+ : " ${BLOCK:= $(sudo lsblk --paths | awk ' /14G/ {print $1}' | head -1)} "
610
711# source https://krew.sigs.k8s.io/docs/user-guide/setup/install/
812install_krew () {
@@ -19,19 +23,21 @@ install_krew() {
1923
2024# source https://github.com/rook/rook
2125use_local_disk () {
26+ BLOCK_DATA_PART=${BLOCK} 1
27+ sudo apt purge snapd -y
28+ sudo dmsetup version || true
2229 sudo swapoff --all --verbose
2330 sudo umount /mnt
2431 # search for the device since it keeps changing between sda and sdb
25- sudo wipefs --all --force /dev/" $( lsblk | awk ' /14G/ {print $1}' | head -1) " 1
26- sudo lsblk
32+ sudo wipefs --all --force " $BLOCK_DATA_PART "
2733}
2834
2935deploy_rook () {
3036 kubectl create -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/common.yaml
3137 kubectl create -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/crds.yaml
3238 kubectl create -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/operator.yaml
3339 curl https://raw.githubusercontent.com/rook/rook/master/deploy/examples/cluster-test.yaml -o cluster-test.yaml
34- sed -i " s|#deviceFilter:|deviceFilter: $( lsblk | awk ' /14G/ {print $1} ' | head -1 ) |g" cluster-test.yaml
40+ sed -i " s|#deviceFilter:|deviceFilter: ${BLOCK / \/ dev \/ / } |g" cluster-test.yaml
3541 sed -i ' 0,/count: 1/ s/count: 1/count: 3/' cluster-test.yaml
3642 kubectl create -f cluster-test.yaml
3743 wait_for_pod_to_be_ready_state_default
@@ -53,7 +59,7 @@ deploy_rook_in_custom_namespace() {
5359 curl -f https://raw.githubusercontent.com/rook/rook/master/deploy/examples/operator.yaml -o operator.yaml
5460 deploy_with_custom_ns " $1 " " $2 " operator.yaml
5561 curl https://raw.githubusercontent.com/rook/rook/master/deploy/examples/cluster-test.yaml -o cluster-test.yaml
56- sed -i " s|#deviceFilter:|deviceFilter: $( lsblk | awk ' /14G/ {print $1} ' | head -1 ) |g" cluster-test.yaml
62+ sed -i " s|#deviceFilter:|deviceFilter: ${BLOCK / \/ dev \/ / } |g" cluster-test.yaml
5763 sed -i ' 0,/count: 1/ s/count: 1/count: 3/' cluster-test.yaml
5864 deploy_with_custom_ns " $1 " " $2 " cluster-test.yaml
5965 wait_for_pod_to_be_ready_state_custom
0 commit comments