Skip to content

Object-Storage Bucket Routing

License: Pro tier and above (bucket_routing). Reads and DNS answers are never gated; only writes to the map are.

An S3-compatible object store (Scality, Cloudian, MinIO, Ceph…) that runs several storage clusters can present one DNS namespace — *.s3.example.com — and let Nexus keep the map of which cluster each bucket lives on. A client resolving photos.s3.example.com is sent to the cluster that holds photos; the storage system never has to proxy or redirect.

For a walkthrough, see [Object-Storage Routing(../user/ObjectStorageRouting.md).

Model

Concept Nexus object
The namespace A wildcard service, e.g. *.s3.example.com
A storage cluster A pool whose members are that cluster's S3 gateway/endpoint IPs
Where a bucket lives A bucket location: an ordered list of pools — primary first, then replicas
Buckets with no entry Served by the service's own (default) pool

The bucket is the part of the queried name the wildcard matched (photos for photos.s3.example.com). A multi-label match (a.b) is kept whole. Bucket names are lower-cased on write and on lookup, so matching is case-insensitive.

Resolution order

For a query that lands on a wildcard service:

  1. An exact static record at the name wins (RFC 4592) — unchanged from any wildcard service.
  2. If the bucket is mapped, the answer comes from the first pool in its list that has an eligible member (healthy, and at least the pool's minHealthy of them). A mapped bucket overrides a [routing schedule(../user/RoutingSchedules.md) as well as the default pool.
  3. Otherwise the service's default pool (or its scheduled pool) answers as usual.

The service's filter chain and algorithm then run inside the chosen pool, so geo-steering, weighting and maxAddrsReturned pick among that cluster's gateways.

Failover

If a bucket's primary cluster has no eligible member, the next pool in its list answers. If every listed pool is unavailable, the query gets the normal unavailable-pool answer (the primary's fallback CNAME if set, otherwise an empty NOERROR answer) — not the default pool. The default pool does not hold the bucket, so sending clients there would turn an outage into confusing NoSuchBucket errors.

If the map cannot be read (datastore trouble), the query fails with SERVFAIL rather than guessing a cluster.

API

All routes need service:read / service:write; the service must be a wildcard service (400 otherwise). Writes need the bucket_routing licence feature (403 otherwise).

Method Path Notes
GET /api/v1/services/{id}/buckets Paged: ?after=<bucket>&limit=<n ≤ 1000>&poolId=<id>. Response {buckets:[…], next} — pass next as after.
GET /api/v1/services/{id}/buckets/{bucket} 404 = unmapped (served by the default pool)
PUT /api/v1/services/{id}/buckets/{bucket} Body {"poolIds":["east","west"]} — idempotent upsert
DELETE /api/v1/services/{id}/buckets/{bucket} Back to the default pool
POST /api/v1/services/{id}/buckets Bulk: {"upsert":[{"bucket","poolIds"}],"delete":["b1"]}

Rules: 1–8 distinct pools per bucket, every pool must exist in the caller's tenant, bucket names must be DNS-label characters (a-z 0-9 - _, dots between labels). Bulk is atomic (one rqlite batch) and validated as a whole first: at most 2000 changes per request, and one bad entry changes nothing.

CLI

gslbctl buckets set    <service-id> photos <east-pool-id>,<west-pool-id>
gslbctl buckets get    <service-id> photos
gslbctl buckets list   <service-id> [--pool ID] [--after B] [--limit N] [--all]
gslbctl buckets delete <service-id> photos
gslbctl buckets import <service-id> inventory.txt     # "-" reads stdin

Import file: one <bucket> <pool>[,<replica>…] per line; # comments and blank lines are skipped; a pool column of - deletes the bucket. Lines are sent in atomic chunks of 2000, so a vendor's full inventory (or a diff of it) is one command.

Bucket discovery (sources)

Instead of (or as well as) feeding the map by hand, you can register bucket sources: S3-compatible endpoints whose bucket lists Nexus polls. Every bucket a source lists is mapped to the source's pool. Plain S3 ListBuckets returns only the buckets the credentials own, so one source is one account or project.

Status: not yet run against any real storage system, and not deployed.

Source fields

Field Notes
name 1–64 characters
type s3 (default) or cloudian-admin
poolId The pool (storage cluster) every bucket found here is mapped to; must exist in your tenant
endpoint http(s) URL of the S3-compatible endpoint (see Endpoint safety)
region Optional, at most 64 characters. s3: signing region, defaults to us-east-1 when empty. cloudian-admin: keep only buckets in this HyperStore region; empty keeps all
accessKey Required
secretKey Write-only: required on create, never returned. An empty value on update keeps the stored one
caPem Optional PEM CA bundle, CERTIFICATE blocks only, at most 64 KiB, trusted in addition to the system roots. Update: omit to keep, empty string to clear. Changing it resets the source's sync
priority 1–1000, default 100. Lower is preferred when a bucket is found on several sources
intervalS Seconds between syncs, 30–3600, default 60
enabled Default true
lastAttemptAt, lastOkAt, lastError, bucketCount, secretKeySet Read-only sync status. lastAttemptAt of 0 means due now; secretKeySet says whether a secret is stored

At most 32 sources per service.

Cloudian HyperStore (cross-account)

A cloudian-admin source lists every bucket of every account through the HyperStore Admin API, so one source covers a whole cluster instead of one account. Use one source per HyperStore region, all pointing at the same Admin API URL, with region set to that HyperStore region. endpoint is the Admin API base URL (for example https://hyperstore.example.com:19443); accessKey and secretKey are the Admin API user and password.

  • The Admin API certificate is usually self-signed. Set the source's CA (see Private or self-signed certificates): verification is never skipped.
  • Least privilege: the Admin API user is an all-powerful admin account. The read-only IAM/RBAC alternative on ports 16443/16080 is not supported yet.
  • Not yet run against a real HyperStore cluster: the Admin API calls follow Cloudian's documentation only.

Private or self-signed certificates

TLS is always verified. Skipping verification is never offered: there is no option for it, by design. An endpoint whose certificate is signed by a private or self-signed CA (common for a Cloudian Admin API on :19443) verifies once you give the source that CA's certificate. Nexus then trusts the system roots plus your bundle, with TLS 1.2 as the minimum, so a public endpoint keeps working too.

gslbctl bucket-sources set --ca-file cloudian-ca.pem <service-id> <source-id>
gslbctl bucket-sources set --clear-ca <service-id> <source-id>   # back to the system roots only
  • WebUI: the Custom CA (PEM, optional) box on the Bucket Sources card; a source with one shows a custom CA tag. Clearing the box and saving removes it.
  • Terraform: ca_pem = file("cloudian-ca.pem") on nexus_bucket_source; removing it from the configuration clears it.
  • REST API: caPem as above. The bundle is public, so it is returned in responses.

gslbctl bucket-sources get shows ca: system trust store or ca: custom (N certificates).

How a sync works

  • It runs only on the rqlite Raft leader, which checks every 10 s for sources that are due.
  • When any source of a service is due, all of that service's enabled sources are polled together, because the result of one listing depends on what the others found.
  • Each listing has a 60 s timeout.
  • Changes are applied in atomic batches of 2000.

Safety rules

  • Rows you set by hand (the API, gslbctl buckets, import) are never changed by a sync.
  • A bucket found on several sources gets an ordered pool list, ordered by source priority (lower first).
  • A source that fails keeps its buckets; a failed pass never unmaps anything, and if every source fails nothing changes.
  • A bucket missing from a successful listing is unmapped only after 3 consecutive successful polls without it.
  • Deleting or disabling a source lets its buckets drain the same way, as long as the service still has other enabled sources to poll; with none left, nothing runs and the map is left as it is.

  • A source that has failed for 3 of its poll intervals raises a bucket_source.failing alert on the configured alert channels (see [Alerting(../user/Alerting.md)), repeated at most every 6 h until it syncs again.

Endpoint safety

Loopback, link-local (including the 169.254.169.254 metadata address), multicast, unspecified and broadcast addresses are refused when the source is saved and on every connection (so a hostname that later resolves to one is refused too). Redirects are not followed. Private addresses (RFC 1918, ULA, CGNAT) are allowed, because storage clusters live there.

Source API

Same permissions and wildcard-service rule as the bucket map. The secret key is never in any response.

Method Path Notes
GET /api/v1/services/{id}/bucket-sources {sources:[…]}
POST /api/v1/services/{id}/bucket-sources Create; 201
GET /api/v1/services/{id}/bucket-sources/{sid} One source and its sync status
PUT /api/v1/services/{id}/bucket-sources/{sid} An omitted priority, intervalS or enabled keeps the stored value; an empty secretKey keeps the secret. Changing the type, pool, endpoint, region, access key or secret makes the source sync on the leader's next tick
DELETE /api/v1/services/{id}/bucket-sources/{sid} 204
POST /api/v1/services/{id}/bucket-sources/{sid}/sync Sync now: 202 {"status":"queued"}; takes effect on the leader within 10 s

Writes (create, update, delete, sync) need the bucket_routing licence feature (403 otherwise); reads do not. A source of another service or tenant is 404.

Source CLI

The secret key can only come from an environment variable or stdin, never a plain flag, so it stays out of shell history.

gslbctl bucket-sources list   <service-id>
gslbctl bucket-sources get    <service-id> <source-id>
gslbctl bucket-sources add --name N --pool ID --endpoint URL --access-key AK \
    (--secret-key-env VAR | --secret-key-stdin) [--region R] [--priority N] [--interval S] [--disabled] [--ca-file PATH] <service-id>
gslbctl bucket-sources set [flags] <service-id> <source-id>   # only the flags you pass change
gslbctl bucket-sources delete <service-id> <source-id>
gslbctl bucket-sources sync   <service-id> <source-id>

Flags go before the positional arguments. set also takes --enabled true|false and --secret-key-env / --secret-key-stdin to replace the secret.

Terraform: resource nexus_bucket_source, import ID <service_id>/<source_id>.

Scale and propagation

  • Lookups are cached per node (database.cacheTTL, default 30 s), misses included, bounded at 200 000 entries so a flood of random bucket names cannot grow memory without limit. A wildcard service with no bucket map costs one cached boolean per TTL, not a lookup per name.
  • A write is visible on the node that took it immediately, and on the other nodes within the cache TTL. Clients then hold the answer for the service's ttl. For namespaces whose buckets move, keep the service ttl low (e.g. 30 s).
  • The map is stored with a composite primary key (service, bucket) and read by keyset pagination, so it is built for millions of rows. Listing never uses OFFSET.

What it does not do

  • Virtual-hosted style only (bucket.s3.example.com). Path-style requests (s3.example.com/bucket) put the bucket in the URL, which DNS never sees, so they cannot be steered. Point path-style traffic at a gateway that can proxy.
  • TLS is the storage system's job: every cluster endpoint needs a certificate for *.s3.example.com. [cert-manager or any ACME client(../user/ACMECertificates.md) can issue it against Nexus.
  • Not in config history. The map is excluded from [config snapshots(../user/ConfigHistory.md) — a restore does not touch it (a million-row table does not belong in a ring of snapshots). Reconcile from the vendor's inventory instead.
  • Nothing moves your data. Mapping a bucket to a cluster declares where it is; replicate or migrate the objects first, then flip the map.
  • No Terraform resource for the bucket map itself (a managed-resource model does not fit a map of millions of vendor-owned rows — use the API, gslbctl buckets import, or a sync job); bucket sources do have one, nexus_bucket_source. The query tracer (/api/v1/simulate) does not take a bucket yet; use dig or gslbctl buckets get.