Skip to content

Deploy Redis Operator, Redis Replication Cluster and Redis Sentinel

Deploy the Redis operator and replication cluster

Genestack primarily makes use of the popular opensource Redis in-memory database to support various services that utilize Taskflow and Jobboard functionality. One such service is Octavia, which uses Redis to track tasks across the Octavia cluster in a HA fashion ensuring that tasks can still be completed in the event of a partial outage of the Octavia system.

In order to take advantage of the Redis system in a HA way we deploy Redis Replication and Redis Sentinel to handle the needs of a clustered, HA Redis deployment.

Tip

As noted in the Sentinel Docs we must deploy the Redis Operator and Replication cluster prior to deploying Sentinel. Below are the steps to achieve this.

CLUSTER_NAME=`kubectl config view --minify -o jsonpath='{.clusters[0].name}'`
echo $CLUSTER_NAME

If cluster_name was anything other than cluster.local you should pass that as a parameter to the installer

Run the redis-operator deployment Script /opt/genestack/bin/install-redis-operator.sh You can include cluster_name paramater from the output of $CLUSTER_NAME. If no paramaters are provided, the system will deploy with cluster.local as the cluster name.

#!/bin/bash
# shellcheck disable=SC2124,SC2145,SC2294

CONFIG_DIR="/etc/genestack/helm-configs/redis-operator-replication"

# Read redis-operator version from helm-chart-versions.yaml
VERSION_FILE="/etc/genestack/helm-chart-versions.yaml"
if [ ! -f "$VERSION_FILE" ]; then
    echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE"
    exit 1
fi

# Extract redis-operator version using grep and sed
REDIS_OPERATOR_VERSION=$(grep 'redis-operator:' "$VERSION_FILE" | sed 's/.*redis-operator: *//')

if [ -z "$REDIS_OPERATOR_VERSION" ]; then
    echo "Error: Could not extract redis-operator version from $VERSION_FILE"
    exit 1
fi

# Extract redis-replication version using grep and sed
REDIS_REPLICATION_VERSION=$(grep 'redis-replication:' "$VERSION_FILE" | sed 's/.*redis-replication: *//')

if [ -z "$REDIS_REPLICATION_VERSION" ]; then
    echo "Error: Could not extract redis-replication version from $VERSION_FILE"
    exit 1
fi

# Add the redis-operator helm repository
helm repo add ot-helm https://ot-container-kit.github.io/helm-charts/
helm repo update

# Install the Operator and CRDs that match the version defined
helm upgrade --install --namespace=redis-systems --create-namespace redis-operator ot-helm/redis-operator --version "${REDIS_OPERATOR_VERSION}"

# Helm command setup for Redis replication cluster
HELM_CMD="helm upgrade --install redis-replication ot-helm/redis-replication --version ${REDIS_REPLICATION_VERSION} \
    --namespace=redis-systems \
    --timeout 120m \
    -f /opt/genestack/base-helm-configs/redis-operator-replication/redis-replication-helm-overrides.yaml"

# Check if YAML files exist in the specified directory
if compgen -G "${CONFIG_DIR}/*.yaml" > /dev/null; then
    # Add all YAML files from the directory to the helm command
    for yaml_file in "${CONFIG_DIR}"/*.yaml; do
        HELM_CMD+=" -f ${yaml_file}"
    done
fi

HELM_CMD+=" $@"

# Run the helm command
echo "Executing Helm command:"
echo "${HELM_CMD}"
eval "${HELM_CMD}"

Verify Redis Operator and Replication cluster readiness with the following command

kubectl --namespace redis-systems get pods -w

Deploy the Redis Sentinel

Run the redis-sentinel deployment Script /opt/genestack/bin/install-redis-sentinel.sh

#!/bin/bash
# shellcheck disable=SC2124,SC2145,SC2294

CONFIG_DIR="/etc/genestack/helm-configs/redis-sentinel"

# Read redis-operator version from helm-chart-versions.yaml
VERSION_FILE="/etc/genestack/helm-chart-versions.yaml"
if [ ! -f "$VERSION_FILE" ]; then
    echo "Error: helm-chart-versions.yaml not found at $VERSION_FILE"
    exit 1
fi

# Extract redis-sentinel version using grep and sed
REDIS_SENTINEL_VERSION=$(grep 'redis-sentinel:' "$VERSION_FILE" | sed 's/.*redis-sentinel: *//')

if [ -z "$REDIS_SENTINEL_VERSION" ]; then
    echo "Error: Could not extract redis-sentinel version from $VERSION_FILE"
    exit 1
fi

# Add the redis-operator helm repository
helm repo add ot-helm https://ot-container-kit.github.io/helm-charts/
helm repo update

# Helm command setup for Redis Sentinel
HELM_CMD="helm upgrade --install redis-sentinel ot-helm/redis-sentinel --version ${REDIS_SENTINEL_VERSION} \
    --namespace=redis-systems \
    --timeout 120m \
    -f /opt/genestack/base-helm-configs/redis-sentinel/redis-sentinel-helm-overrides.yaml"

# Check if YAML files exist in the specified directory
if compgen -G "${CONFIG_DIR}/*.yaml" > /dev/null; then
    # Add all YAML files from the directory to the helm command
    for yaml_file in "${CONFIG_DIR}"/*.yaml; do
        HELM_CMD+=" -f ${yaml_file}"
    done
fi

HELM_CMD+=" $@"

# Run the helm command
echo "Executing Helm command:"
echo "${HELM_CMD}"
eval "${HELM_CMD}"

Verify Sentinel readiness with the following command

kubectl --namespace redis-systems get pods -w