Integration of the Worker Job Protocol v1 with Kubernetes orchestration.
Successfully integrated the Worker Job Protocol with Kubernetes, enabling production-grade deployment of hyper2kvm workers across a cluster.
k8s/worker/)| File | Purpose | Status |
|---|---|---|
configmap.yaml |
Worker and daemon configuration | ✅ Complete |
rbac.yaml |
Service account and permissions | ✅ Complete |
daemonset.yaml |
Long-running worker pods | ✅ Complete |
job-template.yaml |
One-shot CLI migration jobs | ✅ Complete |
README.md |
Complete deployment guide | ✅ Complete |
k8s/worker/examples/)| File | Operation | Requires Privileged |
|---|---|---|
inspect-job.json |
Disk inspection | No |
convert-job.json |
Format conversion | No |
offline-fix-job.json |
Complete offline repair | Yes |
| Component | Status |
|---|---|
| Dockerfile worker stage | ✅ Added |
| docker-entrypoint.sh worker mode | ✅ Implemented |
| Worker health checks | ✅ Configured |
| Environment variables | ✅ Defined |
| Document | Purpose | Status |
|---|---|---|
container-deployment-guide.md |
Complete deployment guide | ✅ Complete |
k8s/worker/README.md |
Kubernetes-specific guide | ✅ Complete |
KUBERNETES_INTEGRATION.md |
This document | ✅ Complete |
┌───────────────────────────────────┐
│ Control Plane (kubectl) │
│ │
│ - Job submission via ConfigMaps │
│ - Status monitoring │
│ - Event streaming │
└────────────┬──────────────────────┘
│
│ Worker Job Protocol (JSON)
▼
┌───────────────────────────────────┐
│ Data Plane (Worker DaemonSet) │
│ │
│ Node 1: │
│ - hyper2kvm-worker pod │
│ - NBD module loaded │
│ - Capabilities detected │
│ │
│ Node 2: │
│ - hyper2kvm-worker pod │
│ - NBD module loaded │
│ - Capabilities detected │
└───────────────────────────────────┘
┌─────────────────────────────────────┐
│ hyper2kvm-worker Pod │
│ │
│ Init Container: │
│ └─ nbd-module-loader │
│ (loads NBD kernel module) │
│ │
│ Main Container: │
│ ├─ Worker daemon process │
│ ├─ Capability detection │
│ ├─ Job queue monitoring │
│ └─ Event streaming │
│ │
│ Volumes: │
│ ├─ /dev (device access) │
│ ├─ /data/incoming (watch dir) │
│ ├─ /data/output (results) │
│ ├─ /var/lib/hyper2kvm (state) │
│ └─ /lib/modules (NBD module) │
└─────────────────────────────────────┘
# Label worker nodes
kubectl label nodes worker-01 hyper2kvm.io/worker-enabled=true
# Deploy base resources
kubectl apply -f k8s/base/namespace.yaml
kubectl apply -f k8s/worker/rbac.yaml
kubectl apply -f k8s/worker/configmap.yaml
# Deploy DaemonSet (one worker per labeled node)
kubectl apply -f k8s/worker/daemonset.yaml
# Verify workers running
kubectl get pods -n hyper2kvm-workers -l app=hyper2kvm-worker
# Create job spec ConfigMap
kubectl create configmap hyper2kvm-job-001 \
--from-file=job-spec.json=k8s/worker/examples/convert-job.json \
-n hyper2kvm-workers
# Deploy job
sed 's/JOBID/001/g' k8s/worker/job-template.yaml | kubectl apply -f -
# Monitor progress
kubectl logs -n hyper2kvm-workers -f job/hyper2kvm-migration-001
Workers automatically detect their execution environment on startup:
kubectl exec -n hyper2kvm-workers hyper2kvm-worker-xxxxx -- \
python3 -m hyper2kvm.worker.cli capabilities
# Output:
# ✅ NBD support: Available
# ✅ LVM support: Available
# ✅ Mount support: Available
# ✅ qemu-img: 9.1.0
# Execution mode: privileged_container
Init container automatically loads NBD kernel module:
initContainers:
- name: nbd-module-loader
image: fedora:43
command: ['modprobe', 'nbd', 'max_part=16', 'nbds_max=16']
securityContext:
privileged: true
Complete job state machine with persistence:
Real-time progress events stored in JSON Lines format:
kubectl exec -n hyper2kvm-workers hyper2kvm-worker-xxxxx -- \
python3 -m hyper2kvm.worker.cli events convert-001 --follow
# Output:
# [validation] 10%: Validating job specification
# [conversion] 25%: Converting VMDK to qcow2
# [conversion] 50%: Compression in progress
# [conversion] 75%: Finalizing output
# [completed] 100%: Job completed successfully
Configurable CPU and memory limits:
resources:
requests:
cpu: "2"
memory: "4Gi"
limits:
cpu: "8"
memory: "16Gi"
Extended grace period for completing in-progress migrations:
terminationGracePeriodSeconds: 7200 # 2 hours
Workers require privileged mode for:
/dev/nbd*)kubectl label namespace hyper2kvm-workers \
pod-security.kubernetes.io/enforce=privileged
Liveness Probe:
livenessProbe:
exec:
command: ['python3', '-c', 'import os; exit(0 if os.path.exists("/var/lib/hyper2kvm/worker.pid") else 1)']
periodSeconds: 30
Readiness Probe:
readinessProbe:
exec:
command: ['python3', '-m', 'hyper2kvm.worker.cli', 'capabilities', '--json-output']
periodSeconds: 30
Workers log to stdout/stderr for collection by Kubernetes logging infrastructure:
# View worker logs
kubectl logs -n hyper2kvm-workers -l app=hyper2kvm-worker --tail=100 -f
# View specific job logs
kubectl logs -n hyper2kvm-workers job/hyper2kvm-migration-001 -f
Planned metrics endpoints:
hyper2kvm_migration_duration_secondshyper2kvm_migration_totalhyper2kvm_migration_failures_totalhyper2kvm_vmdk_size_byteshyper2kvm_worker_capability_info# 1. Deploy complete stack
kubectl apply -f k8s/base/
kubectl apply -f k8s/worker/
# 2. Wait for workers ready
kubectl wait --for=condition=Ready pods \
-n hyper2kvm-workers -l app=hyper2kvm-worker \
--timeout=300s
# 3. Submit test conversion job
kubectl create configmap hyper2kvm-job-test \
--from-file=job-spec.json=k8s/worker/examples/convert-job.json \
-n hyper2kvm-workers
sed 's/JOBID/test/g' k8s/worker/job-template.yaml | kubectl apply -f -
# 4. Verify completion
kubectl wait --for=condition=Complete job/hyper2kvm-migration-test \
-n hyper2kvm-workers --timeout=3600s
# 5. Check output
kubectl exec -n hyper2kvm-workers job/hyper2kvm-migration-test -- \
ls -lh /output/
k8s/
├── base/
│ └── namespace.yaml (already existed)
├── worker/
│ ├── configmap.yaml ✅ NEW
│ ├── rbac.yaml ✅ NEW
│ ├── daemonset.yaml ✅ NEW
│ ├── job-template.yaml ✅ NEW
│ ├── README.md ✅ NEW
│ └── examples/
│ ├── inspect-job.json ✅ NEW
│ ├── convert-job.json ✅ NEW
│ └── offline-fix-job.json ✅ NEW
docs/deployment/
├── container-deployment-guide.md ✅ NEW
└── KUBERNETES_INTEGRATION.md ✅ NEW (this file)
Dockerfile (modified):
- Added worker stage ✅
docker-entrypoint.sh (modified):
- Added worker mode support ✅
Successfully integrated the Worker Job Protocol v1 with Kubernetes, providing:
The integration enables hyper2kvm to scale horizontally across Kubernetes clusters while maintaining security isolation and providing complete observability through the Worker Job Protocol.
Status: ✅ Complete and production-ready
Next Steps: