5.0.10-debian-10-r36 release

This commit is contained in:
Bitnami Bot 2020-12-14 10:23:47 +00:00
parent 2ca73e9f51
commit d68a756d08
4 changed files with 74 additions and 61 deletions

View File

@ -18,7 +18,7 @@ RUN chmod g+rwX /opt/bitnami
COPY rootfs /
RUN /opt/bitnami/scripts/redis-cluster/postunpack.sh
ENV BITNAMI_APP_NAME="redis-cluster" \
BITNAMI_IMAGE_VERSION="5.0.10-debian-10-r35" \
BITNAMI_IMAGE_VERSION="5.0.10-debian-10-r36" \
PATH="/opt/bitnami/redis/bin:/opt/bitnami/common/bin:$PATH"
EXPOSE 6379

View File

@ -69,6 +69,10 @@ redis_cluster_validate() {
[[ -z "$REDIS_CLUSTER_REPLICAS" ]] && print_validation_error "To create the cluster you need to provide the number of replicas"
fi
if ((REDIS_CLUSTER_SLEEP_BEFORE_DNS_LOOKUP < 0)); then
print_validation_error "REDIS_CLUSTER_SLEEP_BEFORE_DNS_LOOKUP must be greater or equal to zero"
fi
[[ "$error_code" -eq 0 ]] || exit "$error_code"
}
@ -116,35 +120,41 @@ redis_cluster_initialize() {
# None
#########################
redis_cluster_create() {
local nodes=("$@")
local ips=()
local wait_command
local create_command
local nodes=("$@")
local ips=()
local wait_command
local create_command
for node in "${nodes[@]}"; do
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
wait_command="redis-cli -h ${node} -p ${REDIS_TLS_PORT} --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} ping"
else
wait_command="redis-cli -h ${node} -p ${REDIS_PORT_NUMBER} ping"
fi
while [[ $($wait_command) != 'PONG' ]]; do
echo "Node $node not ready, waiting for all the nodes to be ready..."
sleep 1
done
ips+=($(dns_lookup "$node"))
done
for node in "${nodes[@]}"; do
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
wait_command="redis-cli -h ${node} -p ${REDIS_TLS_PORT} --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} ping"
else
wait_command="redis-cli -h ${node} -p ${REDIS_PORT_NUMBER} ping"
fi
while [[ $($wait_command) != 'PONG' ]]; do
echo "Node $node not ready, waiting for all the nodes to be ready..."
sleep 1
done
done
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
create_command="redis-cli --cluster create ${ips[*]/%/:${REDIS_TLS_PORT}} --cluster-replicas ${REDIS_CLUSTER_REPLICAS} --cluster-yes --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE}"
else
create_command="redis-cli --cluster create ${ips[*]/%/:${REDIS_PORT_NUMBER}} --cluster-replicas ${REDIS_CLUSTER_REPLICAS} --cluster-yes"
fi
yes yes | $create_command || true
if redis_cluster_check "${ips[0]}"; then
echo "Cluster correctly created"
else
echo "The cluster was already created, the nodes should have recovered it"
fi
echo "Waiting ${REDIS_CLUSTER_SLEEP_BEFORE_DNS_LOOKUP}s before querying node ip addresses"
sleep "${REDIS_CLUSTER_SLEEP_BEFORE_DNS_LOOKUP}"
for node in "${nodes[@]}"; do
ips+=("$(wait_for_dns_lookup "${node}" "${REDIS_CLUSTER_DNS_LOOKUP_RETRIES}" "${REDIS_CLUSTER_DNS_LOOKUP_SLEEP}")")
done
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
create_command="redis-cli --cluster create ${ips[*]/%/:${REDIS_TLS_PORT}} --cluster-replicas ${REDIS_CLUSTER_REPLICAS} --cluster-yes --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE}"
else
create_command="redis-cli --cluster create ${ips[*]/%/:${REDIS_PORT_NUMBER}} --cluster-replicas ${REDIS_CLUSTER_REPLICAS} --cluster-yes"
fi
yes yes | $create_command || true
if redis_cluster_check "${ips[0]}"; then
echo "Cluster correctly created"
else
echo "The cluster was already created, the nodes should have recovered it"
fi
}
#########################
@ -175,18 +185,18 @@ redis_cluster_check() {
# None
#########################
redis_cluster_update_ips() {
IFS=' ' read -ra nodes <<< "$REDIS_NODES"
IFS=' ' read -ra nodes <<<"$REDIS_NODES"
declare -A host_2_ip_array # Array to map hosts and IPs
# Update the IPs when a number of nodes > quorum change their IPs
if [[ ! -f "${REDIS_DATA_DIR}/nodes.sh" ]]; then
if [[ ! -f "${REDIS_DATA_DIR}/nodes.sh" ]]; then
# It is the first initialization so store the nodes
for node in "${nodes[@]}"; do
ip=$(wait_for_dns_lookup "$node" "$REDIS_DNS_RETRIES" 5)
host_2_ip_array["$node"]="$ip"
done
echo "Storing map with hostnames and IPs"
declare -p host_2_ip_array > "${REDIS_DATA_DIR}/nodes.sh"
declare -p host_2_ip_array >"${REDIS_DATA_DIR}/nodes.sh"
else
# The cluster was already started
. "${REDIS_DATA_DIR}/nodes.sh"
@ -197,10 +207,10 @@ redis_cluster_update_ips() {
if [[ ${host_2_ip_array[$node]+true} ]]; then
echo "Changing old IP ${host_2_ip_array[$node]} by the new one ${newIP}"
nodesFile=$(sed "s/${host_2_ip_array[$node]}/$newIP/g" "${REDIS_DATA_DIR}/nodes.conf")
echo "$nodesFile" > "${REDIS_DATA_DIR}/nodes.conf"
echo "$nodesFile" >"${REDIS_DATA_DIR}/nodes.conf"
fi
host_2_ip_array["$node"]="$newIP"
done
declare -p host_2_ip_array > "${REDIS_DATA_DIR}/nodes.sh"
declare -p host_2_ip_array >"${REDIS_DATA_DIR}/nodes.sh"
fi
}

View File

@ -45,6 +45,9 @@ redis_cluster_env_vars=(
REDIS_CLUSTER_ANNOUNCE_IP
REDIS_DNS_RETRIES
REDIS_NODES
REDIS_CLUSTER_SLEEP_BEFORE_DNS_LOOKUP
REDIS_CLUSTER_DNS_LOOKUP_RETRIES
REDIS_CLUSTER_DNS_LOOKUP_SLEEP
REDIS_TLS_PORT
)
for env_var in "${redis_cluster_env_vars[@]}"; do
@ -107,5 +110,8 @@ export REDIS_CLUSTER_DYNAMIC_IPS="${REDIS_CLUSTER_DYNAMIC_IPS:-yes}"
export REDIS_CLUSTER_ANNOUNCE_IP="${REDIS_CLUSTER_ANNOUNCE_IP:-}"
export REDIS_DNS_RETRIES="${REDIS_DNS_RETRIES:-120}"
export REDIS_NODES="${REDIS_NODES:-}"
export REDIS_CLUSTER_SLEEP_BEFORE_DNS_LOOKUP="${REDIS_CLUSTER_SLEEP_BEFORE_DNS_LOOKUP:-0}"
export REDIS_CLUSTER_DNS_LOOKUP_RETRIES="${REDIS_CLUSTER_DNS_LOOKUP_RETRIES:-1}"
export REDIS_CLUSTER_DNS_LOOKUP_SLEEP="${REDIS_CLUSTER_DNS_LOOKUP_SLEEP:-1}"
# Custom environment variables may be defined below

View File

@ -40,7 +40,7 @@ Learn more about the Bitnami tagging policy and the difference between rolling t
* [`6.0`, `6.0-debian-10`, `6.0.9`, `6.0.9-debian-10-r33`, `latest` (6.0/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-redis-cluster/blob/6.0.9-debian-10-r33/6.0/debian-10/Dockerfile)
* [`5.0`, `5.0-debian-10`, `5.0.10`, `5.0.10-debian-10-r35` (5.0/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-redis-cluster/blob/5.0.10-debian-10-r35/5.0/debian-10/Dockerfile)
* [`5.0`, `5.0-debian-10`, `5.0.10`, `5.0.10-debian-10-r36` (5.0/debian-10/Dockerfile)](https://github.com/bitnami/bitnami-docker-redis-cluster/blob/5.0.10-debian-10-r36/5.0/debian-10/Dockerfile)
Subscribe to project updates by watching the [bitnami/redis-cluster GitHub repo](https://github.com/bitnami/bitnami-docker-redis-cluster).
@ -141,33 +141,30 @@ services:
Refer to the [Redis configuration](http://redis.io/topics/config) manual for the complete list of configuration options.
The following env vars are supported for this container:
| Name | Description |
|-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `REDIS_DISABLE_COMMANDS` | Disables the specified Redis commands |
| `REDIS_PORT` | Set the Redis port. Default=: `6379` |
| `REDIS_PASSWORD` | Set the Redis password. Default: `bitnami` |
| `ALLOW_EMPTY_PASSWORD` | Enables access without password |
| `REDIS_DNS_RETRIES` | Number of retries to get the IPs of the provided `REDIS_NODES`. It will wait 5 seconds between retries |
| `REDISCLI_AUTH` | Provide the same value as the configured `REDIS_PASSWORD` for the redis-cli tool to authenticate |
| `REDIS_CLUSTER_CREATOR` | Set to `yes` if the container will be the one on charge of initialize the cluster. This node will not be part of the cluster, it will complete the execution after the initialization. |
| `REDIS_CLUSTER_REPLICAS` | Number of replicas for every master that the cluster will have. |
| `REDIS_NODES` | String delimited by spaces containing the hostnames of all of the nodes that will be part of the cluster |
| `REDIS_CLUSTER_ANNOUNCE_IP` | IP that the node should announce, used for non dynamic ip environents |
| `REDIS_CLUSTER_DYNAMIC_IPS` | Set to `no` if your Redis cluster will be created with statical IPs. Default: `yes` |
| `REDIS_TLS_ENABLED` | Whether to enable TLS for traffic or not. Defaults to `no`. |
| `REDIS_TLS_PORT` | Port used for TLS secure traffic. Defaults to `6379`. |
| `REDIS_TLS_CERT_FILE` | File containing the certificate file for the TSL traffic. No defaults. |
| `REDIS_TLS_KEY_FILE` | File containing the key for certificate. No defaults. |
| `REDIS_TLS_CA_FILE` | File containing the CA of the certificate. No defaults. |
| `REDIS_TLS_DH_PARAMS_FILE` | File containing DH params (in order to support DH based ciphers). No defaults. |
| `REDIS_TLS_AUTH_CLIENTS` | Whether to require clients to authenticate or not. Defaults to `yes`. |
| `REDIS_CLUSTER_SLEEP_BEFORE_DNS_LOOKUP` | Number of seconds to wait before initializing the cluster. Set this to a higher value if you sometimes have issues with initial cluster creation. Defaults to `0`. |
| `REDIS_CLUSTER_DNS_LOOKUP_RETRIES` | Number of retries for the node's DNS lookup during the initial cluster creation. Defaults to `5`. |
| `REDIS_CLUSTER_DNS_LOOKUP_SLEEP` | Number of seconds to wait between each node's DNS lookup during the initial cluster creation. Defaults to `1`. |
| Name | Description |
|-----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `REDIS_DISABLE_COMMANDS` | Disables the specified Redis commands |
| `REDIS_PORT` | Set the Redis port. Default=: `6379` |
| `REDIS_PASSWORD` | Set the Redis password. Default: `bitnami` |
| `ALLOW_EMPTY_PASSWORD` | Enables access without password |
| `REDIS_DNS_RETRIES` | Number of retries to get the IPs of the provided `REDIS_NODES`. It will wait 5 seconds between retries |
| `REDISCLI_AUTH` | Provide the same value as the configured `REDIS_PASSWORD` for the redis-cli tool to authenticate |
| `REDIS_CLUSTER_CREATOR` | Set to `yes` if the container will be the one on charge of initialize the cluster. This node will not be part of the cluster, it will complete the execution after the initialization. |
| `REDIS_CLUSTER_REPLICAS` | Number of replicas for every master that the cluster will have. |
| `REDIS_NODES` | String delimited by spaces containing the hostnames of all of the nodes that will be part of the cluster |
| `REDIS_CLUSTER_ANNOUNCE_IP` | IP that the node should announce, used for non dynamic ip environents |
| `REDIS_CLUSTER_DYNAMIC_IPS` | Set to `no` if your Redis cluster will be created with statical IPs. Default: `yes` |
| `REDIS_TLS_ENABLED` | Whether to enable TLS for traffic or not. Defaults to `no`. |
| `REDIS_TLS_PORT` | Port used for TLS secure traffic. Defaults to `6379`. |
| `REDIS_TLS_CERT_FILE` | File containing the certificate file for the TSL traffic. No defaults. |
| `REDIS_TLS_KEY_FILE` | File containing the key for certificate. No defaults. |
| `REDIS_TLS_CA_FILE` | File containing the CA of the certificate. No defaults. |
| `REDIS_TLS_DH_PARAMS_FILE` | File containing DH params (in order to support DH based ciphers). No defaults. |
| `REDIS_TLS_AUTH_CLIENTS` | Whether to require clients to authenticate or not. Defaults to `yes`. |
| `REDIS_CLUSTER_SLEEP_BEFORE_DNS_LOOKUP` | Number of seconds to wait before initializing the cluster. Set this to a higher value if you sometimes have issues with initial cluster creation. Defaults to `0`. |
| `REDIS_CLUSTER_DNS_LOOKUP_RETRIES` | Number of retries for the node's DNS lookup during the initial cluster creation. Defaults to `5`. |
| `REDIS_CLUSTER_DNS_LOOKUP_SLEEP` | Number of seconds to wait between each node's DNS lookup during the initial cluster creation. Defaults to `1`. |
Once all the Redis nodes are running you need to execute command like the following to initiate the cluster:
@ -180,7 +177,7 @@ Where you can add all the `node:port` that you want. The `--cluster-replicas` pa
## Cluster Initialization Troubleshooting
Depending on the environment you're deploying into, you might run into issues where the cluster initialization
is not completing successfully. One of the issue is related to the DNS lookup of the redis nodes performed during
is not completing successfully. One of the issue is related to the DNS lookup of the redis nodes performed during
cluster initialization. By default, this DNS lookup is performed as soon as all the redis nodes reply to
a successful ping. However, in some environments such as Kubernetes, it can help to wait some time before
performing this DNS lookup in order to prevent getting stale records. To this end, you can increase