@@ -66,15 +66,18 @@ if ! echo "$current_context" | grep -P '.*-admin@.*-mgt-cluster'; then
6666fi
6767
6868branch=$( git branch --show-current)
69+
70+ # No branch name was found. Try to get a git-tag.
6971if [ " $branch " == " " ]; then
7072 branch=$( git describe --tags --exact-match 2> /dev/null || echo " " )
7173fi
7274
7375if [ " $branch " == " " ]; then
74- echo " failed to get branch name"
76+ echo " failed to find git branch/tag name"
7577 exit 1
7678fi
7779
80+ # Build tag for container image.
7881tag=" dev-$USER -$branch "
7982tag=" $( echo -n " $tag " | tr -c ' a-zA-Z0-9_.-' ' -' ) "
8083
@@ -105,18 +108,23 @@ if ! wait $pid_docker_push; then
105108 exit 1
106109fi
107110
111+ # Find namespace of caph deployment.
108112ns=$( kubectl get deployments.apps -A | { grep caph-controller || true ; } | cut -d' ' -f1)
109113if [[ -z $ns ]]; then
110114 echo " failed to get namespace for caph-controller"
111115 exit 1
112116fi
113117
118+ # Scale deployment to 1.
114119kubectl scale --replicas=1 -n " $ns " deployment/caph-controller-manager
115120
116121kubectl set image -n " $ns " deployment/caph-controller-manager manager=" $image "
117122
123+ # Set imagePullPolicy to "Always", so that a new image (with same name/tag) gets pulled.
118124kubectl patch deployment -n " $ns " -p ' [{"op": "replace", "path": "/spec/template/spec/containers/0/imagePullPolicy", "value": "Always"}]' --type=' json' caph-controller-manager
119125
126+ # If you update the image again, there might be no change the deployment spec.
127+ # Force a rollout:
120128kubectl rollout restart -n " $ns " deployment caph-controller-manager
121129
122130trap " echo 'Interrupted! Exiting...'; exit 1" SIGINT
0 commit comments