OpenShift and persistent Redis config

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

  • How to set a time limit for a Kubernetes job?
  • Docker not running on OS/X
  • How to allocate 50% CPU resource to docker container?
  • Extending Docker JBoss WildFly server not working
  • Bash run docker command only if user has privileges (Bash if or statement)
  • Configure Dockerfile to use impdp command when the container is created
  • 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?

  • Mocking 3rd party API calls without changing code
  • Docker Remote API Build with Node and Dockerode
  • Ensure nginx master process stays running
  • Cassandra docker - unable to connect through JMX
  • Find the docker containers using an image?
  • Building a compiled application with Docker
  • 2 Solutions collect form web for “OpenShift and persistent Redis config”

    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
    $ curl -o 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

    • Add spec.template.spec.containers.command :
      - command:
        - /tmp/run-redis
    • Change spec.template.spec.volumes.configMap.defaultMode to 444
      - configMap:
          defaultMode: 444
          name: myredisconfig
        name: conf
    • If you are using an image with healthchecks, don’t forget to change ports to check with your new one, or it will fail (spec.template.spec.containers.livenessProbe.tcpSocket.port)
          failureThreshold: 3
          initialDelaySeconds: 30
          periodSeconds: 10
          successThreshold: 1
            port: 5000
    • Now change the readinessProbe adding “-p $PORT” in test command :
            - /bin/sh
            - -i
            - -c
            - test "$(redis-cli -h -p 5000 -a $REDIS_PASSWORD ping)" == "PONG"
    • Don’t forget to change ContainerPort: 6379 with you new port, or you won’t be able to expose it to services & routes (spec.template.spec.ports)
        - containerPort: 5000
          protocol: TCP
    $ oc edit dc redis

    Hope it helped 🙂

    I solved this issue with run commands specified in deployment config:

            - name: redis
              image: >-
                - /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
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.