Overview
Runs the upstream redis-server with a generated configuration that sets the port, maxmemory and maxmemory-policy, and binds every address. Each replica is an independent Redis: the runtime does not set up replication between them, and its data directory is private to the unit, so data does not survive a restart. Treat it as a cache.
- Shape
- Replicas, independent
- Reached at
- Node port, or a VIP
- Node package
pkgs.redis
Fetched on demand: the first time a block of this type is placed on a node, its agent fetches pkgs.redis, built from the node's own nixpkgs so the NixOS binary cache serves it. That first placement needs network access (or a binary cache on the LAN) and waits for the download; later placements on that node start at once.
Example
apiVersion: expanse.io/v1 kind: Block metadata: name: cache namespace: default spec: type: db/redis replicas: 1 resources: requests: cpu: 100m memory: 128Mi config: port: 16379 maxMemory: 64mb maxMemoryPolicy: allkeys-lru
$ expanse ctl block apply -f redis.yaml --dry-run # validate only $ expanse ctl block apply -f redis.yaml
Configuration
Keys go under spec.config and are checked against the type's JSON Schema when the block is applied. A default is what the block uses when the key is unset.
| Key | Default | Meaning |
|---|---|---|
port | none: always set it | TCP port Redis listens on. Unset, the runtime writes port 0, which turns off the TCP listener. The deploy form sets 16379 and puts 6379 on the VIP. |
maxMemory | 256mb | maxmemory. |
maxMemoryPolicy | none: always set it | maxmemory-policy, one of noeviction, allkeys-lru, volatile-lru, allkeys-random, volatile-random, volatile-ttl. |
appendOnly | none | Accepted by the schema but not applied. |
replicaOf | none | Accepted by the schema but not applied. |
password | none | Accepted by the schema but not applied: there is no requirepass, so anyone who reaches the port can connect. Sealed: kept out of the stored block (block secrets). |
Using it
$ redis-cli -h <node address> -p 16379 ping PONG
Keep the port on a network you trust: the server has no password.
When a node fails
A failed node's replica is placed again on another node after the unreachable grace (30 s) and starts empty.
Limits
- No persistence: the data directory is private to the unit and is discarded when it stops.
- No replication or failover between replicas, although the type's description mentions a primary-replica strategy.
- No authentication:
passwordis ignored.
Source
- nix/blocks/db/redis: the type's identity and JSON Schema.