From 162f609c36c052a4408f94b202d1cd1cbaae9b73 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Tue, 22 Dec 2020 17:46:02 +0800 Subject: [PATCH] improve deployment script Signed-off-by: Kevin Wang --- hack/deploy-karmada.sh | 38 +++++++------------------------------- hack/karmada-bootstrap.sh | 12 ++++++++++++ hack/local-up-karmada.sh | 2 +- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/hack/deploy-karmada.sh b/hack/deploy-karmada.sh index 17f426be5..0f45225aa 100755 --- a/hack/deploy-karmada.sh +++ b/hack/deploy-karmada.sh @@ -8,11 +8,9 @@ CERT_DIR=${CERT_DIR:-"/var/run/karmada"} KARMADA_APISERVER_CONFIG="${CERT_DIR}/karmada-apiserver.config" KUBECONFIG_PATH=${KUBECONFIG_PATH:-"${HOME}/.kube"} KARMADA_KUBECONFIG="${KUBECONFIG_PATH}/karmada.config" -etcd_replicas=1 + etcd_pod_label="etcd" -apiserver_replicas=1 apiserver_pod_label="karmada-apiserver" -controller_replicas=1 controller_pod_label="kube-controller-manager" function usage() { @@ -23,32 +21,10 @@ function usage() { function waitPodReady() { local pod_label=$1 - local pod_namespaces=$2 - local pod_replicas=$3 + local pod_namespace=$2 - timeout=200 - while [[ $timeout -gt 0 ]]; do - echo "Waiting for $pod_label pods to become Ready" - statuses=$(kubectl get pods -n $pod_namespaces -l app=$pod_label \ - -o jsonpath='{.items[*].status.conditions[?(@.type=="Ready")].status}' \ - | grep "True" | wc -w) - if [[ $statuses -eq $pod_replicas ]]; then - break - else - sleep 1 - (( timeout=timeout-1 )) - fi - done - - - if [[ $timeout -gt 0 ]]; then - echo "All $pod_label pods became Ready" - else - echo "ERROR: Not all $pod_label pods became Ready" - echo "kubectl get pods -l app=$pod_label" - kubectl get pods -l app=$pod_label - exit 1 - fi + echo "wait the $pod_label ready..." + kubectl wait --for=condition=Ready --timeout=60s pods -l app=$pod_label -n $pod_namespace } function installCRDs() { @@ -80,7 +56,7 @@ kubectl create -f "${SCRIPT_ROOT}/artifacts/deploy/clusterrolebinding.yaml" kubectl create -f "${SCRIPT_ROOT}/artifacts/deploy/karmada-etcd.yaml" # Wait for karmada-etcd to come up before launching the rest of the components. -waitPodReady $etcd_pod_label "karmada-system" $etcd_replicas +waitPodReady $etcd_pod_label "karmada-system" # deploy karmada apiserver KARMADA_API_IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "karmada-control-plane") @@ -90,13 +66,13 @@ sed -i "s/{{api_addr}}/${KARMADA_API_IP}/g" ${SCRIPT_ROOT}/artifacts/deploy/karm kubectl create -f "${SCRIPT_ROOT}/artifacts/deploy/karmada-apiserver-tmp.yaml" # Wait for karmada-apiserver to come up before launching the rest of the components. -waitPodReady $apiserver_pod_label "karmada-system" $apiserver_replicas +waitPodReady $apiserver_pod_label "karmada-system" # deploy kube controller manager kubectl create -f "${SCRIPT_ROOT}/artifacts/deploy/kube-controller-manager.yaml" # Wait for karmada kube controller manager to come up before launching the rest of the components. -waitPodReady $controller_pod_label "karmada-system" $controller_replicas +waitPodReady $controller_pod_label "karmada-system" export KUBECONFIG=${KARMADA_APISERVER_CONFIG} diff --git a/hack/karmada-bootstrap.sh b/hack/karmada-bootstrap.sh index 274f4a17f..21c59ec9b 100755 --- a/hack/karmada-bootstrap.sh +++ b/hack/karmada-bootstrap.sh @@ -29,3 +29,15 @@ karmadactl join member1 --member-cluster-kubeconfig="${MEMBER_CLUSTER_1_KUBECONF MEMBER_CLUSTER_2_KUBECONFIG="${KUBECONFIG_PATH}/member2.config" "${REPO_ROOT}"/hack/create-cluster.sh member2 "${MEMBER_CLUSTER_2_KUBECONFIG}" karmadactl join member2 --member-cluster-kubeconfig="${MEMBER_CLUSTER_2_KUBECONFIG}" + + +function print_success() { + echo + echo "Local Karmada is running." + echo "To start using your karmada, run:" +cat <