Skip to content

Instantly share code, notes, and snippets.

@FahadBSyed
Created November 8, 2022 17:33
Show Gist options
  • Save FahadBSyed/20e1730b81917aeddbb0c0ce16bfef29 to your computer and use it in GitHub Desktop.
Save FahadBSyed/20e1730b81917aeddbb0c0ce16bfef29 to your computer and use it in GitHub Desktop.
nfs server one pod two containers
# Taken from: https://github.com/appscode/third-party-tools/blob/master/storage/nfs/README.md
apiVersion: apps/v1
kind: Deployment
metadata:
name: nfs-server
namespace: storage
spec:
selector:
matchLabels:
app: nfs-server
template:
metadata:
labels:
app: nfs-server
spec:
containers:
- name: nfs-server
image: k8s.gcr.io/volume-nfs:0.8
ports:
- name: nfs
containerPort: 2049
- name: mountd
containerPort: 20048
- name: rpcbind
containerPort: 111
securityContext:
privileged: true
volumeMounts:
- name: storage
mountPath: /exports
- name: busybox
image: busybox
command:
- sleep
- "3600"
volumeMounts:
- name: data
mountPath: /demo/data
volumes:
- name: storage
hostPath:
path: /data/nfs # store all data in "/data/nfs" directory of the node where it is running
type: DirectoryOrCreate # if the directory does not exist then create it
- name: data
nfs:
server: 10.96.204.162 # replace this with the real cluster IP after the service has been created.
path: "/nfs-direct" # "nfs-direct" folder must exist inside "/exports" directory of NFS server
---
apiVersion: v1
kind: Service
metadata:
name: nfs-service
spec:
ports:
- name: nfs
port: 2049
- name: mountd
port: 20048
- name: rpcbind
port: 111
selector:
app: nfs-server # must match with the label of NFS pod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment