-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alexandre Lamarre <[email protected]>
- Loading branch information
1 parent
ba1202b
commit d20dfcb
Showing
4 changed files
with
153 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
K3D_URL=https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | ||
DEFAULT_K3D_VERSION=v5.4.6 | ||
|
||
install_k3d(){ | ||
local k3dVersion=${K3D_VERSION:-${DEFAULT_K3D_VERSION}} | ||
echo -e "Downloading k3d@${k3dVersion} see: ${K3D_URL}" | ||
curl --silent --fail ${K3D_URL} | TAG=${k3dVersion} bash | ||
} | ||
|
||
install_k3d | ||
|
||
k3d version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
source ./scripts/version | ||
|
||
if [ -z "$CLUSTER_NAME" ]; then | ||
echo "CLUSTER_NAME must be specified when setting up a cluster" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$K3S_VERSION" ]; then | ||
echo "K3S_VERSION must be specified when setting up a cluster, use $(k3d version list k3s) to find valid versions" | ||
exit 1 | ||
fi | ||
|
||
# waits until all nodes are ready | ||
wait_for_nodes(){ | ||
timeout=120 | ||
start_time=$(date +%s) | ||
echo "wait until all agents are ready" | ||
while : | ||
do | ||
current_time=$(date +%s) | ||
elapsed_time=$((current_time - start_time)) | ||
if [ $elapsed_time -ge $timeout ]; then | ||
echo "Timeout reached, exiting..." | ||
exit 1 | ||
fi | ||
|
||
readyNodes=1 | ||
statusList=$(kubectl get nodes --no-headers | awk '{ print $2}') | ||
# shellcheck disable=SC2162 | ||
while read status | ||
do | ||
current_time=$(date +%s) | ||
elapsed_time=$((current_time - start_time)) | ||
if [ $elapsed_time -ge $timeout ]; then | ||
echo "Timeout reached, exiting..." | ||
exit 1 | ||
fi | ||
if [ "$status" == "NotReady" ] || [ "$status" == "" ] | ||
then | ||
readyNodes=0 | ||
break | ||
fi | ||
done <<< "$(echo -e "$statusList")" | ||
# all nodes are ready; exit | ||
if [[ $readyNodes == 1 ]] | ||
then | ||
break | ||
fi | ||
sleep 1 | ||
done | ||
} | ||
|
||
k3d cluster delete $CLUSTER_NAME || true | ||
k3d cluster create $CLUSTER_NAME --image "docker.io/rancher/k3s:${K3S_VERSION}" | ||
|
||
wait_for_nodes | ||
|
||
echo "$CLUSTER_NAME ready" | ||
|
||
kubectl cluster-info --context k3d-${CLUSTER_NAME} | ||
kubectl config use-context k3d-${CLUSTER_NAME} | ||
kubectl get nodes -o wide | ||
|
||
IMAGE=${REPO}/backup-restore-operator:${TAG} | ||
|
||
k3d image import ${IMAGE} -c $CLUSTER_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ REPO=${REPO:-rancher} | |
if echo $TAG | grep -q dirty; then | ||
TAG=dev | ||
fi | ||
IMAGE=${REPO}/helm-project-operator:${TAG} |