forked from kurator-dev/kurator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added script to create two clusters as e2e test environments
Signed-off-by: LiZhenCheng9527 <lizhencheng6@huawei.com>
- Loading branch information
1 parent
6558d00
commit 5d90e31
Showing
6 changed files
with
115 additions
and
53 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,17 @@ | ||
/* | ||
Copyright Kurator Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e |
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
# shellcheck disable=SC2086,SC1090,SC2206,SC1091 | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# This script starts a local karmada control plane based on current codebase and with a certain number of clusters joined. | ||
# Parameters: [HOST_IPADDRESS](optional) if you want to export clusters' API server port to specific IP address | ||
# This script depends on utils in: ${REPO_ROOT}/hack/util.sh | ||
# 1. used by developer to setup develop environment quickly. | ||
# 2. used by e2e testing to setup test environment automatically. | ||
ROOT_DIR=$(git rev-parse --show-toplevel)/hack | ||
KIND_CONFIGS_ROOT=${ROOT_DIR}/kind-configs | ||
source "${ROOT_DIR}"/util.sh | ||
|
||
KIND_VERSION=${KIND_VERSION:-"kindest/node:v1.27.3"} | ||
|
||
# variable define | ||
KUBECONFIG_PATH=${KUBECONFIG_PATH:-"${HOME}/.kube"} | ||
MAIN_KUBECONFIG=${MAIN_KUBECONFIG:-"${KUBECONFIG_PATH}/kurator-host.config"} | ||
HOST_CLUSTER_NAME=${HOST_CLUSTER_NAME:-"kurator-host"} | ||
MEMBER_CLUSTER_KUBECONFIG=${MEMBER_CLUSTER_KUBECONFIG:-"${KUBECONFIG_PATH}/kurator-member.config"} | ||
MEMBER_CLUSTER_NAME=${MEMBER_CLUSTER_NAME:-"kurator-member"} | ||
ENABLE_KIND_WITH_WORKER=${ENABLE_KIND_WITH_WORKER:-"false"} | ||
|
||
#prepare for kind cluster config | ||
TEMP_PATH=$(mktemp -d) | ||
echo -e "Preparing kind config in path: ${TEMP_PATH}" | ||
#When the Enable worker option is turned on, select to copy the configuration that contains the worker. | ||
if [ ${ENABLE_KIND_WITH_WORKER} = "true" ]; then | ||
cp -rf ${ROOT_DIR}/kind-configs-with-worker/*.yaml "${TEMP_PATH}"/ | ||
else | ||
cp -rf "${KIND_CONFIGS_ROOT}"/*.yaml "${TEMP_PATH}"/ | ||
fi | ||
|
||
util::create_cluster "${HOST_CLUSTER_NAME}" "${MAIN_KUBECONFIG}" "${KIND_VERSION}" "${TEMP_PATH}" "${TEMP_PATH}"/host.yaml | ||
util::create_cluster "${MEMBER_CLUSTER_NAME}" "${MEMBER_CLUSTER_KUBECONFIG}" "${KIND_VERSION}" "${TEMP_PATH}" "${TEMP_PATH}"/member1.yaml | ||
|
||
util::check_clusters_ready "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}" | ||
sleep 5s | ||
util::check_clusters_ready "${MEMBER_CLUSTER_KUBECONFIG}" "${MEMBER_CLUSTER_NAME}" | ||
sleep 10s | ||
|
||
# connecting networks between primary, remote clusters | ||
echo "connect primary <-> remote" | ||
util::connect_kind_clusters "${HOST_CLUSTER_NAME}" "${MAIN_KUBECONFIG}" "${MEMBER_CLUSTER_NAME}" "${MEMBER_CLUSTER_KUBECONFIG}" 1 | ||
|
||
echo "cluster networks connected" | ||
|
||
echo "install metallb in host cluster" | ||
util::install_metallb ${MAIN_KUBECONFIG} ${HOST_CLUSTER_NAME} "ipv4" "255" | ||
|
||
|
||
echo "starting install metallb in member clusters" | ||
MEMBER_CLUSTERS=(${MEMBER_CLUSTER_NAME}) | ||
MEMBER_KUBECONFIGS=(${MEMBER_CLUSTER_KUBECONFIG}) | ||
MEMBER_IPSPACES=("254" "253") | ||
echo "install metallb in ${MEMBER_CLUSTERS}" | ||
util::install_metallb ${MEMBER_KUBECONFIGS} ${MEMBER_CLUSTERS} "ipv4" ${MEMBER_IPSPACES} | ||
|
||
function print_success() { | ||
echo "Local clusters is running." | ||
echo -e "\nTo start using your host cluster, run:" | ||
echo -e " export KUBECONFIG=${MAIN_KUBECONFIG}" | ||
echo -e "\nTo manage your remote clusters, run:" | ||
echo -e " export KUBECONFIG=${MEMBER_CLUSTER_KUBECONFIG}" | ||
} | ||
|
||
print_success |
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