From a20da76a23c88f3673a0ee28b3ef3d91c836bfa8 Mon Sep 17 00:00:00 2001 From: Rob de Wit Date: Wed, 15 May 2019 11:13:37 +0200 Subject: [PATCH 1/3] Added option --load-balanced for running in GKE where master nodes are outside the node network. --- deploy/gk-deploy | 44 ++++++++++++++++++-- deploy/kube-templates/heketi-deployment.yaml | 1 + 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/deploy/gk-deploy b/deploy/gk-deploy index 8cf5b40e..cd5b26d1 100755 --- a/deploy/gk-deploy +++ b/deploy/gk-deploy @@ -27,6 +27,8 @@ TEMPLATES="" NAMESPACE="" WAIT=300 ABORT=0 +LOAD_BALANCED=0 +SERVICE_TYPE=ClusterIP NODES="" SKIP_PREREQ=0 EXISTS_GLUSTERFS=0 @@ -57,7 +59,7 @@ usage() { [--daemonset-label ] [--single-node] [--no-object] [--object-account ] [--object-user ] [--object-password ] [--object-sc ] - [--object-capacity ] [-l ] [--abort] []\n" + [--object-capacity ] [--load-balanced] [-l ] [--abort] []\n" } help_exit() { @@ -144,6 +146,10 @@ Options: The total capacity of the GlusterFS volume which will store the object data. Default is '${OBJ_CAPACITY}'. + --load-balanced + Produce a Kubernetes Service of type LoadBalancer (to be used in + GKE or environments where you want access from outside Kubernetes. + -y, --yes Skip the pre-requisites prompt. @@ -501,6 +507,11 @@ while [[ $# -ge 1 ]]; do ABORT=1 keypos=$keylen ;; + -load-balanced*) + LOAD_BALANCED=1 + SERVICE_TYPE=LoadBalancer + keypos=$keylen + ;; h*|-help) help_exit ;; @@ -570,6 +581,25 @@ Do you wish to proceed with deployment? esac fi +if [[ "x${USER_KEY}" == "x" ]] && [[ "${LOAD_BALANCED}" == "1" ]]; then + echo " +LoadBalancer service is selected, but no authentication creedntials have been +provided. It is generally a good idea to add authentication to a (public) +load balanced available Heketi API. + +Do you wish to proceed installing without credentials?" + + read -rp "[Y]es, [N]o? [Default: N]: " ynopt + case $ynopt in + Y*|y*) + echo "" + ;; + *) + exit + ;; + esac +fi + if [[ ! -f ${TOPOLOGY} ]]; then echo "Topology File not found!" exit 1 @@ -890,7 +920,7 @@ if [[ ${EXISTS_HEKETI} -eq 0 ]]; then if [[ "${CLI}" == *oc\ * ]]; then eval_output "${CLI} process ${OC_PROCESS_VAL_SWITCH} HEKETI_EXECUTOR=${EXECUTOR} ${OC_PROCESS_VAL_SWITCH} HEKETI_FSTAB=${FSTAB} ${OC_PROCESS_VAL_SWITCH} HEKETI_ADMIN_KEY=${ADMIN_KEY} ${OC_PROCESS_VAL_SWITCH} HEKETI_USER_KEY=${USER_KEY} heketi | ${CLI} create -f - 2>&1" else - eval_output "sed -e 's/\\\${HEKETI_EXECUTOR}/${EXECUTOR}/' -e 's#\\\${HEKETI_FSTAB}#${FSTAB}#' -e 's/\\\${HEKETI_ADMIN_KEY}/${ADMIN_KEY}/' -e 's/\\\${HEKETI_USER_KEY}/${USER_KEY}/' ${TEMPLATES}/heketi-deployment.yaml | ${CLI} create -f - 2>&1" + eval_output "sed -e 's/\\\${HEKETI_EXECUTOR}/${EXECUTOR}/' -e 's#\\\${HEKETI_FSTAB}#${FSTAB}#' -e 's/\\\${HEKETI_ADMIN_KEY}/${ADMIN_KEY}/' -e 's/\\\${HEKETI_USER_KEY}/${USER_KEY}/' -e 's/\\\${SERVICE_TYPE}/${SERVICE_TYPE}/' ${TEMPLATES}/heketi-deployment.yaml | ${CLI} create -f - 2>&1" fi output -n "Waiting for heketi pod to start ... " @@ -913,7 +943,15 @@ while [[ "x${heketi_service}" == "x" ]] || [[ "${heketi_service}" == "" ]] fi sleep 1 ((s+=1)) - heketi_service=$(${CLI} describe svc/heketi | grep "Endpoints:" | awk '{print $2}') + if [[ ${LOAD_BALANCED} -eq 1 ]]; then + heketi_lb_address=$(${CLI} describe svc/heketi | awk '/^LoadBalancer Ingress:/{print $NF}') + if [ "x${heketi_lb_address}" != "x" ]; then + heketi_port=$(${CLI} describe svc/heketi | awk '/^Port:/{print $NF}' | cut -d/ -f1) + heketi_service=${heketi_lb_address}:${heketi_port} + fi + else + heketi_service=$(${CLI} describe svc/deploy-heketi | grep "Endpoints:" | awk '{print $2}') + fi done heketi_pod=$(${CLI} get pod --no-headers --show-all --selector="heketi" | awk '{print $1}') diff --git a/deploy/kube-templates/heketi-deployment.yaml b/deploy/kube-templates/heketi-deployment.yaml index ecc6cefa..b2d709de 100644 --- a/deploy/kube-templates/heketi-deployment.yaml +++ b/deploy/kube-templates/heketi-deployment.yaml @@ -11,6 +11,7 @@ metadata: spec: selector: glusterfs: heketi-pod + type: ${SERVICE_TYPE} ports: - name: heketi port: 8080 From 79de4830abc36e3bcda9847c19a7239431a52940 Mon Sep 17 00:00:00 2001 From: Rob de Wit Date: Wed, 15 May 2019 11:14:43 +0200 Subject: [PATCH 2/3] Use --all to show completed jobs. --- deploy/gk-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/gk-deploy b/deploy/gk-deploy index cd5b26d1..fc03b404 100755 --- a/deploy/gk-deploy +++ b/deploy/gk-deploy @@ -346,7 +346,7 @@ check() { break fi sleep 2 - res=$(${CLI} get "${resource}" --no-headers "${select}" 2>/dev/null) + res=$(${CLI} get "${resource}" --all --no-headers "${select}" 2>/dev/null) if [[ ${s} -ne 0 ]] && [[ ${VERBOSE} -eq 1 ]]; then reslines=$(echo "$res" | wc -l) ((reslines+=1)) From 2d846bc57af2d441968de5e18da7152ac955d8a7 Mon Sep 17 00:00:00 2001 From: Rob de Wit Date: Wed, 15 May 2019 11:29:59 +0200 Subject: [PATCH 3/3] Update gk-deploy --all should be -a (or --show-all) --- deploy/gk-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/gk-deploy b/deploy/gk-deploy index fc03b404..ed8ae5c8 100755 --- a/deploy/gk-deploy +++ b/deploy/gk-deploy @@ -346,7 +346,7 @@ check() { break fi sleep 2 - res=$(${CLI} get "${resource}" --all --no-headers "${select}" 2>/dev/null) + res=$(${CLI} get "${resource}" -a --no-headers "${select}" 2>/dev/null) if [[ ${s} -ne 0 ]] && [[ ${VERBOSE} -eq 1 ]]; then reslines=$(echo "$res" | wc -l) ((reslines+=1))