6
6
# Known limitations:
7
7
# 1) minikube provides a single node k8s cluster. That is, you will not be able test functions like pod
8
8
# migration between multiple nodes locally
9
+ # 2) this script configures the operator via configmap, not the operator CRD
9
10
10
11
11
12
# enable unofficial bash strict mode
@@ -43,7 +44,7 @@ function retry(){
43
44
}
44
45
45
46
function display_help(){
46
- echo " Usage: $0 [ -r | --rebuild-operator ] [ -h | --help ] [ -f | --force-minikube-restart ] [ -t | --deploy-pg-to-namespace-test ]"
47
+ echo " Usage: $0 [ -r | --rebuild-operator ] [ -h | --help ] [ -n | --deploy-new-operator-image ] [ -t | --deploy-pg-to-namespace-test ]"
47
48
}
48
49
49
50
function clean_up(){
@@ -126,7 +127,7 @@ function deploy_self_built_image() {
126
127
# docker should not attempt to fetch it from the registry due to imagePullPolicy
127
128
sed --expression " s/\(image\:.*\:\).*$/\1$TAG /; s/smoke-tested-//" manifests/postgres-operator.yaml > " $PATH_TO_LOCAL_OPERATOR_MANIFEST "
128
129
129
- retry " kubectl create -f \" $PATH_TO_LOCAL_OPERATOR_MANIFEST \" " " attempt to create $PATH_TO_LOCAL_OPERATOR_MANIFEST resource"
130
+ retry " kubectl apply -f \" $PATH_TO_LOCAL_OPERATOR_MANIFEST \" " " attempt to create $PATH_TO_LOCAL_OPERATOR_MANIFEST resource"
130
131
}
131
132
132
133
@@ -142,17 +143,18 @@ function start_operator(){
142
143
retry " kubectl create -f manifests/\" $file \" " " attempt to create $file resource"
143
144
done
144
145
146
+ cp manifests/postgres-operator.yaml $PATH_TO_LOCAL_OPERATOR_MANIFEST
147
+
145
148
if [[ " $should_build_custom_operator " = true ]]; then # set in main()
146
149
deploy_self_built_image
147
150
else
148
- retry " kubectl create -f manifests/postgres-operator.yaml " " attempt to create /postgres-operator.yaml resource"
151
+ retry " kubectl create -f ${PATH_TO_LOCAL_OPERATOR_MANIFEST} " " attempt to create ${PATH_TO_LOCAL_OPERATOR_MANIFEST} resource"
149
152
fi
150
153
151
154
local -r msg=" Wait for the postgresql custom resource definition to register..."
152
155
local -r cmd=" kubectl get crd | grep --quiet 'postgresqls.acid.zalan.do'"
153
156
retry " $cmd " " $msg "
154
157
155
-
156
158
}
157
159
158
160
@@ -188,6 +190,7 @@ function check_health(){
188
190
fi
189
191
}
190
192
193
+
191
194
function submit_postgresql_manifest(){
192
195
193
196
echo " ==== SUBMIT MINIMAL POSTGRES MANIFEST ==== "
@@ -206,6 +209,7 @@ function submit_postgresql_manifest(){
206
209
207
210
}
208
211
212
+
209
213
function main(){
210
214
211
215
if ! [[ $( basename " $PWD " ) == " postgres-operator" ]]; then
@@ -217,7 +221,7 @@ function main(){
217
221
218
222
local should_build_custom_operator=false
219
223
local should_deploy_pg_to_namespace_test=false
220
- local should_restart_minikube =false
224
+ local should_replace_operator_image =false
221
225
222
226
while true
223
227
do
@@ -227,12 +231,12 @@ function main(){
227
231
display_help
228
232
exit 0
229
233
;;
230
- -r | --rebuild-operator)
234
+ -r | --rebuild-operator) # with minikube restart
231
235
should_build_custom_operator=true
232
236
break
233
237
;;
234
- -f | --force-minikube-restart ) # restarts take minutes so existing minikube is re-used by default
235
- should_restart_minikube =true
238
+ -n | --deploy-new-operator-image ) # without minikube restart that takes minutes
239
+ should_replace_operator_image =true
236
240
break
237
241
;;
238
242
-t | --deploy-pg-to-namespace-test) # to test multi-namespace support locally
@@ -244,6 +248,11 @@ function main(){
244
248
esac
245
249
done
246
250
251
+ if ${should_replace_operator_image} ; then
252
+ deploy_self_built_image
253
+ exit 0
254
+ fi
255
+
247
256
clean_up
248
257
start_minikube
249
258
start_operator
@@ -254,4 +263,5 @@ function main(){
254
263
exit 0
255
264
}
256
265
266
+
257
267
main " $@ "
0 commit comments