@@ -5,40 +5,40 @@ ROOK_DEPLOY_TIMEOUT=${ROOK_DEPLOY_TIMEOUT:-300}
5
5
ROOK_URL=" https://raw.githubusercontent.com/rook/rook/${ROOK_VERSION} /cluster/examples/kubernetes/ceph"
6
6
7
7
function deploy_rook() {
8
- kubectl create -f " ${ROOK_URL} /common.yaml"
9
- kubectl create -f " ${ROOK_URL} /operator.yaml"
10
- kubectl create -f " ${ROOK_URL} /cluster-test.yaml"
11
- kubectl create -f " ${ROOK_URL} /toolbox.yaml"
12
- kubectl create -f " ${ROOK_URL} /filesystem-test.yaml"
13
- kubectl create -f " ${ROOK_URL} /pool-test.yaml"
8
+ kubectl create -f " ${ROOK_URL} /common.yaml"
9
+ kubectl create -f " ${ROOK_URL} /operator.yaml"
10
+ kubectl create -f " ${ROOK_URL} /cluster-test.yaml"
11
+ kubectl create -f " ${ROOK_URL} /toolbox.yaml"
12
+ kubectl create -f " ${ROOK_URL} /filesystem-test.yaml"
13
+ kubectl create -f " ${ROOK_URL} /pool-test.yaml"
14
14
15
15
# Check if CephCluster is empty
16
- if ! kubectl -n rook-ceph get cephclusters -oyaml | grep ' items: \[\]' & > /dev/null; then
16
+ if ! kubectl -n rook-ceph get cephclusters -oyaml | grep ' items: \[\]' & > /dev/null; then
17
17
check_ceph_cluster_health
18
18
fi
19
19
20
20
# Check if CephFileSystem is empty
21
- if ! kubectl -n rook-ceph get cephfilesystems -oyaml | grep ' items: \[\]' & > /dev/null; then
21
+ if ! kubectl -n rook-ceph get cephfilesystems -oyaml | grep ' items: \[\]' & > /dev/null; then
22
22
check_mds_stat
23
23
fi
24
24
25
25
# Check if CephBlockPool is empty
26
- if ! kubectl -n rook-ceph get cephblockpools -oyaml | grep ' items: \[\]' & > /dev/null; then
26
+ if ! kubectl -n rook-ceph get cephblockpools -oyaml | grep ' items: \[\]' & > /dev/null; then
27
27
check_rbd_stat
28
28
fi
29
29
}
30
30
31
31
function teardown_rook() {
32
- kubectl delete -f " ${ROOK_URL} /pool-test.yaml"
33
- kubectl delete -f " ${ROOK_URL} /filesystem-test.yaml"
34
- kubectl delete -f " ${ROOK_URL} /toolbox.yaml"
35
- kubectl delete -f " ${ROOK_URL} /cluster-test.yaml"
36
- kubectl delete -f " ${ROOK_URL} /operator.yaml"
37
- kubectl delete -f " ${ROOK_URL} /common.yaml"
32
+ kubectl delete -f " ${ROOK_URL} /pool-test.yaml"
33
+ kubectl delete -f " ${ROOK_URL} /filesystem-test.yaml"
34
+ kubectl delete -f " ${ROOK_URL} /toolbox.yaml"
35
+ kubectl delete -f " ${ROOK_URL} /cluster-test.yaml"
36
+ kubectl delete -f " ${ROOK_URL} /operator.yaml"
37
+ kubectl delete -f " ${ROOK_URL} /common.yaml"
38
38
}
39
39
40
- function check_ceph_cluster_health(){
41
- for (( retry= 0 ; retry<= ROOK_DEPLOY_TIMEOUT; retry= retry+ 5 )) ; do
40
+ function check_ceph_cluster_health() {
41
+ for (( retry = 0 ; retry <= ROOK_DEPLOY_TIMEOUT; retry = retry + 5 )) ; do
42
42
echo " Wait for rook deploy... ${retry} s" && sleep 5
43
43
44
44
CEPH_STATE=$( kubectl -n rook-ceph get cephclusters -o jsonpath=' {.items[0].status.state}' )
@@ -47,36 +47,36 @@ function check_ceph_cluster_health(){
47
47
if [ " $CEPH_STATE " = " Created" ]; then
48
48
if [ " $CEPH_HEALTH " = " HEALTH_OK" ]; then
49
49
echo " Creating CEPH cluster is done. [$CEPH_HEALTH ]"
50
- break ;
50
+ break
51
51
fi
52
52
fi
53
53
done
54
54
echo " "
55
55
}
56
56
57
- function check_mds_stat(){
58
- for (( retry= 0 ; retry<= ROOK_DEPLOY_TIMEOUT; retry= retry+ 5 )) ; do
57
+ function check_mds_stat() {
58
+ for (( retry = 0 ; retry <= ROOK_DEPLOY_TIMEOUT; retry = retry + 5 )) ; do
59
59
FS_NAME=$( kubectl -n rook-ceph get cephfilesystems.ceph.rook.io -ojsonpath=' {.items[0].metadata.name}' )
60
60
echo " Checking MDS ($FS_NAME ) stats... ${retry} s" && sleep 5
61
61
62
62
ACTIVE_COUNT=$( kubectl -n rook-ceph get cephfilesystems myfs -ojsonpath=' {.spec.metadataServer.activeCount}' )
63
63
64
64
ACTIVE_COUNT_NUM=$(( ACTIVE_COUNT + 0 ))
65
65
echo " MDS ($FS_NAME ) active_count: [$ACTIVE_COUNT_NUM ]"
66
- if (( ACTIVE_COUNT_NUM < 1 )) ; then
67
- continue ;
66
+ if (( ACTIVE_COUNT_NUM < 1 )) ; then
67
+ continue
68
68
else
69
- if kubectl -n rook-ceph get pod -l rook_file_system=myfs | grep Running & > /dev/null; then
69
+ if kubectl -n rook-ceph get pod -l rook_file_system=myfs | grep Running & > /dev/null; then
70
70
echo " Filesystem ($FS_NAME ) is successfully created..."
71
- break ;
71
+ break
72
72
fi
73
73
fi
74
74
done
75
75
echo " "
76
76
}
77
77
78
- function check_rbd_stat(){
79
- for (( retry= 0 ; retry<= ROOK_DEPLOY_TIMEOUT; retry= retry+ 5 )) ; do
78
+ function check_rbd_stat() {
79
+ for (( retry = 0 ; retry <= ROOK_DEPLOY_TIMEOUT; retry = retry + 5 )) ; do
80
80
RBD_POOL_NAME=$( kubectl -n rook-ceph get cephblockpools -ojsonpath=' {.items[0].metadata.name}' )
81
81
echo " Checking RBD ($RBD_POOL_NAME ) stats... ${retry} s" && sleep 5
82
82
@@ -85,7 +85,7 @@ function check_rbd_stat(){
85
85
echo " Toolbox POD ($TOOLBOX_POD ) status: [$TOOLBOX_POD_STATUS ]"
86
86
[[ " $TOOLBOX_POD_STATUS " != " Running" ]] && continue
87
87
88
- if kubectl exec -n rook-ceph " $TOOLBOX_POD " -it -- rbd pool stats " $RBD_POOL_NAME " & > /dev/null; then
88
+ if kubectl exec -n rook-ceph " $TOOLBOX_POD " -it -- rbd pool stats " $RBD_POOL_NAME " & > /dev/null; then
89
89
echo " RBD ($RBD_POOL_NAME ) is successfully created..."
90
90
break
91
91
fi
@@ -95,16 +95,16 @@ function check_rbd_stat(){
95
95
96
96
case " ${1:- } " in
97
97
deploy)
98
- deploy_rook
99
- ;;
98
+ deploy_rook
99
+ ;;
100
100
teardown)
101
- teardown_rook
102
- ;;
101
+ teardown_rook
102
+ ;;
103
103
* )
104
- echo " $0 [command]
104
+ echo " $0 [command]
105
105
Available Commands:
106
106
deploy Deploy a rook
107
107
teardown Teardown a rook
108
108
" >&2
109
- ;;
109
+ ;;
110
110
esac
0 commit comments