Skip to content
This repository has been archived by the owner on Jul 7, 2020. It is now read-only.

Automatically create a dynamically provisioning StorageClass #484

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions deploy/gk-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -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 <TEMPLATES>] [-n NAMESPACE] [-w <SECONDS>]
Expand All @@ -57,7 +58,8 @@ usage() {
[--daemonset-label <DAEMONSET_LABEL> ] [--single-node] [--no-object]
[--object-account <ACCOUNT>] [--object-user <USER>]
[--object-password <PASSWORD>] [--object-sc <STORAGE_CLASS>]
[--object-capacity <CAPACITY>] [-l <LOG_FILE>] [--abort] [<TOPOLOGY>]\n"
[--object-capacity <CAPACITY>] [--storage-class <STORAGE_CLASS>]
[-l <LOG_FILE>] [--abort] [<TOPOLOGY>]\n"
}

help_exit() {
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 '<ADMIN_KEY>' cluster list
# ${CLI} exec -i ${heketi_pod} -- heketi-cli -s http://localhost:8080 --user admin --secret '<ADMIN_KEY>' 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
Expand All @@ -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 <<EOF >> "${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
Expand Down
8 changes: 8 additions & 0 deletions deploy/kube-templates/gluster-storageclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
name: ${STORAGE_CLASS}
provisioner: kubernetes.io/glusterfs
parameters:
resturl: "http://${HEKETI_URL}"