A professional-grade, high-performance API server for synchronizing data from various sources (SSH, Git, S3) to local volumes. Built specifically for Kubernetes SharedVolume operators with Go and Gin framework, designed for containerized environments and enterprise workloads.
Repository: https://github.com/sharedvolume/volume-syncerā
Releases: https://github.com/sharedvolume/volume-syncer/releasesā
GET /health
Returns server health status for Kubernetes readiness and liveness probes.
Response:
{
"status": "healthy",
"timestamp": "2025-08-30T10:30:00Z"
}
POST /api/1.0/sync
Request payload:
{
"source": {
"type": "ssh",
"details": {
"host": "example-server.com",
"port": 22,
"username": "deploy",
"path": "/opt/data",
"privateKey": "<base64 encoded private key>"
}
},
"target": {
"path": "/mnt/shared-volume"
},
"timeout": "30s"
}
Response codes:
201: Sync started successfully400: Invalid request format or parameters503: Sync already in progressgit clone https://github.com/sharedvolume/volume-syncer.git
cd volume-syncer
docker-compose up --build
curl http://localhost:8080/health
docker build -t volume-syncer .
docker run -p 8080:8080 -v $(pwd)/data:/mnt/shared-volume volume-syncer
For production Kubernetes deployments, use the provided manifests or integrate with your SharedVolume operator:
apiVersion: apps/v1
kind: Deployment
metadata:
name: volume-syncer
labels:
app: volume-syncer
spec:
replicas: 1
selector:
matchLabels:
app: volume-syncer
template:
metadata:
labels:
app: volume-syncer
spec:
containers:
- name: volume-syncer
image: volume-syncer:latest
ports:
- containerPort: 8080
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 15
periodSeconds: 20
volumeMounts:
- name: shared-volume
mountPath: /mnt/shared-volume
volumes:
- name: shared-volume
persistentVolumeClaim:
claimName: shared-volume-pvc
go mod tidy
go run cmd/server/main.go
Currently supported:
host: SSH server hostname or IP (required)port: SSH port (default: 22)username: SSH username (default: "root")privateKey: Base64-encoded SSH private key (optional)password: SSH password (optional)Note: privateKey and password cannot be provided at the same time.
url: Git repository URL (required)branch: Branch to clone (optional, if not specified, uses repository's default branch)depth: Clone depth (optional, default: 1 for shallow clone)username: Username for HTTP authentication (optional, requires password)password: Password for HTTP authentication (optional, requires username)privateKey: Base64-encoded SSH private key for SSH authentication (optional)Note: username/password and privateKey cannot be provided at the same time.
url: HTTP/HTTPS URL to download (required)endpointUrl: S3 endpoint URL (required, e.g., "https://s3.amazonaws.comā ")bucketName: S3 bucket name (required)path: Path/prefix in the bucket (required)accessKey: AWS access key (required)secretKey: AWS secret key (required)region: AWS region (required)GIN_MODE: Set to "release" for production deploymentsPORT: Server port (default: 8080)LOG_LEVEL: Logging level (default: "info", options: "debug", "info", "warn", "error")# Using private key (base64 encoded)
curl -X POST http://localhost:8080/api/1.0/sync \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "ssh",
"details": {
"host": "example.com",
"port": 22,
"username": "deploy",
"privateKey": "LS0tLS1CRUdJTi..."
}
},
"target": {
"path": "/mnt/shared-volume"
}
}'
# Using password authentication
curl -X POST http://localhost:8080/api/1.0/sync \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "ssh",
"details": {
"host": "example.com",
"port": 22,
"username": "deploy",
"password": "your-password"
}
},
"target": {
"path": "/mnt/shared-volume"
}
}'
# Clone with username/password authentication
curl -X POST http://localhost:8080/api/1.0/sync \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "git",
"details": {
"url": "https://github.com/user/repo.git",
"branch": "main",
"depth": 1,
"username": "your-username",
"password": "your-password"
}
},
"target": {
"path": "/mnt/shared-volume"
}
}'
# Clone with SSH private key authentication
curl -X POST http://localhost:8080/api/1.0/sync \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "git",
"details": {
"url": "[email protected]:user/repo.git",
"branch": "main",
"depth": 1,
"privateKey": "LS0tLS1CRUdJTi..."
}
},
"target": {
"path": "/mnt/shared-volume"
}
}'
# Clone using repository default branch (no branch specified)
curl -X POST http://localhost:8080/api/1.0/sync \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "git",
"details": {
"url": "https://github.com/user/repo.git",
"depth": 1
}
},
"target": {
"path": "/mnt/shared-volume"
}
}'
curl -X POST http://localhost:8080/api/1.0/sync \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "http",
"details": {
"url": "https://example.com/file.zip"
}
},
"target": {
"path": "/mnt/shared-volume"
}
}'
curl -X POST http://localhost:8080/api/1.0/sync \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "s3",
"details": {
"endpointUrl": "https://s3.amazonaws.com",
"bucketName": "my-aws-bucket",
"path": "project/data/",
"accessKey": "AKIA....",
"secretKey": "abcd1234...",
"region": "us-east-1"
}
},
"target": {
"path": "/mnt/shared-volume"
}
}'
base64 -w 0 ~/.ssh/id_rsa
The server provides comprehensive health check endpoints optimized for Kubernetes:
Health Check Endpoint: /health
{
"status": "healthy",
"timestamp": "2025-08-30T10:30:00Z"
}
Kubernetes Integration:
/health endpoint to determine when pod is ready to receive traffic/health endpoint to determine when pod should be restartedāāā cmd/
ā āāā server/
ā āāā main.go # Application entry point
āāā internal/
ā āāā config/
ā ā āāā config.go # Configuration management
ā āāā handler/
ā ā āāā sync_handler.go # HTTP request handlers
ā āāā models/
ā ā āāā requests.go # Request/response models
ā āāā server/
ā ā āāā server.go # HTTP server setup
ā āāā service/
ā ā āāā sync_service.go # Business logic
ā āāā syncer/
ā ā āāā git/
ā ā ā āāā git_syncer.go # Git synchronization
ā ā āāā http/
ā ā ā āāā http_syncer.go # HTTP download
ā ā āāā s3/
ā ā ā āāā s3_syncer.go # S3 synchronization
ā ā āāā ssh/
ā ā ā āāā ssh_syncer.go # SSH synchronization
ā ā āāā types.go # Common types and factory
ā āāā utils/
ā āāā fs.go # File system utilities
āāā pkg/
ā āāā errors/
ā āāā errors.go # Custom error types
āāā Dockerfile # Container definition
āāā docker-compose.yml # Docker Compose configuration
āāā kubernetes/ # Kubernetes manifests
ā āāā deployment.yaml # Production deployment
ā āāā service.yaml # Service definition
ā āāā configmap.yaml # Configuration
āāā README.md # This documentation
internal/syncer/<type>/internal/models/requests.gointernal/syncer/types.gointernal/service/sync_service.go# Check pod status
kubectl get pods -l app=volume-syncer
# View pod logs
kubectl logs -f deployment/volume-syncer
# Check health endpoint
kubectl port-forward deployment/volume-syncer 8080:8080
curl http://localhost:8080/health
# Debug volume mounts
kubectl exec -it deployment/volume-syncer -- ls -la /mnt/shared-volume
Check container logs for detailed error information:
# Docker Compose
docker-compose logs -f volume-syncer
# Docker
docker logs -f <container-id>
# Kubernetes
kubectl logs -f deployment/volume-syncer
We welcome contributions! Please see CONTRIBUTING.mdā for detailed guidelines on how to contribute to this project.
git checkout -b feature/amazing-featurego test ./...golangci-lint rungit commit -m 'Add amazing feature'git push origin feature/amazing-feature# Clone your fork
git clone https://github.com/yourusername/volume-syncer.git
cd volume-syncer
# Install dependencies
go mod download
# Run tests
go test ./...
# Build and run
go build -o volume-syncer ./cmd/server
./volume-syncer
For more detailed contribution guidelines, code standards, and development practices, please read our Contributing Guideā .
When submitting a pull request, please include:
Description & Type of Change
Changes Made
Testing
Example Manual Testing:
# Test new sync source
curl -X POST http://localhost:8080/api/1.0/sync \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "your-new-source",
"details": {
"host": "test.example.com",
"username": "testuser"
}
},
"target": {
"path": "/mnt/test-volume"
}
}'
Checklist
Related Issues
This project is licensed under the Apache License 2.0 - see the LICENSEā file for details.
Why Apache 2.0?
Content type
Image
Digest
sha256:5f2015ce4ā¦
Size
20.2 MB
Last updated
about 1 year ago
docker pull sharedvolume/volume-syncer