Skip to content

Instantly share code, notes, and snippets.

@alexcpn
Created September 9, 2019 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexcpn/b0d4f41671f94708e1535ac7db697dfe to your computer and use it in GitHub Desktop.
Save alexcpn/b0d4f41671f94708e1535ac7db697dfe to your computer and use it in GitHub Desktop.
Cloned rook ceph gist with small change
#!/bin/bash
# Generically install rook and test it out
: ${ROOK_BRANCH:=release-1.1}
TICK_CHAR='>'
mark_done () {
file_done=$1
date '+%s' > $file_done
echo 'done' >> $file_done
}
w8_4_pvc () {
pvc_claim_2_wait_for=$1
echo "Now we will wait on $pvc_claim_2_wait_for to be bound"
sync
sleep 5
# while loop
countone=1
tick_rate=4
# max time on katacoda is 4 hours, let's call it off a little before that
let max_time=14000/tick_rate
while [ $countone -lt $max_time ]
do
echo -n "$TICK_CHAR"
RESULT=$(kubectl get pvc | grep $pvc_claim_2_wait_for | grep Bound)
if [ "$RESULT" ]; then
echo "$TICK_CHAR"
echo "received = $RESULT"
let so_many=countone*tick_rate
echo "After $so_many seconds"
break
fi
countone=`expr $countone + 1`
sleep $tick_rate
done
sync
sleep $tick_rate
kubectl describe pvc ${1}
mark_done "/tmp/pvc_claim-${1}"
kubectl get pvc
}
w8_4_pod () {
echo "Wait on the $1 pod in the $2 namespace to be up and Running"
# while loop
countone=1
# timeout at 15 minutes
while [ $countone -lt 151 ]
do
echo -n "$TICK_CHAR"
RESULT=$(kubectl get po --namespace=$2 | grep $1 | grep Running)
if [ "$RESULT" ]; then
echo "$TICK_CHAR"
echo "$RESULT"
break
fi
countone=`expr $countone + 1`
sleep 3
done
mark_done "/tmp/${2}-${1}"
}
rk_clone () {
git clone https://github.com/rook/rook.git
git checkout remotes/origin/$ROOK_BRANCH
mark_done "/tmp/rk_clone"
}
rk_step1 () {
cd rook/cluster/examples/kubernetes/ceph/
kubectl create -f common.yaml
kubectl create -f operator.yaml
w8_4_pod rook-ceph-operator rook-ceph
w8_4_pod rook-discover rook-ceph
kubectl create -f cluster-test.yaml
kubectl create -f pool-test.yaml
kubectl create -f toolbox.yaml
kubectl create -f filesystem-test.yaml
kubectl create -f object-test.yaml
kubectl create -f object-user.yaml
cd -
cd rook/cluster/examples/kubernetes/
# Use apply instead of create on this resource as replicapool already exists
kubectl apply -f ceph/csi/rbd/storageclass.yaml
w8_4_pod csi-cephfsplugin-provisioner rook-ceph
w8_4_pod csi-rbdplugin-provisioner rook-ceph
w8_4_pod rook-ceph-agent rook-ceph
w8_4_pod rook-ceph-tools rook-ceph
w8_4_pod rook-ceph-osd rook-ceph
w8_4_pod rook-ceph-mon rook-ceph
w8_4_pod rook-ceph-mgr rook-ceph
w8_4_pod rook-ceph-mds rook-ceph
mark_done "/tmp/rk_step1"
}
rk_step2 () {
sync
sleep 3
cd -
cd rook/cluster/examples/kubernetes/
kubectl create -f mysql.yaml
w8_4_pvc mysql-pvc-claim
kubectl create -f wordpress.yaml
w8_4_pvc wp-pv-claim
kubectl get pods
kubectl get pvc
mark_done "/tmp/rk_step2"
}
main () {
rk_clone
rk_step1
rk_step2
}
time main $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment