Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
postgres-operator
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
zalando
postgres-operator
Commits
35803a8c
Commit
35803a8c
authored
Jan 28, 2019
by
Sergey Dudoladov
Browse files
Options
Downloads
Patches
Plain Diff
Add a command to replace operator image w/o minikube restart
parent
637067e8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
run_operator_locally.sh
+18
-8
18 additions, 8 deletions
run_operator_locally.sh
with
18 additions
and
8 deletions
run_operator_locally.sh
+
18
−
8
View file @
35803a8c
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
# Known limitations:
# Known limitations:
# 1) minikube provides a single node k8s cluster. That is, you will not be able test functions like pod
# 1) minikube provides a single node k8s cluster. That is, you will not be able test functions like pod
# migration between multiple nodes locally
# migration between multiple nodes locally
# 2) this script configures the operator via configmap, not the operator CRD
# enable unofficial bash strict mode
# enable unofficial bash strict mode
...
@@ -43,7 +44,7 @@ function retry(){
...
@@ -43,7 +44,7 @@ function retry(){
}
}
function
display_help
(){
function
display_help
(){
echo
"Usage:
$0
[ -r | --rebuild-operator ] [ -h | --help ] [ -
f
| --
force-minikube-restart
] [ -t | --deploy-pg-to-namespace-test ]"
echo
"Usage:
$0
[ -r | --rebuild-operator ] [ -h | --help ] [ -
n
| --
deploy-new-operator-image
] [ -t | --deploy-pg-to-namespace-test ]"
}
}
function
clean_up
(){
function
clean_up
(){
...
@@ -126,7 +127,7 @@ function deploy_self_built_image() {
...
@@ -126,7 +127,7 @@ function deploy_self_built_image() {
# docker should not attempt to fetch it from the registry due to imagePullPolicy
# docker should not attempt to fetch it from the registry due to imagePullPolicy
sed
--expression
"s/
\(
image
\:
.*
\:\)
.*
$/
\1
$TAG
/; s/smoke-tested-//"
manifests/postgres-operator.yaml
>
"
$PATH_TO_LOCAL_OPERATOR_MANIFEST
"
sed
--expression
"s/
\(
image
\:
.*
\:\)
.*
$/
\1
$TAG
/; s/smoke-tested-//"
manifests/postgres-operator.yaml
>
"
$PATH_TO_LOCAL_OPERATOR_MANIFEST
"
retry
"kubectl
create
-f
\"
$PATH_TO_LOCAL_OPERATOR_MANIFEST
\"
"
"attempt to create
$PATH_TO_LOCAL_OPERATOR_MANIFEST
resource"
retry
"kubectl
apply
-f
\"
$PATH_TO_LOCAL_OPERATOR_MANIFEST
\"
"
"attempt to create
$PATH_TO_LOCAL_OPERATOR_MANIFEST
resource"
}
}
...
@@ -142,17 +143,18 @@ function start_operator(){
...
@@ -142,17 +143,18 @@ function start_operator(){
retry
"kubectl create -f manifests/
\"
$file
\"
"
"attempt to create
$file
resource"
retry
"kubectl create -f manifests/
\"
$file
\"
"
"attempt to create
$file
resource"
done
done
cp
manifests/postgres-operator.yaml
$PATH_TO_LOCAL_OPERATOR_MANIFEST
if
[[
"
$should_build_custom_operator
"
=
true
]]
;
then
# set in main()
if
[[
"
$should_build_custom_operator
"
=
true
]]
;
then
# set in main()
deploy_self_built_image
deploy_self_built_image
else
else
retry
"kubectl
create -f
manifests/postgres-operator.yaml"
"attempt to create /postgres-operator.yaml
resource"
retry
"kubectl create -f
${
PATH_TO_LOCAL_OPERATOR_MANIFEST
}
"
"attempt to create
${
PATH_TO_LOCAL_OPERATOR_MANIFEST
}
resource"
fi
fi
local
-r
msg
=
"Wait for the postgresql custom resource definition to register..."
local
-r
msg
=
"Wait for the postgresql custom resource definition to register..."
local
-r
cmd
=
"kubectl get crd | grep --quiet 'postgresqls.acid.zalan.do'"
local
-r
cmd
=
"kubectl get crd | grep --quiet 'postgresqls.acid.zalan.do'"
retry
"
$cmd
"
"
$msg
"
retry
"
$cmd
"
"
$msg
"
}
}
...
@@ -188,6 +190,7 @@ function check_health(){
...
@@ -188,6 +190,7 @@ function check_health(){
fi
fi
}
}
function
submit_postgresql_manifest
(){
function
submit_postgresql_manifest
(){
echo
"==== SUBMIT MINIMAL POSTGRES MANIFEST ==== "
echo
"==== SUBMIT MINIMAL POSTGRES MANIFEST ==== "
...
@@ -206,6 +209,7 @@ function submit_postgresql_manifest(){
...
@@ -206,6 +209,7 @@ function submit_postgresql_manifest(){
}
}
function
main
(){
function
main
(){
if
!
[[
$(
basename
"
$PWD
"
)
==
"postgres-operator"
]]
;
then
if
!
[[
$(
basename
"
$PWD
"
)
==
"postgres-operator"
]]
;
then
...
@@ -217,7 +221,7 @@ function main(){
...
@@ -217,7 +221,7 @@ function main(){
local
should_build_custom_operator
=
false
local
should_build_custom_operator
=
false
local
should_deploy_pg_to_namespace_test
=
false
local
should_deploy_pg_to_namespace_test
=
false
local
should_re
start_minikub
e
=
false
local
should_re
place_operator_imag
e
=
false
while
true
while
true
do
do
...
@@ -227,12 +231,12 @@ function main(){
...
@@ -227,12 +231,12 @@ function main(){
display_help
display_help
exit
0
exit
0
;;
;;
-r
|
--rebuild-operator
)
-r
|
--rebuild-operator
)
# with minikube restart
should_build_custom_operator
=
true
should_build_custom_operator
=
true
break
break
;;
;;
-
f
|
--
force-
minikube
-
restart
)
# restarts
take minutes
so existing minikube is re-used by default
-
n
|
--
deploy-new-operator-image
)
# without
minikube
restart
that
take
s
minutes
should_re
start_minikub
e
=
true
should_re
place_operator_imag
e
=
true
break
break
;;
;;
-t
|
--deploy-pg-to-namespace-test
)
# to test multi-namespace support locally
-t
|
--deploy-pg-to-namespace-test
)
# to test multi-namespace support locally
...
@@ -244,6 +248,11 @@ function main(){
...
@@ -244,6 +248,11 @@ function main(){
esac
esac
done
done
if
${
should_replace_operator_image
}
;
then
deploy_self_built_image
exit
0
fi
clean_up
clean_up
start_minikube
start_minikube
start_operator
start_operator
...
@@ -254,4 +263,5 @@ function main(){
...
@@ -254,4 +263,5 @@ function main(){
exit
0
exit
0
}
}
main
"
$@
"
main
"
$@
"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment