Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ed46c4db
Commit
ed46c4db
authored
Apr 02, 2015
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add NFS export/import pod examples.
parent
a94ffc86
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
192 additions
and
21 deletions
+192
-21
README.md
examples/nfs/README.md
+37
-0
Dockerfile
examples/nfs/exporter/Dockerfile
+8
-0
README.md
examples/nfs/exporter/README.md
+10
-0
run_nfs
examples/nfs/exporter/run_nfs
+72
-0
Dockerfile
examples/nfs/nfs-data/Dockerfile
+5
-0
README.md
examples/nfs/nfs-data/README.md
+8
-0
index.html
examples/nfs/nfs-data/index.html
+1
-0
nfs-server-pod.yaml
examples/nfs/nfs-server-pod.yaml
+15
-0
nfs-server-service.yaml
examples/nfs/nfs-server-service.yaml
+9
-0
nfs-web-pod.yaml
examples/nfs/nfs-web-pod.yaml
+27
-0
test.yaml
examples/nfs/test.yaml
+0
-21
No files found.
examples/nfs/README.md
0 → 100644
View file @
ed46c4db
# Example of NFS volume
See
[
nfs-web-pod.yaml
](
nfs-web-pod.yaml
)
for a quick example, how to use NFS volume
in a pod.
## Complete setup
The example below shows how to export a NFS share from a pod and import it
into another one.
### NFS server part
Define
[
NFS server pod
](
nfs-server-pod.yaml
)
and
[
NFS service
](
nfs-server-service.yaml
)
:
$ kubectl create -f nfs-server-pod.yaml
$ kubectl create -f nfs-server-service.yaml
The server exports
`/mnt/data`
directory as
`/`
(fsid=0). The directory contains
dummy
`index.html`
. Wait until the pod is running!
### NFS client
[
WEB server pod
](
nfs-web-pod.yaml
)
uses the NFS share exported above as a NFS
volume and runs simple web server on it. The pod assumes your DNS is configured
and the NFS service is reachable as
`nfs-server.default.kube.local`
. Edit the
yaml file to supply another name or directly its IP address (use
`kubectl get services`
to get it).
Define the pod:
$ kubectl create -f nfs-web-pod.yaml
Now the pod serves
`index.html`
from the NFS server:
$ curl http://<the container IP address>/
Hello World!
examples/nfs/exporter/Dockerfile
0 → 100644
View file @
ed46c4db
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"]
\ No newline at end of file
examples/nfs/exporter/README.md
0 → 100644
View file @
ed46c4db
# 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 ...
examples/nfs/exporter/run_nfs
0 → 100755
View file @
ed46c4db
#!/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
examples/nfs/nfs-data/Dockerfile
0 → 100644
View file @
ed46c4db
FROM
jsafrane/nfsexporter
MAINTAINER
Jan Safranek <jsafrane@redhat.com>
ADD
index.html /mnt/data/index.html
ENTRYPOINT
["/usr/local/bin/run_nfs", "/mnt/data"]
examples/nfs/nfs-data/README.md
0 → 100644
View file @
ed46c4db
# NFS-exporter container with a file
This container exports /mnt/data with index.html in it via NFSv4. Based on
../exporter.
Available in dockerhub as
[
jsafrane/nfs-data
](
https://registry.hub.docker.com/u/jsafrane/nfs-data/
)
.
\ No newline at end of file
examples/nfs/nfs-data/index.html
0 → 100644
View file @
ed46c4db
Hello world!
examples/nfs/nfs-server-pod.yaml
0 → 100644
View file @
ed46c4db
apiVersion
:
v1beta3
kind
:
Pod
metadata
:
name
:
nfs-server
labels
:
role
:
nfs-server
spec
:
containers
:
-
name
:
nfs-server
image
:
jsafrane/nfs-data
privileged
:
true
ports
:
-
name
:
nfs
containerPort
:
2049
protocol
:
tcp
examples/nfs/nfs-server-service.yaml
0 → 100644
View file @
ed46c4db
kind
:
Service
apiVersion
:
v1beta3
metadata
:
name
:
nfs-server
spec
:
ports
:
-
port
:
2049
selector
:
role
:
nfs-server
examples/nfs/nfs-web-pod.yaml
0 → 100644
View file @
ed46c4db
#
# This pod imports nfs-server.default.kube.local:/ into /var/www/html
#
apiVersion
:
v1beta3
kind
:
Pod
metadata
:
name
:
nfs-web
spec
:
containers
:
-
name
:
web
image
:
dockerfile/nginx
ports
:
-
name
:
web
containerPort
:
80
protocol
:
tcp
volumeMounts
:
# name must match the volume name below
-
name
:
nfs
mountPath
:
"
/var/www/html"
volumes
:
-
name
:
nfs
nfs
:
# FIXME: use the right hostname
server
:
nfs-server.default.kube.local
path
:
"
/"
readOnly
:
false
examples/nfs/test.yaml
deleted
100644 → 0
View file @
a94ffc86
apiVersion
:
v1beta1
desiredState
:
manifest
:
containers
:
-
name
:
testpd
image
:
dockerfile/nginx
volumeMounts
:
# name must match the volume name below
-
name
:
myshare
mountPath
:
"
/var/www/html/mount-test"
id
:
nfspd
version
:
v1beta1
volumes
:
-
name
:
myshare
source
:
nfs
:
server
:
"
172.17.0.2"
path
:
"
/tmp"
readOnly
:
false
id
:
nfspd
kind
:
Pod
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment