To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 657602d6 authored by Sandro Lutz's avatar Sandro Lutz
Browse files

Initial commit

parents
Pipeline #5719 failed with stage
in 59 seconds
stages:
- build
build_master:
stage: build
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- cd sentinel && docker build --pull -t "$CI_REGISTRY_IMAGE" ./
- docker push "$CI_REGISTRY_IMAGE"
only:
- master
# On branches except master: verify that build works, do not push to registry
build:
stage: build
image: docker:latest
services:
- docker:dind
script:
- cd sentinel && docker build --pull ./
except:
- master
# Redis Cluster on Docker Cluster (Docker Swarm Mode)
This project allows to easily run a HA Redis Cluster with Sentinel on a Docker Cluster (Docker Swarm Mode) with minimal manual interaction.
It is based on https://github.com/AliyunContainerService/redis-cluster
## Usage
You have to run services for `master`, `slave` and `sentinel`. The last one uses our own docker image `amiveth/redis-sentinel`.
```yaml
redis-master:
image: redis:4-alpine
redis-slave:
image: redis:4-alpine
command: redis-server --slaveof redis-master 6379
links:
- redis-master
sentinel:
build: amiv-eth/redis-sentinel
environment:
- SENTINEL_DOWN_AFTER=5000
- SENTINEL_FAILOVER=5000
- REDIS_MASTER=redis-master
links:
- redis-master
- redis-slave
```
FROM redis:3-alpine
# Set default configuration values (in ms)
ENV SENTINEL_QUORUM 2
ENV SENTINEL_DOWN_AFTER 30000
ENV SENTINEL_FAILOVER 180000
# Add configuration file and entrypoint script
COPY sentinel.conf /etc/redis/sentinel.conf
RUN chown redis:redis /etc/redis/sentinel.conf
COPY sentinel-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/sentinel-entrypoint.sh
EXPOSE 26379
ENTRYPOINT ["sentinel-entrypoint.sh"]
# Example sentinel.conf can be downloaded from http://download.redis.io/redis-stable/sentinel.conf
port 26379
dir /tmp
sentinel monitor mymaster {{REDIS_MASTER}} 6379 {{SENTINEL_QUORUM}}
sentinel down-after-milliseconds mymaster {{SENTINEL_DOWN_AFTER}}
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster {{SENTINEL_FAILOVER}}
#!/bin/sh
sed -i 's,{{REDIS_MASTER}},'"${REDIS_MASTER}"',g' /etc/redis/sentinel.conf
sed -i 's,{{SENTINEL_QUORUM}},'"${SENTINEL_QUORUM}"',g' /etc/redis/sentinel.conf
sed -i 's,{{SENTINEL_DOWN_AFTER}},'"${SENTINEL_DOWN_AFTER}"',g' /etc/redis/sentinel.conf
sed -i 's,{{SENTINEL_FAILOVER}},'"${SENTINEL_FAILOVER}"',g' /etc/redis/sentinel.conf
sed -i "s/\{{SENTINEL_QUORUM}}/$SENTINEL_QUORUM/g" /etc/redis/sentinel.conf
sed -i "s/\$SENTINEL_DOWN_AFTER/$SENTINEL_DOWN_AFTER/g" /etc/redis/sentinel.conf
sed -i "s/\$SENTINEL_FAILOVER/$SENTINEL_FAILOVER/g" /etc/redis/sentinel.conf
exec docker-entrypoint.sh redis-server /etc/redis/sentinel.conf --sentinel
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment