Skip to content

Instantly share code, notes, and snippets.

@janeczku
Last active February 2, 2024 15:04
Show Gist options
  • Save janeczku/d1f3b65c67032424ef0ceaa2b95540e0 to your computer and use it in GitHub Desktop.
Save janeczku/d1f3b65c67032424ef0ceaa2b95540e0 to your computer and use it in GitHub Desktop.
User-space NFS Server for deployment in Kubernetes (Note: NFSv4 only, non-standard NFS port 32049/tcp)

Usage

  1. Deploy NFS server to a K8s cluster
kubectl apply -f https://t.ly/m-flt
  1. In the same or a different cluster create a NFS backup target in Longhorn:
    a) Navigate to Longhorn UI -> Settings -> General -> Backup target
    b) Enter the following URL, replacing <Cluster_Node_IP> with the IP address of any node of the K8s cluster running the NFS server, then click 'Save':
nfs://<Cluster_Node_IP>:/?nfsOptions=actimeo=1,soft,timeo=330,retry=2,port=32049
  1. Create a volume backup and navigate to list of Backups in the Longhorn UI
apiVersion: v1
kind: Namespace
metadata:
name: nfs-ganesha
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nfs-ganesha
name: nfs-ganesha
namespace: nfs-ganesha
spec:
replicas: 1
selector:
matchLabels:
app: nfs-ganesha
template:
metadata:
labels:
app: nfs-ganesha
namespace: nfs-ganesha
spec:
containers:
- image: janeczku/nfs-ganesha
imagePullPolicy: Always
name: container-0
ports:
- containerPort: 2049
name: nfsv4
protocol: TCP
securityContext:
capabilities:
add:
- NET_ADMIN
- DAC_READ_SEARCH
privileged: true
volumeMounts:
- mountPath: /data/nfs
name: share
dnsPolicy: ClusterFirst
restartPolicy: Always
volumes:
- emptyDir: {}
name: share
---
apiVersion: v1
kind: Service
metadata:
name: nfs-ganesha-nodeport
namespace: nfs-ganesha
spec:
ports:
- name: nfsv4
nodePort: 32049
port: 2049
protocol: TCP
targetPort: 2049
selector:
app: nfs-ganesha
type: NodePort
---
apiVersion: v1
kind: Service
metadata:
name: nfs-ganesha
namespace: nfs-ganesha
spec:
ports:
- name: nfsv4
port: 2049
protocol: TCP
targetPort: 2049
selector:
app: nfs-ganesha
type: ClusterIP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment