Skip to content

Commit

Permalink
Merge pull request karmada-io#4462 from zhzhuang-zju/local
Browse files Browse the repository at this point in the history
only delete necessary clusters when installed by local-up
  • Loading branch information
karmada-bot authored Jan 15, 2024
2 parents 2d2da55 + ea46fc0 commit 34c4d04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion hack/local-up-karmada.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ echo -e "Preparing kindClusterConfig in path: ${TEMP_PATH}"
cp -rf "${REPO_ROOT}"/artifacts/kindClusterConfig/member1.yaml "${TEMP_PATH}"/member1.yaml
cp -rf "${REPO_ROOT}"/artifacts/kindClusterConfig/member2.yaml "${TEMP_PATH}"/member2.yaml

util::delete_all_clusters "${MAIN_KUBECONFIG}" "${MEMBER_CLUSTER_KUBECONFIG}" "${KIND_LOG_FILE}"
util::delete_necessary_resources "${MAIN_KUBECONFIG},${MEMBER_CLUSTER_KUBECONFIG}" "${HOST_CLUSTER_NAME},${MEMBER_CLUSTER_1_NAME},${MEMBER_CLUSTER_2_NAME},${PULL_MODE_CLUSTER_NAME}" "${KIND_LOG_FILE}"

if [[ -n "${HOST_IPADDRESS}" ]]; then # If bind the port of clusters(karmada-host, member1 and member2) to the host IP
util::verify_ip_address "${HOST_IPADDRESS}"
Expand Down
28 changes: 14 additions & 14 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -449,26 +449,26 @@ function util::kubectl_with_retry() {
return ${ret}
}

# util::delete_all_clusters deletes all clusters directly
# util::delete_all_clusters actually do three things: delete cluster、remove kubeconfig、record delete log
# util::delete_necessary_resources deletes clusters(karmada-host, member1, member2 and member3) and related resources directly
# util::delete_necessary_resources actually do three things: delete cluster、remove kubeconfig、record delete log
# Parameters:
# - $1: KUBECONFIG file of host cluster, such as "~/.kube/karmada.config"
# - $2: KUBECONFIG file of member cluster, such as "~/.kube/members.config"
# - $1: KUBECONFIG files of clusters, separated by ",", such as "~/.kube/karmada.config,~/.kube/members.config"
# - $2: clusters, separated by ",", such as "karmada-host,member1"
# - $3: log file path, such as "/tmp/karmada/"
function util::delete_all_clusters() {
local main_config=${1}
local member_config=${2}
function util::delete_necessary_resources() {
local config_files=${1}
local clusters=${2}
local log_path=${3}

local log_file="${log_path}"/delete-all-clusters.log
rm -rf ${log_file}
local log_file="${log_path}"/delete-necessary-resources.log
rm -f ${log_file}
mkdir -p ${log_path}

kind delete clusters --all >> "${log_file}" 2>&1
rm -f "${main_config}"
rm -f "${member_config}"

echo "Deleted all clusters and the log file is in ${log_file}"
local config_file_arr=$(echo ${config_files}| tr ',' ' ')
local cluster_arr=$(echo ${clusters}| tr ',' ' ')
kind delete clusters ${cluster_arr} >> "${log_file}" 2>&1
rm -f ${config_file_arr}
echo "Deleted all necessary clusters and the log file is in ${log_file}"
}

# util::create_cluster creates a kubernetes cluster
Expand Down

0 comments on commit 34c4d04

Please sign in to comment.