@@ -43,8 +43,9 @@ resize() {
43
43
local CLUSTER_TYPE=$1
44
44
local CLUSTER_NAME=$2
45
45
local NAMESPACE=$3
46
- local INT_NEW_SIZE=$4
47
- local NEW_SIZE_SUFFIX=$5
46
+ local WAIT=$4
47
+ local INT_NEW_SIZE=$5
48
+ local NEW_SIZE_SUFFIX=$6
48
49
49
50
if [ -f " ${CLUSTER_NAME} " -sts.yaml ]; then
50
51
die " ${CLUSTER_NAME} -sts.yaml exist, please delete by running rm -f ${CLUSTER_NAME} -sts.yaml"
@@ -63,14 +64,13 @@ resize() {
63
64
INT_current_capacity=( $( grep -Eo ' ^[0-9]+\.?[0-9]*' <<< " ${current_capacity}" ) )
64
65
INT_current_capacity_suffix=" ${current_capacity# " ${INT_current_capacity} " } "
65
66
current_multiplier=$( get_suffix_multiplier ${INT_current_capacity_suffix} )
66
- RAW_current_size=` bc -l <<< " ${INT_current_capacity} * 1024^ ${current_multiplier}" `
67
+ let RAW_current_size=( ${INT_current_capacity} * 1024** ${current_multiplier} )
67
68
68
- new_mulitplier=$( get_suffix_multiplier ${NEW_SIZE_SUFFIX} )
69
- RAW_new_size=` bc -l <<< " ${INT_NEW_SIZE} * 1024^${new_mulitplier}" `
70
- expand=` bc -l <<< " ${RAW_new_size} > ${RAW_current_size}" `
69
+ new_multiplier=$( get_suffix_multiplier ${NEW_SIZE_SUFFIX} )
70
+ let RAW_new_size=( ${INT_NEW_SIZE} * 1024** ${new_multiplier} )
71
71
72
- if [ ${expand} -eq " 1 " ] ; then
73
- NEW_SIZE= " ${INT_NEW_SIZE}${NEW_SIZE_SUFFIX} "
72
+ NEW_SIZE= " ${INT_NEW_SIZE}${NEW_SIZE_SUFFIX} "
73
+ if [ " ${RAW_new_size} " -gt " ${RAW_current_size} " ] ; then
74
74
echo " ${green} #########################"
75
75
echo " #### PVC: ${PVC} "
76
76
echo " #### Current Size: ${current_capacity} "
@@ -90,15 +90,16 @@ resize() {
90
90
91
91
# Resize can take 2-3 tries 2 mins apart while resizing
92
92
echo " ${green} #### Waiting for PVC resize: ${PVC}${reset} "
93
- kubectl wait --for=condition=FileSystemResizePending pvc/" ${PVC} " -n " ${NAMESPACE} " --timeout=30m
93
+ echo " kubectl wait --for=condition=FileSystemResizePending pvc/" ${PVC} " -n " ${NAMESPACE} " --timeout=" ${WAIT} " m"
94
+ kubectl wait --for=condition=FileSystemResizePending pvc/" ${PVC} " -n " ${NAMESPACE} " --timeout=" ${WAIT} " m
94
95
# Creating the sts puts the pod back and reattached the pvc
95
96
kubectl create -f " ${CLUSTER_NAME} " -sts.yaml -n " ${NAMESPACE} "
96
97
# This wait isn't strictly necessary as the rolling operator on the next \
97
98
# pod in the queue would prevent issues.
98
99
echo " ${green} #### Waiting for Pod to start: ${POD}${reset} "
99
- kubectl wait --for=condition=ready pod/${POD} -n " ${NAMESPACE} " --timeout=30m
100
+ kubectl wait --for=condition=ready pod/${POD} -n " ${NAMESPACE} " --timeout=" ${WAIT} " m
100
101
else
101
- echo " ${green} #### PVC: ${PVC} is already size: ${current_capacity}${reset} . This script is only for disk expansion."
102
+ echo " ${green} #### PVC: ${PVC} is size: ${current_capacity} which is not less than requested new size: ${NEW_SIZE }${reset} . This script is only for disk expansion."
102
103
fi
103
104
done
104
105
@@ -113,12 +114,13 @@ resize() {
113
114
components_types=(kafka ksqldb controlcenter zookeeper)
114
115
valid_suffixes=(" Ki" " Mi" " Gi" " Ti" )
115
116
usage () {
116
- echo " usage: ./pv-resize.sh -c <cluster-name> -t <cluster-type> -n <namespace> -s <size_with_unit>"
117
+ echo " usage: ./pv-resize.sh -c <cluster-name> -t <cluster-type> -n <namespace> -s <size_with_unit> -w <wait_duration_minutes> "
117
118
echo " " ;
118
119
echo " -c | --cluster-name : name of the cluster to resize the PV" ;
119
120
echo " -t | --cluster-type : confluent platform component, supported value: ${components_types[*]} " ;
120
121
echo " -n | --namespace : kubernetes namespace where cluster is running" ;
121
122
echo " -s | --size : new PV size in Ki|Mi|Gi|Ti" ;
123
+ echo " -w | --wait : wait duration for pod to be ready in minutes (default 60 min)" ;
122
124
echo " -h | --help : Usage command" ;
123
125
}
124
126
@@ -130,6 +132,7 @@ parse_args() {
130
132
-c | --name ) name=" ${2} " ; shift ;;
131
133
-n | --namespace ) namespace=" ${2} " ; shift ;;
132
134
-s | --size) size=" ${2} " ; shift ;;
135
+ -w | --wait) wait=" ${2} " ; shift ;;
133
136
-h | --help ) help=" true" ; ;;
134
137
* ) args+=(" $1 " )
135
138
esac
@@ -145,14 +148,15 @@ parse_args() {
145
148
if [[ ! " ${components_types[*]} " =~ ${type} ]]; then die " Please provide cluster type, supported value: ${components_types[*]} " ; fi
146
149
if [[ -z ${namespace} ]]; then usage; die " ==> Please provide namespace where cluster is running" ; fi
147
150
if [[ -z ${size} ]]; then usage; die " ==> Please provide PV size in ${SUFFIXES_STRING} " ; fi
151
+ if [[ -z ${wait} ]]; then wait=60; fi
148
152
149
153
local NEW_SIZE_VALUE=( $( grep -Eo ' ^[0-9]+' <<< " ${size}" ) )
150
154
# decimal todo
151
155
local NEW_SIZE_SUFFIX=" ${size# " ${NEW_SIZE_VALUE} " } "
152
156
if [ -z " ${NEW_SIZE_VALUE} " ] || [ " ${NEW_SIZE_VALUE} " == " 0" ]
153
157
then
154
158
# do not allow decimals https://github.com/kubernetes/kubernetes/pull/100100
155
- die " new size with unit parameter is not properly formatted. No decimals allowed"
159
+ die " -- size parameter is not properly formatted. No decimals allowed"
156
160
fi
157
161
158
162
local in=1
@@ -164,11 +168,10 @@ parse_args() {
164
168
done
165
169
if [[ ${in} -eq 1 ]];
166
170
then
167
- die " new size with unit parameter should not have decimals or is not properly formatted with units ${SUFFIXES_STRING} "
171
+ die " -- size with unit parameter should not have decimals and should be properly formatted with units ${SUFFIXES_STRING} "
168
172
fi
169
173
170
- resize " ${type} " " ${name} " " ${namespace} " " ${NEW_SIZE_VALUE} " " ${NEW_SIZE_SUFFIX} "
174
+ resize " ${type} " " ${name} " " ${namespace} " " ${wait} " " ${ NEW_SIZE_VALUE}" " ${NEW_SIZE_SUFFIX} "
171
175
}
172
176
173
177
parse_args " $@ " ;
174
-
0 commit comments