4 SCRIPTDIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
5 LIBDIR="$(dirname $(dirname $(dirname ${SCRIPTDIR})))/env/lib"
7 source $LIBDIR/common.sh
9 BUILDDIR=${SCRIPTDIR/deploy/build}
13 SSH_AUTHORIZED_KEY=$(cat ${HOME}/.ssh/id_rsa.pub)
14 # Use ! instead of usual / to avoid escaping / in
16 sed -e 's!sshAuthorizedKey: .*!sshAuthorizedKey: '"${SSH_AUTHORIZED_KEY}"'!' ${SCRIPTDIR}/clusters-values.yaml >${BUILDDIR}/clusters-values.yaml
20 helm -n metal3 install machines ${SCRIPTDIR}/../../machines --create-namespace -f ${BUILDDIR}/machines-values.yaml
21 helm -n metal3 install clusters ${SCRIPTDIR}/../../clusters --create-namespace -f ${BUILDDIR}/clusters-values.yaml
25 helm -n metal3 uninstall clusters
26 helm -n metal3 uninstall machines
29 function is_cluster_ready {
30 [[ $(kubectl -n metal3 get cluster e2etest -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}') == "True" ]]
33 function are_kustomizations_ready {
34 [[ $(kubectl --kubeconfig=${BUILDDIR}/e2etest-admin.conf get Kustomization -n flux-system -o jsonpath='{range .items[*]}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}' | grep -c -v True) == 0 ]]
37 function are_helmreleases_ready {
38 [[ $(kubectl --kubeconfig=${BUILDDIR}/e2etest-admin.conf get HelmRelease -n flux-system -o jsonpath='{range .items[*]}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}' | grep -c -v True) == 0 ]]
41 function wait_for_all_ready {
43 wait_for is_cluster_ready
44 clusterctl -n metal3 get kubeconfig e2etest >${BUILDDIR}/e2etest-admin.conf
45 chmod 600 ${BUILDDIR}/e2etest-admin.conf
46 # TODO The following checks are not ideal: resources created by
47 # operators aren't detected here, but this is the best that can be
50 wait_for are_kustomizations_ready
51 wait_for are_helmreleases_ready
58 "wait") wait_for_all_ready ;;
60 Usage: $(basename $0) COMMAND
63 build - Build the site deployment values
64 clean - Remove the site
65 deploy - Deploy the site
66 wait - Wait for the site to be ready