forked from docc-lab/dsb_k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup NFS by default, for use by kubernetes persistent volumes.
- Loading branch information
1 parent
d50a2cd
commit 2b01a86
Showing
6 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
|
||
if [ -z "$EUID" ]; then | ||
EUID=`id -u` | ||
fi | ||
|
||
# Grab our libs | ||
. "`dirname $0`/setup-lib.sh" | ||
|
||
if [ -f $OURDIR/nfs-client-done ]; then | ||
exit 0 | ||
fi | ||
|
||
logtstart "nfs-client" | ||
|
||
if [ -f $SETTINGS ]; then | ||
. $SETTINGS | ||
fi | ||
if [ -f $LOCALSETTINGS ]; then | ||
. $LOCALSETTINGS | ||
fi | ||
|
||
maybe_install_packages nfs-common | ||
service_enable rpcbind | ||
service_start rpcbind | ||
|
||
dataip=`getnodeip $HEAD $DATALAN` | ||
prefix=`getnetmaskprefix $DATALAN` | ||
|
||
while ! (rpcinfo -s $dataip | grep -q nfs); do | ||
echo "Waiting for NFS server $dataip..." | ||
sleep 10 | ||
done | ||
|
||
$SUDO mkdir -p $NFSMOUNTDIR | ||
$SUDO chmod 755 $NFSMOUNTDIR | ||
echo "$dataip:$NFSEXPORTDIR $NFSMOUNTDIR nfs rw,bg,sync,hard,intr 0 0" | $SUDO tee -a /etc/fstab | ||
while ! $SUDO mount $NFSMOUNTDIR ; do | ||
echo "Mounting $dataip:$NFSEXPORTDIR..." | ||
sleep 10 | ||
done | ||
|
||
logtend "nfs-client" | ||
|
||
touch $OURDIR/nfs-client-done |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
|
||
if [ -z "$EUID" ]; then | ||
EUID=`id -u` | ||
fi | ||
|
||
# Grab our libs | ||
. "`dirname $0`/setup-lib.sh" | ||
|
||
if [ -f $OURDIR/nfs-server-done ]; then | ||
exit 0 | ||
fi | ||
|
||
logtstart "nfs-server" | ||
|
||
if [ -f $SETTINGS ]; then | ||
. $SETTINGS | ||
fi | ||
if [ -f $LOCALSETTINGS ]; then | ||
. $LOCALSETTINGS | ||
fi | ||
|
||
maybe_install_packages nfs-kernel-server | ||
service_stop nfs-kernel-server | ||
|
||
$SUDO mkdir -p $NFSEXPORTDIR | ||
$SUDO chmod 755 $NFSEXPORTDIR | ||
|
||
dataip=`getnodeip $HEAD $DATALAN` | ||
prefix=`getnetmaskprefix $DATALAN` | ||
networkip=`getnetworkip $HEAD $DATALAN` | ||
|
||
echo "$NFSEXPORTDIR $networkip/$prefix(rw,sync,no_root_squash,no_subtree_check,fsid=0)" | $SUDO tee -a /etc/exports | ||
|
||
echo "OPTIONS=\"-l -h 127.0.0.1 -h $dataip\"" | $SUDO tee /etc/default/rpcbind | ||
$SUDO sed -i.bak -e "s/^rpcbind/#rpcbind/" /etc/hosts.deny | ||
echo "rpcbind: ALL EXCEPT 127.0.0.1, $networkip/$prefix" | $SUDO tee -a /etc/hosts.deny | ||
|
||
service_enable rpcbind | ||
service_restart rpcbind | ||
service_enable nfs-kernel-server | ||
service_restart nfs-kernel-server | ||
|
||
$SUDO mkdir -p $NFSMOUNTDIR | ||
$SUDO chmod 755 $NFSMOUNTDIR | ||
echo "$NFSEXPORTDIR $NFSMOUNTDIR none defaults,bind 0 0" | $SUDO tee -a /etc/fstab | ||
$SUDO mount $NFSMOUNTDIR | ||
|
||
logtend "nfs-server" | ||
|
||
touch $OURDIR/nfs-server-done |