only delete necessary clusters when installed by local-up
Signed-off-by: zhzhuang-zju <m17799853869@163.com>
This commit is contained in:
parent
41acf8fbf2
commit
ea46fc0192
|
|
@ -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}"
|
||||
|
|
|
|||
28
hack/util.sh
28
hack/util.sh
|
|
@ -442,26 +442,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
|
||||
|
|
|
|||
Loading…
Reference in New Issue