4 SCRIPTDIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
5 LIBDIR="$(dirname $(dirname $(dirname ${SCRIPTDIR})))/env/lib"
7 source $LIBDIR/common.sh
8 source $SCRIPTDIR/../common.sh
10 BUILDDIR=${SCRIPTDIR/deploy/build}
13 SITE_REPO=${SITE_REPO:-"https://gerrit.akraino.org/r/icn"}
14 SITE_BRANCH=${SITE_BRANCH:-"master"}
15 SITE_PATH=${SITE_PATH:-"deploy/site/pod11/deployment"}
18 # TODO Replace ICN test key with real key
19 flux_create_site ${SITE_REPO} ${SITE_BRANCH} ${SITE_PATH} ${FLUX_SOPS_KEY_NAME}
23 kubectl -n flux-system delete kustomization $(flux_site_kustomization_name ${SITE_REPO} ${SITE_BRANCH} ${SITE_PATH})
26 function is_cluster_ready {
27 [[ $(kubectl -n ${SITE_NAMESPACE} get cluster icn -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}') == "True" ]]
30 function is_control_plane_ready {
31 # Checking the Cluster resource status is not sufficient, it
32 # reports the control plane as ready before the nodes forming the
33 # control plane are ready
34 local -r replicas=$(kubectl -n ${SITE_NAMESPACE} get kubeadmcontrolplane icn -o jsonpath='{.spec.replicas}')
35 [[ $(kubectl --kubeconfig=${BUILDDIR}/icn-admin.conf get nodes -l node-role.kubernetes.io/control-plane -o jsonpath='{range .items[*]}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}' | grep -c True) == ${replicas} ]]
38 function wait_for_all_ready {
41 wait_for is_cluster_ready
42 clusterctl -n ${SITE_NAMESPACE} get kubeconfig icn >${BUILDDIR}/icn-admin.conf
43 chmod 600 ${BUILDDIR}/icn-admin.conf
44 wait_for is_control_plane_ready
47 function is_cluster_deleted {
48 ! kubectl -n ${SITE_NAMESPACE} get cluster icn
51 function wait_for_all_deleted {
54 wait_for is_cluster_deleted
60 "wait") wait_for_all_ready ;;
61 "wait-clean") wait_for_all_deleted ;;
63 Usage: $(basename $0) COMMAND
66 clean - Remove the site
67 deploy - Deploy the site
68 wait - Wait for the site to be ready