Skip to content

Instantly share code, notes, and snippets.

@hodrigohamalho
Created December 12, 2017 12:22
Show Gist options
  • Save hodrigohamalho/f05541f20d3ebb54d7031279d73f9515 to your computer and use it in GitHub Desktop.
Save hodrigohamalho/f05541f20d3ebb54d7031279d73f9515 to your computer and use it in GitHub Desktop.
lab01 - create pvs
# NFS Server Host - CHANGE the GUID!
HOST=support1.54d2.internal
ROOT_NFS=/exports
NFS_CONFIG_FILE=/etc/exports.d/openshift-ansible.exports
create-pv () {
DIR=$1
SIZE=$2
ACCESS_MODE=$3
RECLAIM_POLICY=$4
cont=$(oc get pv | grep "^$DIR " | wc -l)
if [ $cont -eq 0 ];then
oc create -f -<< EOF
apiVersion: v1
kind: PersistentVolume
metadata:
name: $DIR
spec:
capacity:
storage: ${SIZE}Gi
accessModes:
- $ACCESS_MODE
persistentVolumeReclaimPolicy: $RECLAIM_POLICY
nfs:
server: $HOST
path: $ROOT_NFS/$DIR
EOF
else
echo "PV already exists, skipping creation..."
fi
}
for i in {1..25};do
create-pv pv$i 5 ReadWriteOnce Recycle
done
for i in {26..50};do
create-pv pv$i 10 ReadWriteMany Retain
done
@ricardozanini
Copy link

ricardozanini commented Dec 12, 2017

create-pv: not a valid identifier

Please, change the function name from create-pv to createpv. 👍

@hodrigohamalho
Copy link
Author

it's weird...
I executed this on my lab and in the colleague lab and it works that way, Do you tried in a RHEL, right ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment