-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable locally building and loading kubectl-bats docker image i…
…nto the cluster for helm tests (#310) Signed-off-by: Lenin Mehedy <lenin.mehedy@swirldslabs.com>
- Loading branch information
1 parent
b3a7429
commit 230b291
Showing
6 changed files
with
192 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# helm test container | ||
tester: | ||
image: | ||
registry: "docker.fst.local" | ||
repository: "kubectl-bats" | ||
tag: "local" | ||
pullPolicy: "Never" | ||
resources: {} |
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,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" | ||
readonly SCRIPT_DIR | ||
readonly DOCKERFILE_DIR="${SCRIPT_DIR}/../../docker" | ||
readonly LOCAL_DOCKER_REGISTRY="docker.fst.local" # same as in dev/ci/ci-values.yaml | ||
readonly LOCAL_DOCKER_IMAGE_TAG="local" | ||
readonly KUBECTL_BATS_IMAGE="${LOCAL_DOCKER_REGISTRY}/kubectl-bats:${LOCAL_DOCKER_IMAGE_TAG}" | ||
|
||
function build_kubectl_bats() { | ||
local cluster_name=$1 | ||
local cluster_name=$1 | ||
[[ -z "${cluster_name}" ]] && echo "ERROR: Cluster name is required" && return 1 | ||
|
||
echo "" | ||
echo "Building kubectl-bats image" | ||
echo "-----------------------------------------------------------------------------------------------------" | ||
cd "${DOCKERFILE_DIR}/kubectl-bats" && docker build -t "${KUBECTL_BATS_IMAGE}" . | ||
kind load docker-image ${KUBECTL_BATS_IMAGE} -n "${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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" | ||
readonly SCRIPT_DIR | ||
CHART_DIR="${SCRIPT_DIR}/../../charts/hedera-network" | ||
|
||
function setup_cluster() { | ||
local cluster_name=$1 | ||
[[ -z "${cluster_name}" ]] && echo "ERROR: Cluster name is required" && return 1 | ||
|
||
local count=$(kind get clusters -q | grep -c -sw "${cluster_name}") | ||
if [[ $count -eq 0 ]]; then | ||
echo "Cluster '${cluster_name}' not found" | ||
kind create cluster -n "${cluster_name}" | ||
else | ||
echo "Cluster '${cluster_name}' found" | ||
fi | ||
|
||
kubectl config use-context "kind-${cluster_name}" | ||
kubectl config set-context --current --namespace=default | ||
kubectl config get-contexts | ||
} | ||
|
||
function install_chart() { | ||
local node_setup_script=$1 | ||
|
||
echo "" | ||
echo "Installing helm chart... " | ||
echo "SCRIPT_NAME: ${node_setup_script}" | ||
echo "Values: -f ${CHART_DIR}/values.yaml --values ${CHART_VALUES_FILES}" | ||
echo "-----------------------------------------------------------------------------------------------------" | ||
if [ "${node_setup_script}" = "nmt-install.sh" ]; then | ||
nmt_install | ||
else | ||
direct_install | ||
fi | ||
} | ||
|
||
function uninstall_chart() { | ||
echo "" | ||
echo "Uninstalling helm chart... " | ||
echo "-----------------------------------------------------------------------------------------------------" | ||
helm uninstall fst | ||
sleep 10 | ||
} | ||
|
||
function nmt_install() { | ||
if [[ -z "${CHART_VALUES_FILES}" ]]; then | ||
helm install fst "${CHART_DIR}" --set defaults.root.image.repository=hashgraph/full-stack-testing/ubi8-init-dind | ||
else | ||
helm install fst "${CHART_DIR}" -f "${CHART_DIR}/values.yaml" --values "${CHART_VALUES_FILES}" --set defaults.root.image.repository=hashgraph/full-stack-testing/ubi8-init-dind | ||
fi | ||
} | ||
|
||
function direct_install() { | ||
if [[ -z "${CHART_VALUES_FILES}" ]]; then | ||
helm install fst "${CHART_DIR}" | ||
else | ||
helm install fst "${CHART_DIR}" -f "${CHART_DIR}/values.yaml" --values "${CHART_VALUES_FILES}" | ||
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