-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split python setup and tearmdown scripts to bash scripts
this allows the CI and makefile to have more configurations Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
- Loading branch information
Showing
11 changed files
with
212 additions
and
130 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
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,41 @@ | ||
#!/bin/bash | ||
|
||
# Description: | ||
# This script checks for the existence of specific binaries on the system. | ||
# It uses a function called which_binary to accomplish this. | ||
# The script first verifies the existence of the binaries and then prints their paths. | ||
|
||
# Usage: | ||
# ./check-bins.sh | ||
|
||
# Dependencies: | ||
# The script expects the following binaries to be present in the system's PATH: | ||
# k3d, cross, docker, kubectl | ||
|
||
set -euo pipefail | ||
|
||
# Function: which_binary | ||
# Description: | ||
# Finds and prints the path of the specified binary if it exists in the system's PATH. | ||
# If the binary is not found, it prints an error message. | ||
# Parameters: | ||
# $1 - The name of the binary to locate. | ||
which_binary() { | ||
local binary_name="$1" | ||
local binary_path | ||
binary_path=$(command -v "$binary_name") | ||
if [[ -n "$binary_path" ]]; then | ||
echo "$binary_path" | ||
else | ||
echo "Could not find $binary_name" >&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
|
||
# List of binary names | ||
binaries=("k3d" "cross" "docker" "kubectl") | ||
|
||
for binary in "${binaries[@]}"; do | ||
which_binary "$binary" | ||
done |
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,15 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
cluster_name="test-cluster" | ||
|
||
teardown_test() { | ||
# delete k3d cluster | ||
k3d cluster delete "$cluster_name" | ||
|
||
# delete docker image | ||
docker rmi k3d-shim-test | ||
} | ||
|
||
teardown_test |
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,46 @@ | ||
#!/bin/bash | ||
|
||
# Containerd Shim Installer Script | ||
# | ||
# This script automates the installation of specific containerd shim versions (slight, spin, wws) | ||
# by checking their existence and copying them to a desired location if not found. | ||
# | ||
# Usage: | ||
# ./move-bins.sh [release_pattern] [target] | ||
# | ||
# Arguments: | ||
# 1. release_pattern (Optional): The pattern used to locate the shim binaries. | ||
# 2. target (Optional): The target architecture used in the release path. | ||
# Default value is `x86_64-unknown-linux-musl`. | ||
# | ||
# Example: | ||
# ./move-bins.sh | ||
# | ||
|
||
set -euo pipefail | ||
|
||
target="${2:-x86_64-unknown-linux-musl}" | ||
release_pattern="${1:-containerd-shim-%s-v1/target/$target/release}" | ||
|
||
dockerfile_path="deployments/k3d" | ||
bin_path="${dockerfile_path}/.tmp/" | ||
cluster_name="test-cluster" | ||
default_shim_path="${bin_path}containerd-shim-" | ||
|
||
declare -A shims=( | ||
[slight]="${default_shim_path}slight-v1" | ||
[spin]="${default_shim_path}spin-v1" | ||
[wws]="${default_shim_path}wws-v1" | ||
) | ||
|
||
mkdir -p "$bin_path" | ||
|
||
for shim_key in "${!shims[@]}"; do | ||
shim_path=${shims[$shim_key]} | ||
release_path=$(printf "$release_pattern" "$shim_key") | ||
|
||
if [ ! -f "$shim_path" ]; then | ||
echo ">>> install containerd-shim-${shim_key}-v1 from $release_path" | ||
cp "$(eval echo $release_path)/containerd-shim-${shim_key}-v1" "${bin_path}containerd-shim-${shim_key}-v1" | ||
fi | ||
done |
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,21 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
# Get the status of all pods | ||
pod_statuses=$(kubectl get pods --no-headers -o custom-columns=":status.phase") | ||
|
||
# Check if all pods are running fine | ||
all_running=true | ||
for status in $pod_statuses; do | ||
if [ "$status" != "Running" ]; then | ||
all_running=false | ||
break | ||
fi | ||
done | ||
|
||
if $all_running; then | ||
echo "All pods are running fine." | ||
else | ||
echo "Not all pods are running fine. Please check the status." | ||
fi |
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,29 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
cluster_name="test-cluster" # name of the k3d cluster | ||
dockerfile_path="deployments/k3d" # path to the Dockerfile | ||
|
||
DOCKER_IMAGES=("slight" "spin" "wws") | ||
OUT_DIRS=("test/out_slight" "test/out_spin" "test/out_wws") | ||
IMAGES=("slight-hello-world" "spin-hello-world" "wws-hello-world") | ||
|
||
# build the Docker image for the k3d cluster | ||
docker build -t k3d-shim-test "$dockerfile_path" | ||
|
||
k3d cluster create "$cluster_name" --image k3d-shim-test --api-port 6551 -p '8082:80@loadbalancer' --agents 2 | ||
|
||
kubectl wait --for=condition=ready node --all --timeout=120s | ||
|
||
# Iterate through the Docker images and build them | ||
for i in "${!DOCKER_IMAGES[@]}"; do | ||
docker buildx build -t "${IMAGES[$i]}:latest" "./images/${DOCKER_IMAGES[$i]}" --load | ||
mkdir -p "${OUT_DIRS[$i]}" | ||
docker save -o "${OUT_DIRS[$i]}/img.tar" "${IMAGES[$i]}:latest" | ||
k3d image import "${OUT_DIRS[$i]}/img.tar" -c "$cluster_name" | ||
done | ||
|
||
sleep 5 | ||
|
||
echo ">>> cluster is ready" |
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,26 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
# apply the workloads | ||
echo ">>> apply workloads" | ||
kubectl apply -f tests/workloads | ||
|
||
|
||
# wait for all the pods to be ready | ||
kubectl wait --for=condition=ready --timeout=50s pod --all | ||
|
||
# get and describe all the pods | ||
echo ">>> Pods:" | ||
kubectl get pods -o wide | ||
kubectl describe pods | ||
|
||
# get and describe all the deployments | ||
echo ">>> Deployments:" | ||
kubectl get deployments -o wide | ||
kubectl describe deployments | ||
|
||
# get and describe all the services | ||
echo ">>> Services:" | ||
kubectl get services -o wide | ||
kubectl describe services |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.