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 debug rails application which is running inside docker container
  • Expressjs app started with PM2 in Docker dies with SIGINT
  • How to change the ownership of Docker-Tomcat log files?
  • Why I can't find ip_vs module or use ipvsadm when I add privileged
  • docker connect from container to public ip of host
  • Docker plugin : /src/main/docker/Dockerfile gradle-docker fails
  • 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?

  • How to import SHP file into docker PostgreSQL container?
  • Difference between Docker registry and repository
  • ElasticBeanstalk MultiContainer docker with nginx
  • exec not found using Dockerfile ENTRYPOINT
  • How to send http request from Docker to localhost or Virtual Machine
  • How to pull signed docker images using dockerode NodeJS API
  • 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.