create cluster script support MacOS

Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
This commit is contained in:
chaosi-zju 2023-11-21 19:17:19 +08:00
parent cf1dbf0e16
commit 29a4ace923
1 changed files with 4 additions and 4 deletions

View File

@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# This script only fits for Linux, macOS adaptation will come soon
# This script works for both linux and macOS.
set -o errexit
set -o nounset
set -o pipefail
@ -70,7 +69,7 @@ fi
function rand() {
min=$1
max=$(($2-$min+1))
num=$(date +%s%N)
num=$(date +%s)
echo $(($num%$max+$min))
}
@ -96,7 +95,8 @@ cp -rf "${REPO_ROOT}"/artifacts/kindClusterConfig/general-config.yaml "${TEMP_PA
sed -i'' -e "s#{{pod_cidr}}#${POD_CIDR}#g" "${TEMP_PATH}"/"${CLUSTER_NAME}"-config.yaml
sed -i'' -e "s#{{service_cidr}}#${SERVICE_CIDR}#g" "${TEMP_PATH}"/"${CLUSTER_NAME}"-config.yaml
kind_log="$(mktemp --suffix=-kind.log)"
mkdir -p /tmp/kind-log/
kind_log="/tmp/kind-log/$(date +%s)"
echo "Creating cluster \"${CLUSTER_NAME}\" ..."
kind create cluster --name "${CLUSTER_NAME}" --kubeconfig="${KUBECONFIG}" --image="${CLUSTER_VERSION}" --config="${TEMP_PATH}"/"${CLUSTER_NAME}"-config.yaml > ${kind_log} 2>&1 || (
echo "Creating cluster ${CLUSTER_NAME} failed, see detail log in ${kind_log}."