Reputation: 1425
I have successfully deployed Redis (persistent) image on my OpenShift installation. Now I want to persist the Redis configuration, and I have followed this instructions.
However, the Redis is started with this command inside a container:
/opt/rh/rh-redis32/root/usr/bin/redis-server *:6379
I see that it should be started with the first argument as a path to the configuration file in order to configure itself on startup.
How can I achieve this in OpenShift?
Upvotes: 0
Views: 4206
Reputation: 1425
I solved this issue with run commands specified in deployment config:
containers:
- name: redis
image: >-
centos/redis-32-centos7@sha256:7289ff47dd1c5bd24e6eefaf18cfbacf5ad68c0768f1b727a79c026bbef5a038
command:
- /opt/rh/rh-redis32/root/usr/bin/redis-server
- /redis-master/redis.conf
Since this completly overrides default startup behaviof of the provided Docker image I had to add dir and requirepass configs to my config map:
dir /var/lib/redis/data
requirepass srid
maxmemory 2mb
maxmemory-policy allkeys-lru
Upvotes: 3
Reputation: 374
I'm not sure you are supposed to try that kind of stuff ;) But you can use that workaround (not using it in production could be a good idea)
First of all create download your config file :
$ curl -o redis.conf http://download.redis.io/redis-stable/redis.conf
$ curl -o run-redis https://raw.githubusercontent.com/sclorg/redis-container/master/3.2/root/usr/bin/run-redis
Then edit redis.conf and change the values you want
$ vi redis.conf
Now edit run-redis and replace last line with :
exec ${REDIS_PREFIX}/bin/redis-server /tmp/redis.conf --daemonize no "$@" 2>&1
$ vi run-redis
Now you have to create a configMap from these files :
$ oc create configmap myredisconfig --from-file=redis.conf --from-file=run-redis
And mount the configmap into the container:
$ oc volume dc/redis --add --name=conf --type=configmap --configmap-name=myredisconfig --mount-path=/tmp
Finally edit redis dc:
Let's suppose I changed port 6379 to port 5000 in my redis.conf
spec: containers: - command: - /tmp/run-redis
- configMap: defaultMode: 444 name: myredisconfig name: conf
livenessProbe: failureThreshold: 3 initialDelaySeconds: 30 periodSeconds: 10 successThreshold: 1 tcpSocket: port: 5000
readinessProbe: exec: command: - /bin/sh - -i - -c - test "$(redis-cli -h 127.0.0.1 -p 5000 -a $REDIS_PASSWORD ping)" == "PONG"
ports: - containerPort: 5000 protocol: TCP
$ oc edit dc redis
Hope it helped :)
Upvotes: 0