lhaig / nomad-redis

Published by Lance Haig | Raw HCL

job
0 stars
Description
Redis Database
License
MPL-2.0
Tags
#redis #database
Versions
Select a version to see its documentation and run command.
Quick Run (v0.0.1)
ramble job run lhaig/nomad-redis@v0.0.1
README
# Redis A fast in-memory data store for caching, sessions, and queues. ## Overview This job deploys [Redis](https://redis.io/) as a service job on Nomad. It includes sensible defaults for memory management and persistence. ## Requirements - Docker driver enabled on Nomad clients ## Usage ```bash nomad job run redis.nomad.hcl ``` With custom variables: ```bash nomad job run \ -var="memory=512" \ -var="maxmemory=400mb" \ redis.nomad.hcl ``` ## Variables | Name | Description | Default | |------|-------------|---------| | `datacenters` | List of datacenters to deploy to | `["dc1"]` | | `redis_version` | Redis Docker image tag | `7-alpine` | | `count` | Number of Redis instances | `1` | | `port` | Static port (0 for dynamic) | `0` | | `cpu` | CPU allocation in MHz | `500` | | `memory` | Memory allocation in MB | `256` | | `maxmemory` | Redis maxmemory setting | `200mb` | | `maxmemory_policy` | Eviction policy | `allkeys-lru` | | `service_provider` | Service discovery provider | `nomad` | ## Eviction Policies Available `maxmemory_policy` options: - `noeviction` - Return errors when memory limit reached - `allkeys-lru` - Evict least recently used keys (recommended for cache) - `volatile-lru` - Evict LRU keys with TTL set - `allkeys-random` - Evict random keys - `volatile-random` - Evict random keys with TTL set - `volatile-ttl` - Evict keys with shortest TTL ## Connecting From another Nomad job using Nomad service discovery templates: ```hcl template { data = <<EOF {{- range nomadService "redis" }} REDIS_ADDR={{ .Address }}:{{ .Port }} {{- end }} EOF destination = "local/env" env = true } ``` ## Persistence This job enables append-only file (AOF) persistence by default. Data survives container restarts but not node failures. For production, consider: - Using host volumes for persistent storage - Running Redis Sentinel or Redis Cluster for HA ## License MPL 2.0