@@ -21,9 +21,9 @@ function get_default_storageclass() {
21
21
function ensure_default_sc_allows_expansion() {
22
22
local default_sc=$( get_default_storageclass)
23
23
24
- echo " Checking if default storageclass ${default_sc} allows volume expansion"
24
+ echo " Checking if default storageclass ${default_sc} allows volume expansion"
25
25
26
- local allowVolumeExpansion=$( kubectl_bin get sc -o jsonpath=' {.items[?(@.metadata.name=="' " ${default_sc} " ' ")].allowVolumeExpansion}' )
26
+ local allowVolumeExpansion=$( kubectl_bin get sc -o jsonpath=' {.items[?(@.metadata.name=="' " ${default_sc} " ' ")].allowVolumeExpansion}' )
27
27
28
28
if [[ ${allowVolumeExpansion} != " true" ]]; then
29
29
echo " Default storageclass ${default_sc} does not allow volume expansion"
@@ -32,15 +32,15 @@ function ensure_default_sc_allows_expansion() {
32
32
}
33
33
34
34
function apply_resourcequota() {
35
- local quota=$1
36
- local default_sc=$( get_default_storageclass)
35
+ local quota=$1
36
+ local default_sc=$( get_default_storageclass)
37
37
38
- echo " Applying resourcequota for default storageclass ${default_sc} with quota ${quota} "
38
+ echo " Applying resourcequota for default storageclass ${default_sc} with quota ${quota} "
39
39
40
- cat ${test_dir} /conf/resourcequota.yml \
41
- | sed " s/STORAGECLASS/${default_sc} /" \
42
- | sed " s/QUOTA/${quota} /" \
43
- | kubectl_bin apply -f -
40
+ cat ${test_dir} /conf/resourcequota.yml |
41
+ sed " s/STORAGECLASS/${default_sc} /" |
42
+ sed " s/QUOTA/${quota} /" |
43
+ kubectl_bin apply -f -
44
44
}
45
45
46
46
function wait_cluster_status() {
@@ -66,41 +66,59 @@ function wait_cluster_status() {
66
66
67
67
set_debug
68
68
69
- ensure_default_sc_allows_expansion
69
+ if [ " $EKS " == 1 ]; then
70
+ echo " EKS environment detected, creating storageclass for EBS volumes"
71
+ kubectl_bin apply -f ${test_dir} /conf/eks-storageclass.yml
72
+ else
73
+ ensure_default_sc_allows_expansion
74
+ fi
70
75
71
76
create_infra ${namespace}
72
77
73
78
desc ' create secrets and psmdb client'
74
79
kubectl_bin apply \
75
- -f $conf_dir /secrets.yml \
76
- -f $conf_dir /client.yml
80
+ -f $conf_dir /secrets.yml \
81
+ -f $conf_dir /client.yml
77
82
78
83
desc ' create PSMDB cluster'
79
84
cluster=" some-name"
80
- spinup_psmdb " ${cluster} -rs0" " $conf_dir / $cluster -rs0 .yml"
85
+ spinup_psmdb " ${cluster} -rs0" " $test_dir /conf/ $cluster .yml"
81
86
82
87
patch_pvc_request " ${cluster} " " 2Gi"
83
88
wait_cluster_consistency " $cluster " 3 2
84
89
echo
85
90
86
91
for pvc in $( kubectl_bin get pvc -l app.kubernetes.io/component=mongod -o name) ; do
87
- retry=0
88
- echo -n " Waiting for pvc/${pvc} to be resized"
89
- until [[ $( kubectl_bin get ${pvc} -o jsonpath={.status.capacity.storage}) == " 2Gi" ]]; do
90
- if [[ $retry -ge 60 ]]; then
91
- echo
92
- echo " pvc/${pvc} was not resized, max retries exceeded"
93
- exit 1
94
- fi
95
- echo -n " ."
96
- sleep 5
97
-
98
- retry=$(( retry + 1 ))
99
- done
100
- echo
101
- echo " pvc/${pvc} was resized"
92
+ retry=0
93
+ echo -n " Waiting for pvc/${pvc} to be resized"
94
+ until [[ $( kubectl_bin get ${pvc} -o jsonpath={.status.capacity.storage}) == " 2Gi" ]]; do
95
+ if [[ $retry -ge 60 ]]; then
96
+ echo
97
+ echo " pvc/${pvc} was not resized, max retries exceeded"
98
+ exit 1
99
+ fi
100
+ echo -n " ."
101
+ sleep 5
102
+
103
+ retry=$(( retry + 1 ))
104
+ done
105
+ echo
106
+ echo " pvc/${pvc} was resized"
102
107
done
103
108
109
+ if [[ " $EKS " == 1 || -n ${OPENSHIFT} ]]; then
110
+ # AWS rate limits PVC expansion for the same EBS volume (1 expand operation in every 6 hours),
111
+ # so we need to delete and recreate the cluster
112
+ echo " Deleting and recreating PSMDB cluster ${cluster} "
113
+ kubectl_bin delete psmdb ${cluster}
114
+ kubectl_bin apply -f $conf_dir /secrets.yml
115
+ if [ " $EKS " == 1 ]; then
116
+ spinup_psmdb " ${cluster} -rs0" " $test_dir /conf/$cluster -eks.yml"
117
+ else
118
+ spinup_psmdb " ${cluster} -rs0" " $test_dir /conf/$cluster .yml"
119
+ fi
120
+ fi
121
+
104
122
desc ' create resourcequota'
105
123
106
124
# We're setting the quota to 7Gi, so we can only resize the first PVC to 3Gi
@@ -134,21 +152,21 @@ patch_pvc_request "${cluster}" "3Gi"
134
152
wait_cluster_consistency " $cluster " 3 2
135
153
echo
136
154
for pvc in $( kubectl_bin get pvc -l app.kubernetes.io/component=mongod -o name) ; do
137
- retry=0
138
- echo -n " Waiting for pvc/${pvc} to be resized"
139
- until [[ $( kubectl_bin get ${pvc} -o jsonpath={.status.capacity.storage}) == " 3Gi" ]]; do
140
- if [[ $retry -ge 60 ]]; then
141
- echo
142
- echo " pvc/${pvc} was not resized, max retries exceeded"
143
- exit 1
144
- fi
145
- echo -n " ."
146
- sleep 5
147
-
148
- retry=$(( retry + 1 ))
149
- done
150
- echo
151
- echo " pvc/${pvc} was resized"
155
+ retry=0
156
+ echo -n " Waiting for pvc/${pvc} to be resized"
157
+ until [[ $( kubectl_bin get ${pvc} -o jsonpath={.status.capacity.storage}) == " 3Gi" ]]; do
158
+ if [[ $retry -ge 60 ]]; then
159
+ echo
160
+ echo " pvc/${pvc} was not resized, max retries exceeded"
161
+ exit 1
162
+ fi
163
+ echo -n " ."
164
+ sleep 5
165
+
166
+ retry=$(( retry + 1 ))
167
+ done
168
+ echo
169
+ echo " pvc/${pvc} was resized"
152
170
done
153
171
154
172
desc " test downscale"
0 commit comments