Unverified Commit 662e516d authored by Sandeep Rawat's avatar Sandeep Rawat Committed by GitHub

Merge pull request #14 from OT-CONTAINER-KIT/redis-7

[Enhancement][Add] Added support for Redis 7
parents 95ce711e fac68559
......@@ -17,9 +17,7 @@ RUN curl -fL -Lo /tmp/redis-${REDIS_VERSION}.tar.gz ${REDIS_DOWNLOAD_URL}/redis-
tar xvzf redis-${REDIS_VERSION}.tar.gz && \
cd redis-${REDIS_VERSION} && \
make && \
make install BUILD_TLS=yes && \
mkdir -p /etc/redis && \
cp -f *.conf /etc/redis
make install BUILD_TLS=yes
FROM alpine:3.15
......@@ -31,9 +29,8 @@ LABEL VERSION=1.0 \
COPY --from=builder /usr/local/bin/redis-server /usr/local/bin/redis-server
COPY --from=builder /usr/local/bin/redis-cli /usr/local/bin/redis-cli
COPY --from=builder /etc/redis /etc/redis
RUN addgroup -S -g 1001 redis && adduser -S -G redis -u 1001 redis && \
RUN addgroup -S -g 1000 redis && adduser -S -G redis -u 1000 redis && \
apk add --no-cache bash
COPY redis.conf /etc/redis/redis.conf
......@@ -44,9 +41,6 @@ COPY setupMasterSlave.sh /usr/bin/setupMasterSlave.sh
COPY healthcheck.sh /usr/bin/healthcheck.sh
RUN mkdir -p /opt/redis/ && \
chmod -R g+rwX /etc/redis /opt/redis
VOLUME ["/data"]
WORKDIR /data
......
......@@ -2,7 +2,7 @@ FROM alpine:3.15 as builder
ARG EXPORTER_URL="https://github.com/oliver006/redis_exporter/releases/download"
ARG REDIS_EXPORTER_VERSION="1.5.2"
ARG REDIS_EXPORTER_VERSION="1.44.0"
RUN apk add --no-cache curl ca-certificates && \
curl -fL -Lo /tmp/redis_exporter-v${REDIS_EXPORTER_VERSION}.linux-amd64.tar.gz \
......
REDIS_VERSION ?= 6.2.5
EXPORTER_VERSION?=1.0
REDIS_VERSION ?= v7.0.5
EXPORTER_VERSION ?= v1.44.0
build-redis-image:
docker build -t quay.io/opstree/redis:$(REDIS_VERSION) -f Dockerfile .
......
......@@ -2,20 +2,17 @@
set -a
CLUSTER_DIRECTORY=${CLUSTER_DIRECTORY:-"/opt/redis"}
PERSISTENCE_ENABLED=${PERSISTENCE_ENABLED:-"false"}
DATA_DIR=${DATA_DIR:-"/data"}
EXTERNAL_CONFIG_FILE=${EXTERNAL_CONFIG_FILE:-"/etc/redis/external.conf.d/redis-external.conf"}
REDIS_MAJOR_VERSION=${REDIS_MAJOR_VERSION:-"v7"}
apply_permissions() {
chgrp -R 0 /etc/redis
chgrp -R 1000 /etc/redis
chmod -R g=u /etc/redis
chgrp -R 0 /opt
chmod -R g=u /opt
}
common_operation() {
mkdir -p "${CLUSTER_DIRECTORY}"
mkdir -p "${DATA_DIR}"
}
......@@ -40,11 +37,12 @@ redis_mode_setup() {
echo cluster-config-file "${DATA_DIR}/nodes.conf"
} >> /etc/redis/redis.conf
if [[ "${REDIS_MAJOR_VERSION}" != "v7" ]]; then
if [[ -z "${POD_IP}" ]]; then
POD_IP=$(hostname -i)
fi
sed -i -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/" "${DATA_DIR}/nodes.conf"
fi
else
echo "Setting up redis in standalone mode"
fi
......@@ -95,7 +93,11 @@ external_config() {
start_redis() {
if [[ "${SETUP_MODE}" == "cluster" ]]; then
echo "Starting redis service in cluster mode....."
if [[ "${REDIS_MAJOR_VERSION}" != "v7" ]]; then
redis-server /etc/redis/redis.conf --cluster-announce-ip "${POD_IP}"
else
redis-server /etc/redis/redis.conf
fi
else
echo "Starting redis service in standalone mode....."
redis-server /etc/redis/redis.conf
......
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