sanderploegsma / redis-cluster

Redis Cluster setup running on Kubernetes
https://sanderp.nl/running-redis-cluster-on-kubernetes-e451bda76cad
MIT License
246 stars 132 forks source link

Docker build fails (redis requires Ruby version >= 2.2.2) #2

Closed atomantic closed 6 years ago

atomantic commented 6 years ago

Looks like the public Redis image uses Jessie, which only has ruby 2.1 available.

ERROR:  Error installing redis:
    redis requires Ruby version >= 2.2.2.
The command '/bin/sh -c apt-get -y update   && apt-get -y upgrade   && apt-get -y --no-install-recommends install ruby   && gem install redis   && apt-get -y autoremove   && apt-get -y clean' returned a non-zero code: 1

I'm hacking away at it to get ruby >= 2.2.2 installed but figured I'd drop this here for posterity (and in case you know of a solution quicker than I am able to find one).

atomantic commented 6 years ago

I'm not sure what the gem install redis was about so I removed that from the Dockerfile and it builds and runs. Also needed to install wget.

New Dockerfile

FROM redis
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update \
  && apt-get -y upgrade \
  && apt-get -y autoremove \
  && apt-get -y clean \
  && apt-get install -y wget
RUN wget -O /usr/local/bin/redis-trib http://download.redis.io/redis-stable/src/redis-trib.rb
RUN chmod 755 /usr/local/bin/redis-trib
CMD redis-server
atomantic commented 6 years ago

Ah! redis-trib needs redis :) so that doesn't totally work.

atomantic commented 6 years ago

Alright, since I don't need redis-trib to actually be installed on the redis nodes themselves, I changed my setup a little:

The statefulset now references redis:latest from docker hub

kubectl create -f config.yml
kubectl create -f service.yml
kubectl create -f statefulset.yml

# create redis-trib pod so we can join the redis pods together
kubectl run redistrib --image=zvelo/redis-trib --command -- tail -f /etc/hosts

# tell redistrib to join the pods
REDIS_PODS=$(kubectl get pods -l app=redis-cluster -o jsonpath='{range.items[*]}{.status.podIP}:6379 ')
REDISTRIB=$(kubectl get pods -l run=redistrib -o jsonpath='{range.items[*]}{.metadata.name}')

kubectl exec -it $REDISTRIB bash

# in sub-shell
./redis-trib.rb create --replicas 1 $REDIS_PODS

Then I can delete the redistrib deployment until I need it later (if I need it later).

Thanks for getting me started :)

sanderploegsma commented 6 years ago

Thanks for opening the issue, I wasn't aware that this had become an issue. Anyway, I believe the easiest solution would be to pin the redis gem to a version that works with the ruby version shipped with Jessie.

I particularly like your solution too, having a dedicated pod for redis-trib instead of shipping it with all the others. This way you can run it as needed and don't have a Dockerfile to maintain. Thanks!