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

  • nginx not starting inside Docker [duplicate]
  • deisctl list command raises a timeout error what am I doing wrong
  • Can I alias a subcommand? (shortening the output of `docker ps`)
  • Docker php_network_getaddresses error
  • Docker container connection to host
  • pycharm can't complete remote interpreter setup for Docker
  • 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?

  • ctrl+G in erl doesn't work
  • How can I pass build args with a remote image in docker-compose.yml?
  • App container to cassandra node - one to one or?
  • Ran docker container `--restart always` rebooted server, container/image did not restart
  • docker-machine amazon-ec2 fail during init
  • Kubernetes, Java and Grafana - How to display only the running containers?
  • 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 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

    • Add spec.template.spec.containers.command :
    spec:
      containers:
      - 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)
        livenessProbe:
          failureThreshold: 3
          initialDelaySeconds: 30
          periodSeconds: 10
          successThreshold: 1
          tcpSocket:
            port: 5000
    
    • Now change the readinessProbe adding “-p $PORT” in test command :
        readinessProbe:
          exec:
            command:
            - /bin/sh
            - -i
            - -c
            - test "$(redis-cli -h 127.0.0.1 -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)
     ports:
        - containerPort: 5000
          protocol: TCP
    
    $ oc edit dc redis
    

    Hope it helped 🙂

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