Joblet is a micro-container runtime for running Linux jobs with: Process and filesystem isolation (PID namespace, chroot) Fine-grained CPU, memory, and IO throttling (cgroups v2) Secure job execution with mTLS and RBAC Built-in scheduler, SSE log streaming, and multi-core pinning Ideal for: Agentic AI Workloads (Untrusted code)
This document consolidates advanced runtime implementation details, security considerations, enterprise deployment patterns, and sophisticated scenarios for production environments.
The Joblet runtime system provides a sophisticated isolation and mounting architecture for secure job execution.
internal/joblet/runtime/resolver.go)
openjdk-21, python-3.11-ml)internal/joblet/core/filesystem/isolator.go)
isolated/ directories into job filesystemsinternal/joblet/runtime/types.go)
internal/rnx/resources/runtime.go)
rnx runtime install/list/info)Runtime configurations are stored in /opt/joblet/runtimes/:
/opt/joblet/runtimes/
├── openjdk-21/
│ ├── isolated/ # Self-contained runtime files
│ │ ├── usr/bin/ # System binaries
│ │ ├── usr/lib/ # System libraries
│ │ ├── usr/lib/jvm/ # Java installation
│ │ ├── etc/ # Configuration files
│ │ └── ... # Complete runtime environment
│ └── runtime.yml # Runtime configuration
└── python-3.11-ml/
├── isolated/ # Self-contained Python+ML environment
└── runtime.yml
name: openjdk-21
version: "21.0.8"
description: "OpenJDK 21 - self-contained (1872 files)"
# All mounts from isolated/ - no host dependencies
mounts:
# Essential system binaries
- source: "isolated/usr/bin"
target: "/usr/bin"
readonly: true
# Essential libraries
- source: "isolated/lib"
target: "/lib"
readonly: true
# Java-specific mounts
- source: "isolated/usr/lib/jvm"
target: "/usr/lib/jvm"
readonly: true
environment:
JAVA_HOME: "/usr/lib/jvm"
PATH: "/usr/lib/jvm/bin:/usr/bin:/bin"
JAVA_VERSION: "21.0.8"
LD_LIBRARY_PATH: "/usr/lib/x86_64-linux-gnu:/lib/x86_64-linux-gnu:/usr/lib/jvm/lib"
Runtime installation uses a modular, template-based architecture:
internal/joblet/runtime/installers/interfaces.go)
internal/joblet/runtime/installers/manager.go)
internal/joblet/runtime/installers/base.go)
# List available runtimes
rnx runtime list
# Get runtime information
rnx runtime info openjdk-21
# Run job with runtime
rnx job run --runtime=openjdk-21 java -version
# Upload and run script with runtime
rnx job run --runtime=openjdk-21 --upload=App.java bash -c "javac App.java && java App"
# ML/Data Science with Python
rnx job run --runtime=python-3.11-ml \
--volume=datasets \
--upload=analysis.py \
python analysis.py
Job struct with Runtime fieldruntime field to RunJobReq messagernx job run with --runtime flagThe cleanup system transforms builder chroot runtime installations into secure, isolated runtime environments for production jobs.
When runtimes are built in the builder chroot environment, they initially have access to the full host OS filesystem. This creates a security risk if not properly isolated.
Before Cleanup (INSECURE):
# Points to actual host OS paths
mounts:
- source: "usr/lib/jvm/java-21-openjdk-amd64" # HOST PATH!
target: "/usr/lib/jvm/java-21-openjdk-amd64"
readonly: true
The cleanup system transforms runtime installations into isolated, self-contained packages:
1. Runtime Built in Builder Chroot
2. Cleanup Phase Initiated
3. Parse runtime.yml
4. Create isolated/ Directory
5. Copy Runtime Files from Host Paths
6. Update runtime.yml with Isolated Paths
7. Backup Original Configuration
8. Secure Runtime Ready for Production
Before Cleanup:
/opt/joblet/runtimes/java/openjdk-21/
├── runtime.yml # Points to host OS paths
└── setup.sh
After Cleanup (SECURE):
/opt/joblet/runtimes/java/openjdk-21/
├── isolated/ # Self-contained runtime files
│ ├── usr/
│ │ ├── lib/jvm/ # Copied Java installation
│ │ └── bin/ # Copied Java binaries
│ └── etc/ssl/certs/ # Copied certificates
├── runtime.yml # Updated with isolated paths
├── runtime.yml.original # Backup of original
└── setup.sh
# Java Runtime Cleanup Example
mkdir -p "/opt/joblet/runtimes/java/openjdk-21/isolated/usr/lib/jvm"
cp -r "/usr/lib/jvm/java-21-openjdk-amd64" \
"/opt/joblet/runtimes/java/openjdk-21/isolated/usr/lib/jvm/"
mkdir -p "/opt/joblet/runtimes/java/openjdk-21/isolated/usr/bin"
cp "/usr/bin/java" "/opt/joblet/runtimes/java/openjdk-21/isolated/usr/bin/"
cp "/usr/bin/javac" "/opt/joblet/runtimes/java/openjdk-21/isolated/usr/bin/"
After cleanup, runtime.yml is rewritten:
# SECURE - Points to isolated copy
mounts:
- source: "isolated/usr/lib/jvm/java-21-openjdk-amd64" # Isolated path
target: "/usr/lib/jvm/java-21-openjdk-amd64"
readonly: true
Attack Vector Mitigation:
/usr/bin/java and explore host filesystem/opt/joblet/runtimes/Defense in Depth:
/opt/joblet/runtimes/{runtime}/isolated/Dev Host → Runtime Built → Runtime.tar.gz → Multiple Production Hosts
(Auto Package) (Direct Extract)
All runtimes use direct extraction for deployment:
# Pre-built packages available:
# - python-3.11-ml-runtime.tar.gz (226MB)
# - java-17-runtime-complete.tar.gz (193MB)
# - java-21-runtime-complete.tar.gz (208MB)
# Extract directly to runtimes directory
sudo tar -xzf python-3.11-ml-runtime.tar.gz -C /opt/joblet/runtimes/python/
sudo tar -xzf java-17-runtime-complete.tar.gz -C /opt/joblet/runtimes/java/
# Set proper permissions
sudo chown -R joblet:joblet /opt/joblet/runtimes/
# Verify deployment
rnx runtime list
# Build on development host where contamination is acceptable
sudo ./runtimes/python-3.11-ml/setup_python_3_11_ml.sh
sudo ./runtimes/java-17/setup_java_17.sh
sudo ./runtimes/java-21/setup_java_21.sh
Each script automatically:
/tmp/runtime-deployments/[runtime]-runtime.zip# Copy from build host
scp build-host:/tmp/runtime-deployments/python-3.11-ml-runtime.zip .
scp build-host:/tmp/runtime-deployments/java-17-runtime.zip .
# Single host deployment
sudo unzip python-3.11-ml-runtime.zip -d /opt/joblet/runtimes/
# Multi-host deployment
for host in prod-01 prod-02 prod-03; do
scp python-3.11-ml-runtime.zip admin@$host:/tmp/
ssh admin@$host "sudo unzip /tmp/python-3.11-ml-runtime.zip -d /opt/joblet/runtimes/"
done
# List available runtimes
rnx runtime list
# Test runtime functionality
rnx runtime test python-3.11-ml
rnx runtime info python-3.11-ml
# Run jobs using deployed runtime
rnx job run --runtime=python-3.11-ml python script.py
Production hosts require NO:
Only requirement:
#!/bin/bash
# runtime_promotion.sh - Promote runtimes through environments
RUNTIME="python-3.11-ml"
ENVIRONMENTS=("staging" "prod-eu" "prod-us" "prod-asia")
ARTIFACT_REGISTRY="https://artifacts.company.com/joblet-runtimes"
# Download certified runtime from artifact registry
curl -H "Authorization: Bearer $REGISTRY_TOKEN" \
"$ARTIFACT_REGISTRY/$RUNTIME-runtime.zip" \
-o "$RUNTIME-runtime.zip"
# Deploy to all environments
for env in "${ENVIRONMENTS[@]}"; do
echo "🚀 Deploying $RUNTIME to $env..."
# Get environment host list
hosts=$(kubectl get nodes -l environment=$env --no-headers | awk '{print $1}')
for host in $hosts; do
scp "$RUNTIME-runtime.zip" admin@$host:/tmp/
ssh admin@$host "sudo unzip /tmp/$RUNTIME-runtime.zip -d /opt/joblet/runtimes/"
# Verify deployment
ssh admin@$host "rnx runtime test $RUNTIME" || {
echo "❌ Failed to deploy $RUNTIME on $host"
exit 1
}
done
echo "✅ $env deployment complete"
done
#!/bin/bash
# blue_green_runtime.sh - Zero-downtime runtime updates
deploy_runtime_blue_green() {
local host=$1
local runtime_file=$2
echo "🔄 Starting blue-green deployment on $host"
# Step 1: Deploy new runtime with versioned name
ssh admin@$host "sudo unzip /tmp/$runtime_file -d /opt/joblet/runtimes/"
# Step 2: Health check new runtime
ssh admin@$host "rnx job run --runtime=python-3.11-ml-v2.0 python health_check.py" || {
echo "❌ Health check failed on $host"
return 1
}
# Step 3: Update symlink for seamless cutover
ssh admin@$host "sudo ln -sfn /opt/joblet/runtimes/python/python-3.11-ml-v2.0 /opt/joblet/runtimes/python/python-3.11-ml"
# Step 4: Verify production traffic
ssh admin@$host "rnx job run --runtime=python-3.11-ml python -c 'print(\"✅ Production ready\")'"
echo "✅ Blue-green deployment complete on $host"
}
# Deploy to production cluster
PROD_HOSTS=("prod-web-01" "prod-web-02" "prod-worker-01" "prod-worker-02")
for host in "${PROD_HOSTS[@]}"; do
deploy_runtime_blue_green "$host" "$NEW_RUNTIME_FILE"
done
name: Runtime Build & Deploy Pipeline
on:
push:
paths:
- 'runtimes/**'
jobs:
build-runtime:
runs-on: [self-hosted, linux, build-cluster]
strategy:
matrix:
runtime: [python-3.11-ml, node-18, java-17]
steps:
- uses: actions/checkout@v4
- name: Build Runtime
run: |
sudo ./runtimes/$/setup_$.sh
- name: Security Scan
run: |
trivy fs /opt/joblet/runtimes/ --format table --exit-code 1
- name: Package Verification
run: |
zip -T /tmp/runtime-deployments/$-runtime.zip
- name: Upload to Registry
run: |
curl -X PUT \
-H "Authorization: Bearer $" \
-F "file=@/tmp/runtime-deployments/$-runtime.zip" \
"$/$-runtime.zip"
deploy-staging:
needs: build-runtime
runs-on: ubuntu-latest
environment: staging
steps:
- name: Deploy to Staging
run: |
for runtime in python-3.11-ml node-18 java-17; do
for host in $; do
curl -H "Authorization: Bearer $" \
"$/${runtime}-runtime.zip" \
-o "${runtime}-runtime.zip"
scp "${runtime}-runtime.zip" admin@${host}:/tmp/
ssh admin@${host} "sudo unzip /tmp/${runtime}-runtime.zip -d /opt/joblet/runtimes/"
ssh admin@${host} "rnx runtime test ${runtime}"
done
done
deploy-production:
needs: deploy-staging
runs-on: ubuntu-latest
environment: production
steps:
- name: Production Deployment
run: |
echo "🚀 Starting production deployment..."
./scripts/production_runtime_deploy.sh
#!/bin/bash
# Update all runtimes across fleet
RUNTIMES=("python-3.11-ml" "node-18" "java-17")
HOSTS=("prod-01" "prod-02" "prod-03")
for runtime in "${RUNTIMES[@]}"; do
echo "Deploying $runtime to all hosts..."
for host in "${HOSTS[@]}"; do
echo " -> $host"
scp "${runtime}-runtime.zip" admin@$host:/tmp/
ssh admin@$host "sudo unzip /tmp/${runtime}-runtime.zip -d /opt/joblet/runtimes/"
done
done
# Check runtime installation
rnx runtime list | grep python-3.11-ml
# Test runtime functionality
rnx runtime test python-3.11-ml
# Run simple test job
rnx job run --runtime=python-3.11-ml python -c "import numpy; print('✅ Runtime working')"
| Issue | Solution |
|---|---|
runtime error: invalid zip file |
Ensure zip was created properly, not corrupted during transfer |
could not detect runtime name |
Verify zip contains proper directory structure with metadata |
grpc: received message larger than max |
Use local copy approach for runtimes >128MB |