Redis Cache Module
This module contains a Redis Cache, located in the redis
key.
The following snippets lists all available configuration options alongside their default values:
(import 'cloudflight-libsonnet/databases/redis.libsonnet')
+ {
_config+: {
redis: {
name: 'redis',
image: 'registry.redhat.io/rhel8/redis-6:1-62',
exporterImage: 'docker.io/oliver006/redis_exporter:v1.43.0',
password: error 'cfg.password must either be defined or set to null',
storage: null,
resources:: {
limits: {
cpu: '100m',
memory: '1Gi',
},
requests: {
cpu: '50m',
memory: '1Gi',
},
},
},
}
}
Starting multiple instances
Another way to use this module, is by calling the newRedis
function. This
allows you to create multiple instances without polluting the global scope.
{
_config+:: {
cacheOne: {
name: 'cacheOne',
password: 'foo',
},
cacheTwo: {
name: 'cacheTwo',
password: 'bar',
}
},
cacheOne: (import 'cloudflight-libsonnet/databases/redis.libsonnet').newRedis($._config.cacheOne),
cacheTwo: (import 'cloudflight-libsonnet/databases/redis.libsonnet').newRedis($._config.cacheTwo),
}
High Availability
If required, you can instead import the redis-sentinel
module. This creates an
additional sentinel deployment which fails over the master and replicas:
(import 'cloudflight-libsonnet/databases/redis-sentinel.libsonnet')
+ {
_config+: {
redis: {
name: 'redis',
replicas: 3,
sentinels: 3,
image: 'quay.io/fedora/redis-6:20221012',
exporterImage: 'docker.io/oliver006/redis_exporter:v1.43.0',
password: error 'cfg.password must either be defined or set to null',
topologyKey: 'kubernetes.io/hostname',
storage: null,
resources:: {
limits: {
cpu: '100m',
memory: '1Gi',
},
requests: {
cpu: '50m',
memory: '1Gi',
},
},
},
}
}
Exposed values
When using redis-sentinel
, you also have access to the following values. They are exposed, but not exported.
Name | Contents |
---|---|
redis.sentinelNodes |
Array of sentinel host:port pairs |