feat: simpler test workflow with configuration
This commit is contained in:
@@ -1,28 +1,31 @@
|
||||
#!/bin/bash
|
||||
# This creates a persistent volume and claim.
|
||||
# Params:
|
||||
# -p|--pv <pv-name> -c|--pvc <pvc-name> -s|--nfs-server <nfs-server> -n|--nfs-path <nfs-path>
|
||||
# pv-name - the name used for the persistent volume
|
||||
# pvc-name - the name used for the claim
|
||||
# -p|--pv <pv-name> -c|--pvc <pvc-name> -s|--nfs-server <nfs-server> -n|--nfs-path <nfs-path> -N|--namespace <name>
|
||||
# pv-name - the name used for the persistent volume
|
||||
# pvc-name - the name used for the claim
|
||||
# nfs-server - IP or hostname of the NFS server
|
||||
# nfs-path - Path on the NFS server
|
||||
# nfs-path - Path on the NFS server
|
||||
# namespace - Kubernetes namespace
|
||||
|
||||
PV_NAME=
|
||||
PVC_NAME=
|
||||
NFS_SERVER=
|
||||
NFS_PATH=
|
||||
SIZE=
|
||||
NAMESPACE=default
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Usage: provision-volume-claim.sh < -p | --pv-name name > < -c | --pvc-name name >
|
||||
< -n | --nfs-server server >
|
||||
< -m | --nfs-path path >
|
||||
< -s | --size size >"
|
||||
< -s | --size size >
|
||||
< -N | --namespace name >"
|
||||
exit 2
|
||||
}
|
||||
|
||||
PARSED_ARGUMENTS=$(getopt -a -n provision-volume-claim -o p:c:n:m:s: --long pv-name:,pvc-name:,nfs-server:,nfs-path:,size: -- "$@")
|
||||
PARSED_ARGUMENTS=$(getopt -a -n provision-volume-claim -o p:c:n:m:s:N: --long pv-name:,pvc-name:,nfs-server:,nfs-path:,size:,namespace: -- "$@")
|
||||
VALID_ARGUMENTS=$?
|
||||
if [ "$VALID_ARGUMENTS" != "0" ]; then
|
||||
usage
|
||||
@@ -37,6 +40,7 @@ do
|
||||
-n | --nfs-server) NFS_SERVER="$2" ; shift 2 ;;
|
||||
-m | --nfs-path) NFS_PATH="$2" ; shift 2 ;;
|
||||
-s | --size) SIZE="$2" ; shift 2 ;;
|
||||
-N | --namespace) NAMESPACE="$2" ; shift 2 ;;
|
||||
# -- means the end of the arguments; drop this, and break out of the while loop
|
||||
--) shift; break ;;
|
||||
*) echo "Unexpected option: $1 - this should not happen."
|
||||
@@ -69,7 +73,6 @@ spec:
|
||||
- ReadWriteMany
|
||||
persistentVolumeReclaimPolicy: Recycle
|
||||
storageClassName: slow
|
||||
|
||||
mountOptions:
|
||||
- hard
|
||||
- nfsvers=4.1
|
||||
@@ -88,6 +91,7 @@ apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: $PVC_NAME
|
||||
namespace: $NAMESPACE
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteMany
|
||||
@@ -106,7 +110,7 @@ cat $PVC_MANIFEST
|
||||
# Generate cleanup script
|
||||
cat > cleanup-volume-claim.sh << EOM
|
||||
#!/bin/bash
|
||||
kubectl delete pvc $PVC_NAME
|
||||
kubectl delete pvc $PVC_NAME -n $NAMESPACE
|
||||
kubectl delete pv $PV_NAME
|
||||
EOM
|
||||
chmod +x cleanup-volume-claim.sh
|
||||
|
||||
Reference in New Issue
Block a user