Skip to content

Commit

Permalink
DEV (kubevirtci): allow redploying the operator/webhook
Browse files Browse the repository at this point in the history
Added two new Makefile targets:
```shell
make cluster-redeploy-operator
make cluster-redeploy-webhook
```

It will rebuild the image, and restart the operator/webhook pods with
the new image.

Signed-off-by: Nahshon Unna-Tsameret <[email protected]>
  • Loading branch information
nunnatsa committed Dec 15, 2024
1 parent 45bbc9c commit 6554186
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ cluster-down:
cluster-sync:
IMAGE_REGISTRY=$(IMAGE_REGISTRY) REGISTRY_NAMESPACE=$(REGISTRY_NAMESPACE) ./cluster/sync.sh

cluster-redeploy-operator:
IMAGE_REGISTRY=$(IMAGE_REGISTRY) REGISTRY_NAMESPACE=$(REGISTRY_NAMESPACE) ./cluster/sync-pod.sh operator

cluster-redeploy-webhook:
IMAGE_REGISTRY=$(IMAGE_REGISTRY) REGISTRY_NAMESPACE=$(REGISTRY_NAMESPACE) ./cluster/sync-pod.sh webhook

cluster-clean:
CMD="./cluster/kubectl.sh" ./hack/clean.sh

Expand Down Expand Up @@ -267,6 +273,8 @@ bump-hco:
cluster-up \
cluster-down \
cluster-sync \
cluster-redeploy-operator \
cluster-redeploy-webhook \
cluster-clean \
stageRegistry \
functest \
Expand Down
37 changes: 37 additions & 0 deletions cluster/sync-pod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash -ex

source ./hack/common.sh
source ./_kubevirtci/cluster-up/cluster/ephemeral-provider-common.sh

function set_env() {
if [ ${KUBEVIRT_PROVIDER} != "external" ]; then
registry_port=$(${_cri_bin} ps | grep -Po '(?<=0.0.0.0:)\d+(?=->5000\/tcp)' | head -n 1)
if [ -z "$registry_port" ]; then
>&2 echo "unable to get the registry port"
exit 1
fi
export IMAGE_REGISTRY=localhost:$registry_port
export REGISTRY=registry:5000
export CMD="./cluster/kubectl.sh"
else
if [ "${REGISTRY_NAMESPACE}" == "kubevirt" ]; then
echo "REGISTRY_NAMESPACE cant be kubevirt when using KUBEVIRT_PROVIDER=external"
exit 1
fi
export REGISTRY=$IMAGE_REGISTRY
export CMD="oc"
fi
}

deploy_name=$1
if [[ "${deploy_name}" != "operator" && "${deploy_name}" != "webhook" ]]; then
echo "must use $0 with \"operator\" or \"webhook\""
exit 1
fi

set_env

make container-build-$1 container-push-${deploy_name}
${CMD} scale deployment -n kubevirt-hyperconverged hyperconverged-cluster-${deploy_name} --replicas=0
${CMD} scale deployment -n kubevirt-hyperconverged hyperconverged-cluster-${deploy_name} --replicas=1
${CMD} wait deployment hyperconverged-cluster-${deploy_name} --for=condition=Available

0 comments on commit 6554186

Please sign in to comment.