Last active
November 14, 2017 17:18
-
-
Save dwojciec/6ade592a21c8b4fff810e3bfc85fc1f4 to your computer and use it in GitHub Desktop.
pv creation for openshift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on the bastion host : | |
* Create 100 directory exports as persistent volumes: | |
mkdir -p /var/export/pvs/pv{1..100} | |
chown -R nfsnobody:nfsnobody /var/export/pvs/ | |
chmod -R 700 /var/export/pvs/ | |
* add a line for each export directory to /et/exports | |
for volume in pv{1..100} ; do echo Creating export for volume $volume; echo "/var/export/pvs/${volume} 192.168.0.0/24(rw,sync,all_squash)" >> /etc/exports; done; | |
* enable and start nfs services: | |
systemctl enable rpcbind nfs-server | |
systemctl start rpcbind nfs-server nfs-lock nfs-idmap | |
systemctl stop firewalld | |
systemctl disable firewalld | |
* Run the following to allow containers to write to NFS-mounted directories on all the nodes where the pod could land (that is, all of them): | |
for node in hdbsalx00004 hdbsalx00005 hdbsalx00006 hdbsalx00007 hdbsalx00008 hdbsalx00009; | |
do echo "Setting SElinux Policy on $node " ; ssh $node " setsebool -P virt_use_nfs=true;" | |
done | |
* To ensure NFS access, connect to a node a and verify that you can mount a volume from the bastion | |
ssh hdbsalx00005 | |
mkdir /tmp/test | |
mount -v bastion:/var/export/pvs/pv98 /tmp/test | |
umount /tmp/test | |
Create Definition Files for Volumes | |
* create directory to host pv and pvc definition | |
mkdir /root/pvs | |
* create 25 instances of PV (pv1 to pv25) with a size of 5GB | |
$ cat pvtype1.sh | |
export volsize="5Gi"; | |
export SERVERNAME="192.168.0.254" | |
export NFS_PATH="/var/export/pvs" | |
export LOCAL_PATH="/root/pvs" | |
for volume in pv{1..25} ; do cat << EOF > $LOCAL_PATH/${volume} | |
{ "apiVersion": "v1", | |
"kind": "PersistentVolume", | |
"metadata": | |
{ "name": "${volume}" }, | |
"spec": { | |
"capacity": { "storage": "${volsize}" }, | |
"accessModes": [ "ReadWriteOnce" ], | |
"nfs": { "path": $NFS_PATH/${volume}", | |
"server": $SERVERNAME }, | |
"persistentVolumeReclaimPolicy": "Recycle" }} | |
EOF | |
echo "Created def file for ${volume}"; done; | |
* Create 25 more instances of PersistentVolume (pv26 to pv50) with a size of 10 GB: | |
$ cat pvtype2.sh | |
export volsize="10Gi"; | |
export SERVERNAME="192.168.0.254" | |
export NFS_PATH="/var/export/pvs" | |
export LOCAL_PATH="/root/pvs" | |
for volume in pv{26..50} ; do cat << EOF > $LOCAL_PATH/${volume} | |
{ "apiVersion": "v1", | |
"kind": "PersistentVolume", | |
"metadata": | |
{ "name": "${volume}" }, | |
"spec": { | |
"capacity": { "storage": "${volsize}" }, | |
"accessModes": [ "ReadWriteOnce" ], | |
"nfs": { "path": $NFS_PATH/${volume}", | |
"server": $SERVERNAME }, | |
"persistentVolumeReclaimPolicy": "Recycle" }} | |
EOF | |
echo "Created def file for ${volume}"; done; | |
* Create 50 more instances of PersistentVolume (pv51 to pv100) with a size of 1 GB: | |
$ cat pvtype3.sh | |
export volsize="1Gi"; | |
export SERVERNAME="192.168.0.254" | |
export NFS_PATH="/var/export/pvs" | |
export LOCAL_PATH="/root/pvs" | |
for volume in pv{51..100} ; do cat << EOF > $LOCAL_PATH/${volume} | |
{ "apiVersion": "v1", | |
"kind": "PersistentVolume", | |
"metadata": | |
{ "name": "${volume}" }, | |
"spec": { | |
"capacity": { "storage": "${volsize}" }, | |
"accessModes": [ "ReadWriteOnce" ], | |
"nfs": { "path": $NFS_PATH/${volume}", | |
"server": $SERVERNAME }, | |
"persistentVolumeReclaimPolicy": "Recycle" }} | |
EOF | |
echo "Created def file for ${volume}"; done; | |
* Allocate three of the 5-GB volumes--pv21, pv22, and pv23--to the default project: | |
cd /root/pvs | |
cat pv21 pv22 pv23 | oc create -f - -n default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment