Skip to main content

Installation, Standalone Mode & Cloud / Kubernetes Deployment

This guide covers how to deploy and operate Arkhos File Vault in your own infrastructure — from a Standalone single-binary / Docker setup to a production-grade, highly available Kubernetes (EKS / GKE / AKS) deployment connected to managed PostgreSQL and multi-cloud storage buckets.


1. Runtime Environment Variables Reference​

Arkhos follows the 12-Factor App methodology and is configured entirely through environment variables:

Environment VariableRequiredDefaultDescription
ARKHOS_DATABASE_URLYes—PostgreSQL 16+ connection string (postgres://user:pass@host:5432/arkhos?sslmode=require).
ARKHOS_MASTER_KEYYes—32-byte (256-bit) root key encoded as 64 hex chars or Base64, used by INTERNAL_MASTER_KEY (HKDF-SHA256 + AES-256-GCM) to wrap client KEKs and sign stateless download tokens.
ARKHOS_ADMIN_TOKENYes—Bearer token required by /v1/admin/* endpoints and arkhosctl.
ARKHOS_PORTNo8080TCP port for the HTTP server (1..65535).
ARKHOS_LOCAL_STORAGE_DIRNo./data/storageBase directory on disk for LOCAL_DISK Big Buckets.
ARKHOS_KMS_CACHE_TTLNo5mIn-memory TTL cache duration for unwrapped client KEKs (e.g., 5m, 15m, 0s to disable).
ARKHOS_AUTO_MIGRATENotrueAutomatically applies embedded SQL migrations (000001..000004) on server startup.
ARKHOS_LOG_LEVELNoINFOStructured JSON (log/slog) level: DEBUG, INFO, WARN, or ERROR.
Generating Cryptographically Secure Secrets

Before deploying to production, generate a 256-bit ARKHOS_MASTER_KEY and a high-entropy ARKHOS_ADMIN_TOKEN:

export ARKHOS_MASTER_KEY=$(openssl rand -hex 32)
export ARKHOS_ADMIN_TOKEN="arkhos_adm_$(openssl rand -hex 24)"

2. Mode A: Standalone Deployment (Binary, Systemd & Docker)​

Standalone mode is ideal for bare-metal servers, Linux VMs (EC2, Compute Engine, Azure VMs), on-premises appliances, or edge environments.

Option 1: Native Go Binary + systemd Service​

Because Arkhos compiles to a single static binary (CGO_ENABLED=0) with embedded SQL migrations, it runs on any Linux host without runtime dependencies:

# 1. Compile the static production binaries
cd src
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o ../dist/arkhos ./cmd/arkhos
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o ../dist/arkhosctl ./cmd/arkhosctl

# 2. Install binaries and create storage directory on the target host
sudo install -m 0755 ../dist/arkhos /usr/local/bin/arkhos
sudo install -m 0755 ../dist/arkhosctl /usr/local/bin/arkhosctl
sudo useradd --system --home-dir /var/lib/arkhos --create-home --shell /sbin/nologin arkhos
sudo mkdir -p /var/lib/arkhos/storage /etc/arkhos
sudo chown -R arkhos:arkhos /var/lib/arkhos

Create /etc/arkhos/arkhos.env (chmod 0600):

ARKHOS_PORT=8080
ARKHOS_DATABASE_URL=postgres://arkhos:STRONG_DB_PASSWORD@127.0.0.1:5432/arkhos?sslmode=disable
ARKHOS_MASTER_KEY=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
ARKHOS_ADMIN_TOKEN=arkhos_adm_replace_with_strong_secret
ARKHOS_LOCAL_STORAGE_DIR=/var/lib/arkhos/storage
ARKHOS_LOG_LEVEL=INFO

Create /etc/systemd/system/arkhos.service:

[Unit]
Description=Arkhos Multi-Cloud File Vault Server
After=network-online.target postgresql.service
Wants=network-online.target

[Service]
Type=simple
User=arkhos
Group=arkhos
EnvironmentFile=/etc/arkhos/arkhos.env
ExecStart=/usr/local/bin/arkhos
Restart=on-failure
RestartSec=5s
LimitNOFILE=65536
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/arkhos

[Install]
WantedBy=multi-user.target

Enable and verify the service:

sudo systemctl daemon-reload
sudo systemctl enable --now arkhos
curl -fsS http://127.0.0.1:8080/readyz

Option 2: Standalone Container (iac/Dockerfile)​

Arkhos ships with a hardened multi-stage Alpine image in iac/Dockerfile (runs as non-root user arkhos and bundles both arkhos and arkhosctl):

# 1. Build the container image from the repository root
docker build -f iac/Dockerfile -t arkhos:latest .

# 2. Run Arkhos in standalone container mode
docker run -d \
--name arkhos-vault \
--restart unless-stopped \
-p 8080:8080 \
-e ARKHOS_DATABASE_URL="postgres://arkhos:arkhos@host.docker.internal:5432/arkhos?sslmode=disable" \
-e ARKHOS_MASTER_KEY="$(openssl rand -hex 32)" \
-e ARKHOS_ADMIN_TOKEN="arkhos-prod-admin-token" \
-v arkhos_local_data:/var/lib/arkhos/storage \
arkhos:latest

3. Mode B: Cloud & Kubernetes Deployment (EKS / GKE / AKS)​

Because Arkhos processes file streams in constant $O(1)$ RAM (4 MB chunks) and stores all state in PostgreSQL 16 and Cloud Object Storage (S3 / GCS / Azure Blob), the arkhos pods are stateless and horizontally scalable.

Step 1: Provision Cloud Big Buckets with OpenTofu (iac/tofu/)​

The repository includes a ready-to-use OpenTofu / Terraform module in iac/tofu/ that provisions hardened, private, encrypted, versioned Big Buckets on AWS S3, Google Cloud Storage, and Azure Blob Storage:

cd iac/tofu
tofu init

# Example: Provision an AWS S3 Big Bucket and a GCP GCS Big Bucket for tenant 'acme-corp'
tofu apply \
-var="client_slug=acme-corp" \
-var="environment=prod" \
-var="enable_aws_s3=true" \
-var="aws_region=us-east-1" \
-var="enable_gcp_gcs=true" \
-var="gcp_project_id=my-gcp-project-id"

Step 2: Kubernetes Manifests (Namespace, Secret, ConfigMap)​

Save as k8s-arkhos-config.yaml:

apiVersion: v1
kind: Namespace
metadata:
name: arkhos-system
---
apiVersion: v1
kind: ConfigMap
metadata:
name: arkhos-config
namespace: arkhos-system
data:
ARKHOS_PORT: "8080"
ARKHOS_LOCAL_STORAGE_DIR: "/var/lib/arkhos/storage"
ARKHOS_KMS_CACHE_TTL: "5m"
ARKHOS_AUTO_MIGRATE: "true"
ARKHOS_LOG_LEVEL: "INFO"
---
apiVersion: v1
kind: Secret
metadata:
name: arkhos-secrets
namespace: arkhos-system
type: Opaque
stringData:
# Replace with your Managed PostgreSQL URL (RDS / Cloud SQL / Azure PostgreSQL)
ARKHOS_DATABASE_URL: "postgres://arkhos_user:CHANGE_ME@postgres.internal.cloud:5432/arkhos?sslmode=require"
# 64-character hex string (32 bytes) generated via: openssl rand -hex 32
ARKHOS_MASTER_KEY: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
# Admin Bearer token used by arkhosctl to onboard tenants
ARKHOS_ADMIN_TOKEN: "arkhos_adm_CHANGE_ME_IN_PRODUCTION"

Step 3: Kubernetes Deployment (with /healthz, /readyz & Constant RAM Limits)​

Because Arkhos streams uploads and downloads in 4 MB chunks without buffering entire files in memory, you can run multiple high-throughput pods with predictable, small memory limits (128Mi request / 512Mi limit).

Save as k8s-arkhos-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
name: arkhos
namespace: arkhos-system
labels:
app.kubernetes.io/name: arkhos
spec:
replicas: 3
selector:
matchLabels:
app.kubernetes.io/name: arkhos
template:
metadata:
labels:
app.kubernetes.io/name: arkhos
spec:
serviceAccountName: default
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
containers:
- name: arkhos
image: ghcr.io/zarathon/arkhos:latest
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8080
protocol: TCP
envFrom:
- configMapRef:
name: arkhos-config
- secretRef:
name: arkhos-secrets
resources:
requests:
cpu: "250m"
memory: "128Mi"
limits:
cpu: "1000m"
memory: "512Mi"
livenessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 3
readinessProbe:
httpGet:
path: /readyz
port: http
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
volumeMounts:
- name: local-storage
mountPath: /var/lib/arkhos/storage
volumes:
# Use emptyDir when all clients use AWS_S3 / GCP_GCS / AZURE_BLOB,
# or replace with a ReadWriteMany (RWX) PersistentVolumeClaim for LOCAL_DISK tenants.
- name: local-storage
emptyDir: {}

Step 4: Service, Ingress (Large Streaming Body Support) & HorizontalPodAutoscaler​

When exposing Arkhos through an NGINX Ingress Controller or Cloud Load Balancer, disable request body buffering (proxy-request-buffering: "off") and proxy-body-size: "0" so multi-gigabyte uploads stream directly to the arkhos pods in $O(1)$ RAM.

Save as k8s-arkhos-network-hpa.yaml:

apiVersion: v1
kind: Service
metadata:
name: arkhos
namespace: arkhos-system
spec:
type: ClusterIP
selector:
app.kubernetes.io/name: arkhos
ports:
- name: http
port: 80
targetPort: http
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: arkhos-ingress
namespace: arkhos-system
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/proxy-request-buffering: "off"
nginx.ingress.kubernetes.io/proxy-buffering: "off"
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"
spec:
ingressClassName: nginx
tls:
- hosts:
- vault.example.com
secretName: arkhos-tls-cert
rules:
- host: vault.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: arkhos
port:
name: http
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: arkhos-hpa
namespace: arkhos-system
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: arkhos
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70

Step 5: Apply Manifests & Onboard Your First Cloud Tenant via arkhosctl​

# 1. Deploy Arkhos to Kubernetes
kubectl apply -f k8s-arkhos-config.yaml
kubectl apply -f k8s-arkhos-deployment.yaml
kubectl apply -f k8s-arkhos-network-hpa.yaml

# 2. Verify rollout and readiness probes
kubectl -n arkhos-system rollout status deployment/arkhos
kubectl -n arkhos-system get pods

# 3. Run arkhosctl inside the cluster (or via port-forward) to onboard an AWS S3 client
kubectl -n arkhos-system exec -it deploy/arkhos -- \
/usr/local/bin/arkhosctl \
--server http://127.0.0.1:8080 \
--admin-token "arkhos_adm_CHANGE_ME_IN_PRODUCTION" \
client create \
--slug acme-corp \
--name "Acme Corp Production" \
--provider AWS_S3 \
--bucket arkhos-acme-corp-prod \
--provider-config '{"region":"us-east-1"}'