HUB
Sign inSign up
nfs-server logo

boyroywax/nfs-server

By boyroywax

β€’Updated about 1 year ago

A lightweight, secure NFS server built on Alpine Linux.

Image
Databases & storage
0

2.4K

boyroywax/nfs-server repository overview

⁠Alpine NFS Server for Kubernetes

Docker Hub Docker Scout License: MIT

A lightweight, secure NFS server built on Alpine Linux, designed for Kubernetes environments with modular model storage architecture. Perfect for AI/ML workloads, microservices shared storage, and cloud-native applications.

Now available in two optimized variants:

  • Standard (v1.0.2) - 62.8 MB - Full features with NFSv4 support
  • Slim (v1.0.2-slim) - 22.7 MB - Ultra-lightweight NFSv3 (67% smaller!)

β πŸš€ Features

  • πŸ”οΈ Alpine Linux 3.22 - Minimal, secure base image
  • πŸ”’ Security Hardened - Non-root user, minimal attack surface, Docker Scout verified
  • ⚑ High Performance - NFSv3/NFSv4 support with optimized configuration
  • 🐳 Kubernetes Ready - Purpose-built for containerized deployments
  • πŸ“¦ Modular Design - One NFS server per model/dataset for easy scaling
  • πŸ›‘οΈ Enterprise Ready - Health checks, graceful shutdown, comprehensive logging
  • πŸ”§ Configurable - Environment-driven configuration for maximum flexibility
  • πŸ“‰ Size Optimized - Choose between standard (62.8 MB) or slim (22.7 MB) variants

β πŸ“‹ Table of Contents

⁠🎯 Variants

Choose the right variant for your needs:

VariantTagSizePythonNFSv4KerberosBest For
Standard1.0.262.8 MBβœ… Yesβœ… Yesβœ… YesProduction, enterprise, full features
Slim1.0.2-slim22.7 MB❌ No❌ No (v3 only)❌ NoEdge, IoT, CI/CD, size-critical
  • Full NFSv3/NFSv4 support
  • Kerberos/GSS authentication
  • Python tools (nfsiostat, etc.)
  • 8.5% smaller than v1.0.1
  • POSIX shell scripts
⁠Slim Variant
  • 67% smaller than v1.0.1
  • NFSv3 only (no v4)
  • No Python (built from source)
  • No Kerberos (basic auth)
  • Perfect for size-critical deployments

⁠⚑ Quick Start

⁠Standard Version (Default)
⁠Docker Run
# Basic NFS server with full features
docker run -d 
  --name nfs-server 
  --privileged 
  -e SHARE_NAME=mydata 
  -e CLIENT_CIDR=10.0.0.0/8 
  -p 2049:2049 
  -p 20048:20048 
  -p 111:111 
  -v /path/to/data:/nfsshare/data 
  boyroywax/nfs-server:1.0.2
⁠Docker Compose
version: '3.8'
services:
  nfs-server:
    image: boyroywax/nfs-server:1.0.2
    privileged: true
    environment:
      - SHARE_NAME=mydata
      - CLIENT_CIDR=10.0.0.0/8
    ports:
      - "2049:2049"
      - "20048:20048"
      - "111:111"
    volumes:
      - /path/to/data:/nfsshare/data
⁠Slim Variant (Lightweight)
# Ultra-lightweight NFS server (NFSv3 only)
docker run -d 
  --name nfs-server-slim 
  --privileged 
  -e SHARE_NAME=mydata 
  -e CLIENT_CIDR=10.0.0.0/8 
  -p 2049:2049 
  -p 20048:20048 
  -p 111:111 
  -v /path/to/data:/nfsshare/data 
  boyroywax/nfs-server:1.0.2-slim

⁠☸️ Kubernetes Deployment

⁠Prerequisites
  • Kubernetes cluster with privileged pod support
  • kubectl configured and connected to your cluster
⁠Quick Deploy
# Deploy to default namespace
kubectl apply -f https://raw.githubusercontent.com/boyroywax/nfs-server/main/examples/deployment.yaml

# Deploy to specific namespace
kubectl apply -f https://raw.githubusercontent.com/boyroywax/nfs-server/main/examples/deployment.yaml -n your-namespace
⁠Custom Deployment
  1. Clone the repository:

    git clone https://github.com/boyroywax/nfs-server.git
    cd nfs-server
    
  2. Customize the deployment:

    # Edit the deployment configuration
    cp examples/deployment.yaml my-nfs-deployment.yaml
    # Modify as needed...
    
  3. Deploy:

    kubectl apply -f my-nfs-deployment.yaml
    
⁠Using with Persistent Volumes
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: nfs-server.default.svc.cluster.local
    path: "/"
  mountOptions:
    - nfsvers=4.1
    - proto=tcp
    - hard
    - intr

β βš™οΈ Configuration

⁠Environment Variables
VariableDefaultDescription
SHARE_NAMEdefault-shareNFS share identifier for logging and management
EXPORT_PATH/nfsshare/dataPath to export via NFS
CLIENT_CIDR10.0.0.0/8,172.16.0.0/12,192.168.0.0/16Comma-separated list of allowed client networks
NFS_OPTIONSrw,sync,no_subtree_check,no_root_squash,insecureNFS export options
TZUTCTimezone for logging
⁠NFS Export Options
  • rw - Read-write access
  • sync - Synchronous writes (safer but slower)
  • no_subtree_check - Disable subtree checking for better performance
  • no_root_squash - Allow root access from clients
  • insecure - Allow connections from ports > 1024
⁠Security Considerations

For production environments, consider:

  • Using root_squash instead of no_root_squash
  • Restricting CLIENT_CIDR to specific networks
  • Using NFSv4 with Kerberos authentication
  • Implementing network policies in Kubernetes

⁠🎯 Use Cases

⁠AI/ML Model Storage

Perfect for serving large language models (LLaMA, Ollama, etc.) across multiple inference pods:

# Example: Shared model storage for Ollama
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ollama-llama32-1b
spec:
  replicas: 3
  template:
    spec:
      containers:
      - name: ollama
        image: ollama/ollama:latest
        volumeMounts:
        - name: models
          mountPath: /models
      volumes:
      - name: models
        nfs:
          server: nfs-server.default.svc.cluster.local
          path: "/"
⁠Microservices Shared Storage

Enable multiple services to share configuration, assets, or temporary files:

# Shared uploads directory
volumes:
- name: shared-uploads
  nfs:
    server: nfs-server.uploads.svc.cluster.local
    path: "/"
⁠Development Environment

Quick shared storage for development teams:

# Local development with docker-compose
docker-compose -f examples/docker-compose.dev.yaml up -d

β πŸ”’ Security

⁠Container Security
  • Non-root default user (nfsuser:1001)
  • Minimal Alpine base with only required packages
  • Regular security updates via automated builds
  • Docker Scout verified with no high/critical vulnerabilities
⁠Network Security
  • Configurable client access via CIDR blocks
  • Standard NFS ports (2049, 111, 20048)
  • Optional encryption (NFSv4 with Kerberos)
⁠Kubernetes Security
  • SecurityContext configured for least privilege
  • Resource limits to prevent resource exhaustion
  • Health checks for automatic recovery

β πŸ“š Examples

The examples/ directory contains various deployment scenarios:

β πŸ”§ Troubleshooting

⁠Common Issues

Pod not starting:

# Check if the namespace allows privileged containers
kubectl describe pod <pod-name>

# Check events
kubectl get events --sort-by='.lastTimestamp'

Mount failures:

# Test NFS connectivity from a debug pod
kubectl run -it --rm debug --image=busybox --restart=Never -- sh
# Inside the pod:
apk add nfs-utils
showmount -e <nfs-server-ip>

Permission denied:

# Check export configuration
kubectl exec <nfs-pod> -- cat /etc/exports
kubectl exec <nfs-pod> -- showmount -e localhost
⁠Performance Tuning

For high-throughput workloads:

env:
- name: NFS_OPTIONS
  value: "rw,async,no_subtree_check,no_root_squash,insecure"

For safety-critical workloads:

env:
- name: NFS_OPTIONS
  value: "rw,sync,subtree_check,root_squash,secure"

β πŸ“ˆ Monitoring

⁠Health Checks

The container includes built-in health checks:

  • Startup probe - Ensures NFS service starts correctly
  • Liveness probe - Monitors ongoing NFS service health
  • Readiness probe - Indicates when ready to serve traffic
⁠Logs
# View NFS server logs
kubectl logs -f <nfs-pod-name>

# View export status
kubectl exec <nfs-pod> -- showmount -e localhost
⁠Metrics

Consider integrating with:

  • Prometheus - For metrics collection
  • Grafana - For dashboards
  • AlertManager - For alerting

⁠🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

⁠Development Setup
  1. Clone the repository:

    git clone https://github.com/boyroywax/nfs-server.git
    cd nfs-server
    
  2. Build locally:

    docker build -t nfs-server:dev .
    
  3. Test:

    docker-compose -f examples/docker-compose.dev.yaml up -d
    
⁠Building with Attestation
# Create buildx builder
docker buildx create --name attestation-builder --driver docker-container --use

# Build with attestation and SBOM
docker buildx build 
  --builder attestation-builder 
  --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" 
  --build-arg VCS_REF="$(git rev-parse HEAD)" 
  --build-arg VERSION="1.0.1" 
  --platform linux/amd64 
  --attest type=provenance,mode=max 
  --attest type=sbom 
  -t boyroywax/nfs-server:dev 
  --push 
  .

β πŸ“„ License

This project is licensed under the MIT License - see the LICENSE⁠ file for details.

β πŸ™ Acknowledgments

  • Alpine Linux team for the secure, minimal base image
  • Kubernetes community for orchestration excellence
  • Docker for containerization standards
  • Contributors who help improve this project

Built with ❀️ for the cloud-native community.

For questions, issues, or contributions, please visit our GitHub repository⁠.

Tag summary

Content type

Image

Digest

sha256:5110eed7a…

Size

23.6 MB

Last updated

about 1 year ago

docker pull boyroywax/nfs-server