diff --git a/deploy/gk-deploy b/deploy/gk-deploy index 625961c9..5cec63ec 100755 --- a/deploy/gk-deploy +++ b/deploy/gk-deploy @@ -49,6 +49,7 @@ OBJ_USER="" OBJ_PASSWORD="" OBJ_STORAGE_CLASS="glusterfs-for-s3" OBJ_CAPACITY="2Gi" +STORAGE_CLASS="glusterfs" usage() { echo -e "USAGE: ${PROG} [-ghvy] [-c CLI] [-t ] [-n NAMESPACE] [-w ] @@ -57,7 +58,8 @@ usage() { [--daemonset-label ] [--single-node] [--no-object] [--object-account ] [--object-user ] [--object-password ] [--object-sc ] - [--object-capacity ] [-l ] [--abort] []\n" + [--object-capacity ] [--storage-class ] + [-l ] [--abort] []\n" } help_exit() { @@ -144,6 +146,11 @@ Options: The total capacity of the GlusterFS volume which will store the object data. Default is '${OBJ_CAPACITY}'. + --storage-class STORAGE_CLASS + Create a dynamicly provisioned StorageClass. + Default is to create a new StorageClass called '${STORAGE_CLASS}' + if no STORAGE_CLASS name is provided. + -y, --yes Skip the pre-requisites prompt. @@ -497,6 +504,11 @@ while [[ $# -ge 1 ]]; do if [[ $? -eq 2 ]]; then shift; fi keypos=$keylen ;; + -storage-class*) + STORAGE_CLASS=$(assign "${key:${keypos}}" "${2}") + if [[ $? -eq 2 ]]; then shift; fi + keypos=$keylen + ;; -abort) ABORT=1 keypos=$keylen @@ -942,10 +954,11 @@ administrative commands you can install 'heketi-cli' and use it as follows: You can find it at https://github.com/heketi/heketi/releases . Alternatively, use it from within the heketi pod: - # ${CLI} exec -i ${heketi_pod} -- heketi-cli -s http://localhost:8080 --user admin --secret '' cluster list + # ${CLI} exec -i ${heketi_pod} -- heketi-cli -s http://localhost:8080 --user admin --secret '' cluster list" -For dynamic provisioning, create a StorageClass similar to this: +if [[ "x${STORAGE_CLASS}" != "x" ]]; then +output "For dynamic provisioning, create a StorageClass similar to this: --- apiVersion: storage.k8s.io/v1beta1 kind: StorageClass @@ -958,9 +971,22 @@ parameters: output " restuser: \"user\" restuserkey: \"${USER_KEY}\"" fi +fi output "" fi +if [[ "x${STORAGE_CLASS}" != "x" ]]; then + if [[ "x${ADMIN_KEY}" != "x" ]]; then + # REST API Security is enabled - Append "restuser" and "restuserkey" to the StorageClass yaml +cat <> "${TEMPLATES}"/gluster-storageclass.yaml + restuser: "admin" + restuserkey: "${ADMIN_KEY}" +EOF + eval_output "sed -e 's/\\\${STORAGE_CLASS}/${STORAGE_CLASS}/' -e 's/\\\${HEKETI_URL}/${heketi_service}/' -e 's/\\\${NAMESPACE}/${NAMESPACE}/' ${TEMPLATES}/gluster-storageclass.yaml | ${CLI} create -f - 2>&1" + else + eval_output "sed -e 's/\\\${STORAGE_CLASS}/${STORAGE_CLASS}/' -e 's/\\\${HEKETI_URL}/${heketi_service}/' -e 's/\\\${NAMESPACE}/${NAMESPACE}/' ${TEMPLATES}/gluster-storageclass.yaml | ${CLI} create -f - 2>&1" + fi +fi if [[ ${DEPLOY_OBJECT} -eq 1 ]] && [[ "${OBJ_ACCOUNT}" != "" ]] && [[ "${OBJ_USER}" != "" ]] && [[ "${OBJ_PASSWORD}" != "" ]] && [[ ${EXISTS_OBJECT} -eq 0 ]]; then if [[ "${OBJ_STORAGE_CLASS}" == "glusterfs-for-s3" ]]; then diff --git a/deploy/kube-templates/gluster-storageclass.yaml b/deploy/kube-templates/gluster-storageclass.yaml new file mode 100644 index 00000000..f92a65b9 --- /dev/null +++ b/deploy/kube-templates/gluster-storageclass.yaml @@ -0,0 +1,8 @@ +--- +kind: StorageClass +apiVersion: storage.k8s.io/v1beta1 +metadata: + name: ${STORAGE_CLASS} +provisioner: kubernetes.io/glusterfs +parameters: + resturl: "http://${HEKETI_URL}"