mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
Add NFS export/import pod examples.
This commit is contained in:
7
examples/nfs/exporter/Dockerfile
Normal file
7
examples/nfs/exporter/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM fedora:21
|
||||
MAINTAINER Jan Safranek <jsafrane@redhat.com>
|
||||
EXPOSE 2049/tcp
|
||||
|
||||
RUN yum -y install nfs-utils && yum clean all && run_nfs /usr/local/bin/run_nfs
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/run_nfs"]
|
||||
10
examples/nfs/exporter/README.md
Normal file
10
examples/nfs/exporter/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# NFS-exporter container
|
||||
|
||||
Inspired by https://github.com/cpuguy83/docker-nfs-server. Rewritten for
|
||||
Fedora.
|
||||
|
||||
Serves NFS4 exports, defined on command line. At least one export must be defined!
|
||||
|
||||
Usage::
|
||||
|
||||
docker run -d --name nfs --privileged jsafrane/nfsexporter /path/to/share /path/to/share2 ...
|
||||
72
examples/nfs/exporter/run_nfs
Executable file
72
examples/nfs/exporter/run_nfs
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015 Red Hat Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
function start()
|
||||
{
|
||||
|
||||
# prepare /etc/exports
|
||||
seq=0
|
||||
for i in "$@"; do
|
||||
echo "$i *(rw,sync,no_root_squash,insecure,fsid=$seq)" >> /etc/exports
|
||||
seq=$(($seq + 1))
|
||||
echo "Serving $i"
|
||||
done
|
||||
|
||||
# from /lib/systemd/system/proc-fs-nfsd.mount
|
||||
mount -t nfsd nfds /proc/fs/nfsd
|
||||
|
||||
# from /lib/systemd/system/nfs-config.service
|
||||
/usr/lib/systemd/scripts/nfs-utils_env.sh
|
||||
|
||||
# from /lib/systemd/system/nfs-mountd.service
|
||||
. /run/sysconfig/nfs-utils
|
||||
/usr/sbin/rpc.mountd $RPCMOUNTDARGS
|
||||
|
||||
# from /lib/systemd/system/nfs-server.service
|
||||
. /run/sysconfig/nfs-utils
|
||||
/usr/sbin/exportfs -r
|
||||
/usr/sbin/rpc.nfsd -N 2 -N 3 -V 4 -V 4.1 $RPCNFSDARGS
|
||||
|
||||
echo "NFS started"
|
||||
}
|
||||
|
||||
function stop()
|
||||
{
|
||||
echo "Stopping NFS"
|
||||
|
||||
# from /lib/systemd/system/nfs-server.service
|
||||
/usr/sbin/rpc.nfsd 0
|
||||
/usr/sbin/exportfs -au
|
||||
/usr/sbin/exportfs -f
|
||||
|
||||
# from /lib/systemd/system/nfs-mountd.service
|
||||
kill $( pidof rpc.mountd )
|
||||
# from /lib/systemd/system/proc-fs-nfsd.mount
|
||||
umount /proc/fs/nfsd
|
||||
|
||||
echo > /etc/exports
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
trap stop TERM
|
||||
|
||||
start "$@"
|
||||
|
||||
# Ugly hack to do nothing and wait for SIGTERM
|
||||
while true; do
|
||||
read
|
||||
done
|
||||
Reference in New Issue
Block a user