rustberg 0.0.5

A production-grade, cross-platform, single-binary Apache Iceberg REST Catalog
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
---
layout: default
title: Storage Backends
nav_order: 5
description: "Storage backends for Rustberg: S3, GCS, Azure Blob, local filesystem"
permalink: /docs/storage
---

# Storage Backends
{: .no_toc }

Configure persistent storage for catalog metadata.
{: .fs-6 .fw-300 }

## Table of contents
{: .no_toc .text-delta }

1. TOC
{:toc}

---

## Overview

Rustberg uses **SlateDB** (100% pure Rust) for catalog metadata storage:

| Backend | URL Scheme | K8s HA | Use Case |
|---------|------------|--------|----------|
| Memory | `memory://` || Development, testing |
| Local File | `file:///path` || Single-node production |
| AWS S3 | `s3://bucket/prefix` || Cloud production |
| GCS | `gs://bucket/prefix` || Cloud production |
| Azure Blob | `az://container/prefix` || Cloud production |
| MinIO | `s3://bucket` + endpoint || Air-gapped |

### What Gets Stored

SlateDB stores all catalog metadata, including:

| Data Type | Key Pattern | Persistence |
|-----------|-------------|-------------|
| Namespaces | `namespace:{name}` | ✅ Durable |
| Tables | `table:{namespace}:{name}` | ✅ Durable |
| Views | `view:{namespace}:{name}` | ✅ Durable |
| Idempotency Keys | `idempotency:{scope}:{key}` | ✅ Durable |
| API Keys | `apikey:{prefix}` | ✅ Durable (with slatedb-storage) |

All data survives server restarts when using persistent backends (file, S3, GCS, Azure).

---

## Quick Start

### Memory (Default)

```bash
# In-memory storage (data lost on restart)
./rustberg
```

### Local Filesystem

```bash
# Persistent local storage
./rustberg --storage file:///var/lib/rustberg
```

### AWS S3

```bash
# S3 backend (K8s HA ready)
export AWS_ACCESS_KEY_ID=your_key
export AWS_SECRET_ACCESS_KEY=your_secret
./rustberg --storage s3://my-bucket/rustberg-catalog
```

---

## Memory Backend

**URL:** `memory://`

Best for:
- Development
- CI/CD testing
- Ephemeral workloads

```toml
[storage]
object_store_url = "memory://"
```

{: .warning }
> Data is lost when the process restarts. Not for production.

---

## Local Filesystem

**URL:** `file:///absolute/path`

Best for:
- Single-node production
- Edge deployments
- Simple setups

### Configuration

```toml
[storage]
object_store_url = "file:///var/lib/rustberg"
```

### Directory Structure

```
/var/lib/rustberg/
├── slatedb/           # SlateDB LSM-tree data
│   ├── wal/           # Write-ahead log
│   ├── sst/           # Sorted string tables
│   └── manifest/      # Metadata
└── backup/            # Optional backup location
```

### Permissions

```bash
# Create directory
sudo mkdir -p /var/lib/rustberg
sudo chown rustberg:rustberg /var/lib/rustberg
chmod 700 /var/lib/rustberg
```

{: .important }
> Use absolute paths. Relative paths may cause issues.

---

## AWS S3

**URL:** `s3://bucket/prefix`

Best for:
- Kubernetes deployments
- High availability
- Multi-replica setups

### Configuration

```toml
[storage]
object_store_url = "s3://my-bucket/rustberg-catalog"
aws_region = "us-east-1"
```

### Authentication

#### Environment Variables (Recommended)

```bash
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
export AWS_REGION=us-east-1
```

#### IAM Role (EC2/EKS)

```yaml
# EKS Service Account with IRSA
apiVersion: v1
kind: ServiceAccount
metadata:
  name: rustberg
  annotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::123456789:role/rustberg-role
```

#### IAM Policy

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:PutObject",
        "s3:DeleteObject",
        "s3:ListBucket"
      ],
      "Resource": [
        "arn:aws:s3:::my-bucket",
        "arn:aws:s3:::my-bucket/rustberg-catalog/*"
      ]
    }
  ]
}
```

### S3 Bucket Settings

| Setting | Recommended Value | Why |
|---------|------------------|-----|
| Versioning | Enabled | Disaster recovery |
| Encryption | SSE-S3 or SSE-KMS | Data protection |
| Lifecycle | 30 days for old versions | Cost optimization |
| Replication | Optional | Multi-region HA |

---

## Google Cloud Storage

**URL:** `gs://bucket/prefix`

Best for:
- GKE deployments
- Google Cloud workloads

### Configuration

```toml
[storage]
object_store_url = "gs://my-bucket/rustberg-catalog"
```

### Authentication

#### Service Account Key

```bash
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
```

#### Workload Identity (GKE)

```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: rustberg
  annotations:
    iam.gke.io/gcp-service-account: rustberg@project.iam.gserviceaccount.com
```

#### IAM Permissions

```bash
gsutil iam ch serviceAccount:rustberg@project.iam.gserviceaccount.com:objectAdmin \
  gs://my-bucket
```

---

## Azure Blob Storage

**URL:** `az://container/prefix`

Best for:
- AKS deployments
- Azure workloads

### Configuration

```toml
[storage]
object_store_url = "az://my-container/rustberg-catalog"
azure_storage_account = "mystorageaccount"
```

### Authentication

#### Access Key

```bash
export AZURE_STORAGE_ACCOUNT=mystorageaccount
export AZURE_STORAGE_KEY=your_storage_key
```

#### Managed Identity (AKS)

```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: rustberg
  annotations:
    azure.workload.identity/client-id: <client-id>
```

---

## MinIO (Self-Hosted S3)

**URL:** `s3://bucket` with custom endpoint

Best for:
- Air-gapped environments
- On-premises deployments
- Development with S3 API

### Configuration

```toml
[storage]
object_store_url = "s3://rustberg-bucket/catalog"
aws_endpoint = "http://minio.local:9000"
aws_region = "us-east-1"
aws_allow_http = true  # Only for development
```

### Docker Compose Example

```yaml
version: '3.8'
services:
  minio:
    image: minio/minio
    ports:
      - "9000:9000"
      - "9001:9001"
    environment:
      MINIO_ROOT_USER: minioadmin
      MINIO_ROOT_PASSWORD: minioadmin
    command: server /data --console-address ":9001"

  rustberg:
    image: ghcr.io/hupe1980/rustberg:latest
    ports:
      - "8181:8181"
    environment:
      RUSTBERG_STORAGE: "s3://rustberg/catalog"
      AWS_ENDPOINT_URL: "http://minio:9000"
      AWS_ACCESS_KEY_ID: minioadmin
      AWS_SECRET_ACCESS_KEY: minioadmin
      AWS_REGION: us-east-1
    depends_on:
      - minio
```

---

## Kubernetes Horizontal Scaling

SlateDB enables **horizontal scaling** without external coordination:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rustberg
spec:
  replicas: 3  # ✅ Multiple replicas!
  selector:
    matchLabels:
      app: rustberg
  template:
    spec:
      containers:
      - name: rustberg
        image: ghcr.io/hupe1980/rustberg:latest
        env:
        - name: RUSTBERG_STORAGE
          value: "s3://my-bucket/rustberg-catalog"
```

### How It Works

1. **No leader election** - SlateDB's `writer_epoch` fencing handles coordination
2. **CAS operations** - Object storage provides atomic compare-and-swap
3. **Automatic retry** - Contention resolved with exponential backoff
4. **11-nines durability** - Inherits S3/GCS durability

```
┌─────────────────────────────────────────────────────────────────┐
│                    Rustberg K8s Deployment                       │
├─────────────────────────────────────────────────────────────────┤
│   ┌──────────┐  ┌──────────┐  ┌──────────┐                     │
│   │  Pod 1   │  │  Pod 2   │  │  Pod 3   │                     │
│   │ Rustberg │  │ Rustberg │  │ Rustberg │                     │
│   └────┬─────┘  └────┬─────┘  └────┬─────┘                     │
│        └─────────────┼─────────────┘                            │
│                      ▼                                          │
│        ┌─────────────────────────────┐                         │
│        │         SlateDB             │                         │
│        │  (writer_epoch fencing)     │                         │
│        └─────────────┬───────────────┘                         │
│                      ▼                                          │
│        ┌─────────────────────────────┐                         │
│        │      S3 / GCS / MinIO       │                         │
│        │   (CAS + 11-nines durable)  │                         │
│        └─────────────────────────────┘                         │
└─────────────────────────────────────────────────────────────────┘
```

---

## Backup and Restore

### Backup

```bash
# Backup catalog to archive
./rustberg backup \
  --storage s3://my-bucket/rustberg-catalog \
  --output /backups/catalog-2026-01-24.tar.gz
```

### Restore

```bash
# Restore from backup
./rustberg restore \
  --input /backups/catalog-2026-01-24.tar.gz \
  --storage s3://my-bucket/rustberg-catalog
```

### Validate Backup

```bash
# Verify backup integrity
./rustberg validate-backup \
  --input /backups/catalog-2026-01-24.tar.gz
```

---

## Performance Tuning

### S3 Optimization

```toml
[storage]
object_store_url = "s3://my-bucket/catalog"
aws_region = "us-east-1"

# Performance settings
s3_multipart_threshold_mb = 8
s3_multipart_chunk_size_mb = 8
s3_max_concurrent_requests = 100
```

### Local Filesystem

```toml
[storage]
object_store_url = "file:///var/lib/rustberg"

# Use SSD for best performance
# Mount with noatime for reduced I/O
```

---

## Troubleshooting

### S3 Access Denied

```bash
# Verify credentials
aws sts get-caller-identity

# Test bucket access
aws s3 ls s3://my-bucket/rustberg-catalog/

# Check bucket policy
aws s3api get-bucket-policy --bucket my-bucket
```

### GCS Permission Denied

```bash
# Verify service account
gcloud auth list

# Test bucket access
gsutil ls gs://my-bucket/rustberg-catalog/
```

### Local Filesystem Issues

```bash
# Check permissions
ls -la /var/lib/rustberg

# Check disk space
df -h /var/lib/rustberg

# Check for lock files
ls -la /var/lib/rustberg/slatedb/
```

---

## Next Steps

- [Encryption Guide]/rustberg/docs/encryption - Encrypt data at rest
- [Kubernetes Guide]/rustberg/docs/kubernetes - Production K8s deployment
- [Backup Guide]/rustberg/docs/backup - Disaster recovery