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 FLUX_SOPS_KEY_NAME=${FLUX_SOPS_KEY_NAME:-"icn-site-vm"} # TODO Replace ICN test key with real key
15 function build_source {
16 sops_encrypt_site ${SCRIPTDIR}/site.yaml ${FLUX_SOPS_KEY_NAME}
20 flux_create_site https://gerrit.akraino.org/r/icn master deploy/site/pod11 ${FLUX_SOPS_KEY_NAME}
24 kubectl -n flux-system delete kustomization icn-master-site-pod11
27 function is_cluster_ready {
28 [[ $(kubectl -n metal3 get cluster icn -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}') == "True" ]]
31 function is_control_plane_ready {
32 # Checking the Cluster resource status is not sufficient, it
33 # reports the control plane as ready before the nodes forming the
34 # control plane are ready
35 local -r replicas=$(kubectl -n metal3 get kubeadmcontrolplane icn -o jsonpath='{.spec.replicas}')
36 [[ $(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} ]]
39 function wait_for_all_ready {
42 wait_for is_cluster_ready
43 clusterctl -n metal3 get kubeconfig icn >${BUILDDIR}/icn-admin.conf
44 chmod 600 ${BUILDDIR}/icn-admin.conf
45 wait_for is_control_plane_ready
49 "build-source") build_source ;;
52 "wait") wait_for_all_ready ;;
54 Usage: $(basename $0) COMMAND
57 build-source - Rebuild the in-tree site files
58 clean - Remove the site
59 deploy - Deploy the site
60 wait - Wait for the site to be ready