Apply stashed changes that build operator
This commit is contained in:
parent
2cd6e9d989
commit
7ce36a3d5b
|
|
@ -20,6 +20,37 @@ function retry(){ # timeouts after 1 minutes
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function build_operator_binary(){
|
||||||
|
make tools && make deps && make local
|
||||||
|
}
|
||||||
|
|
||||||
|
# the fastest way to run your docker image locally is to reuse the docker from minikube.
|
||||||
|
function deploy_self_built_image() {
|
||||||
|
|
||||||
|
echo "==== DEPLOY CUSTOM OPERATOR IMAGE ==== "
|
||||||
|
|
||||||
|
build_operator_binary
|
||||||
|
|
||||||
|
# set docker env vars so that it can talk to the Docker daemon inside the minikube VM
|
||||||
|
eval $(minikube docker-env)
|
||||||
|
|
||||||
|
# image tag consists of a git tag or a unique commit prefix
|
||||||
|
# and the "-dev" suffix if there are uncommited changes in the working dir
|
||||||
|
export TAG=$(git describe --tags --always --dirty="-dev")
|
||||||
|
|
||||||
|
# build the image
|
||||||
|
make docker
|
||||||
|
|
||||||
|
# update the tag in the postgres operator conf
|
||||||
|
# since the image with this tag is already present on the machine,
|
||||||
|
# docker should not attempt to fetch it from the registry due to imagePullPolicy
|
||||||
|
file="manifests/local-postgres-operator.yaml"
|
||||||
|
sed -e "s/\(image\:.*\:\).*$/\1$TAG/" manifests/postgres-operator.yaml >> "$file"
|
||||||
|
|
||||||
|
retry "kubectl create -f \"$file\"" "attempt to create $file resource"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
echo "==== CLEAN UP PREVIOUS RUN ==== "
|
echo "==== CLEAN UP PREVIOUS RUN ==== "
|
||||||
|
|
||||||
status=$(minikube status --format "{{.MinikubeStatus}}")
|
status=$(minikube status --format "{{.MinikubeStatus}}")
|
||||||
|
|
@ -39,8 +70,8 @@ if [ -e /tmp/kubectl-port-forward.pid ]; then
|
||||||
kill "$pid"
|
kill "$pid"
|
||||||
fi
|
fi
|
||||||
rm /tmp/kubectl-port-forward.pid
|
rm /tmp/kubectl-port-forward.pid
|
||||||
fi
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
echo "==== START MINIKUBE ==== "
|
echo "==== START MINIKUBE ==== "
|
||||||
echo "May take a few minutes ..."
|
echo "May take a few minutes ..."
|
||||||
|
|
@ -52,11 +83,18 @@ minikube status
|
||||||
|
|
||||||
echo "==== START OPERATOR ==== "
|
echo "==== START OPERATOR ==== "
|
||||||
# the order of files is significant
|
# the order of files is significant
|
||||||
for file in "configmap.yaml" "serviceaccount.yaml" "postgres-operator.yaml"
|
for file in "configmap.yaml" "serviceaccount.yaml"
|
||||||
do
|
do
|
||||||
retry "kubectl create -f manifests/\"$file\"" "attempt to create $file resource"
|
retry "kubectl create -f manifests/\"$file\"" "attempt to create $file resource"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
should_build_operator=true
|
||||||
|
if [ "$should_build_operator" = true ]; then
|
||||||
|
deploy_self_built_image
|
||||||
|
else
|
||||||
|
retry "kubectl create -f manifests/postgres-operator.yaml" "attempt to create $file resource"
|
||||||
|
fi
|
||||||
|
|
||||||
msg="Wait for the postgresql custom resource definition to register..."
|
msg="Wait for the postgresql custom resource definition to register..."
|
||||||
cmd="kubectl get crd | grep --quiet 'postgresqls.acid.zalan.do'"
|
cmd="kubectl get crd | grep --quiet 'postgresqls.acid.zalan.do'"
|
||||||
retry "$cmd" "$msg "
|
retry "$cmd" "$msg "
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue