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 e2etest -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 e2etest -o jsonpath='{.spec.replicas}')
36 [[ $(kubectl --kubeconfig=${BUILDDIR}/e2etest-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 insert_control_plane_network_identity_into_ssh_config {
40 # This enables logging into the control plane machines from this
41 # machine without specifying the identify file on the command line
43 # Create ssh config if it doesn't exist
44 mkdir -p ${HOME}/.ssh && chmod 700 ${HOME}/.ssh
45 touch ${HOME}/.ssh/config
46 chmod 600 ${HOME}/.ssh/config
47 # Add the entry for the control plane network, host value in ssh
48 # config is a wildcard
49 endpoint=$(helm -n metal3 get values -a cluster-e2etest | awk '/controlPlaneEndpoint:/ {print $2}')
50 prefix=$(helm -n metal3 get values -a cluster-e2etest | awk '/controlPlanePrefix:/ {print $2}')
51 host=$(ipcalc ${endpoint}/${prefix} | awk '/Network:/ {sub(/\.0.*/,".*"); print $2}')
52 if [[ $(grep -c "Host ${host}" ${HOME}/.ssh/config) != 0 ]]; then
53 sed -i -e '/Host '"${host}"'/,+1 d' ${HOME}/.ssh/config
55 cat <<EOF >>${HOME}/.ssh/config
57 IdentityFile ${SCRIPTDIR}/id_rsa
61 function wait_for_all_ready {
64 wait_for is_cluster_ready
65 clusterctl -n metal3 get kubeconfig e2etest >${BUILDDIR}/e2etest-admin.conf
66 chmod 600 ${BUILDDIR}/e2etest-admin.conf
67 wait_for is_control_plane_ready
68 insert_control_plane_network_identity_into_ssh_config
72 "build-source") build_source ;;
75 "wait") wait_for_all_ready ;;
77 Usage: $(basename $0) COMMAND
80 build-source - Rebuild the in-tree site files
81 clean - Remove the site
82 deploy - Deploy the site
83 wait - Wait for the site to be ready