Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

feat(helm-chart): update helm release redis to 18.5.0 #3323

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

trux-bot[bot]
Copy link
Contributor

@trux-bot trux-bot bot commented Nov 8, 2023

This PR contains the following updates:

Package Update Change
redis (source) minor 18.2.1 -> 18.5.0

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Renovate Bot.

@trux-bot trux-bot bot requested a review from truxnell as a code owner November 8, 2023 22:09
@trux-bot trux-bot bot changed the title fix(helm-chart): update helm release redis to 18.2.2 feat(helm-chart): update helm release redis to 18.3.0 Nov 9, 2023
@trux-bot trux-bot bot force-pushed the renovate/redis-18.x branch from fe4c9c3 to d1a4728 Compare November 9, 2023 11:08
@trux-bot trux-bot bot changed the title feat(helm-chart): update helm release redis to 18.3.0 feat(helm-chart): update helm release redis to 18.3.1 Nov 9, 2023
@trux-bot trux-bot bot force-pushed the renovate/redis-18.x branch from d1a4728 to 90584d0 Compare November 9, 2023 18:12
@trux-bot trux-bot bot changed the title feat(helm-chart): update helm release redis to 18.3.1 fix(helm-chart): update helm release redis to 18.2.2 Nov 9, 2023
@trux-bot trux-bot bot force-pushed the renovate/redis-18.x branch from 90584d0 to 970230e Compare November 9, 2023 23:09
@trux-bot trux-bot bot changed the title fix(helm-chart): update helm release redis to 18.2.2 feat(helm-chart): update helm release redis to 18.3.1 Nov 10, 2023
@trux-bot trux-bot bot force-pushed the renovate/redis-18.x branch 2 times, most recently from 2a7e58f to ed29e2e Compare November 10, 2023 09:11
@trux-bot trux-bot bot changed the title feat(helm-chart): update helm release redis to 18.3.1 feat(helm-chart): update helm release redis to 18.3.2 Nov 10, 2023
@trux-bot
Copy link
Contributor Author

trux-bot bot commented Nov 10, 2023

Helm Release: kubernetes/apps/databases/redis-sentinel/app/helmrelease.yaml

spec.template.spec.containers.redis.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis:7.2.3-debian-11-r0
    + docker.io/bitnami/redis:7.2.3-debian-11-r1

spec.template.spec.containers.sentinel.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis-sentinel:7.2.3-debian-11-r0
    + docker.io/bitnami/redis-sentinel:7.2.3-debian-11-r1

spec.template.spec.containers.metrics.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis-exporter:1.55.0-debian-11-r0
    + docker.io/bitnami/redis-exporter:1.55.0-debian-11-r2

@trux-bot trux-bot bot changed the title feat(helm-chart): update helm release redis to 18.3.2 feat(helm-chart): update helm release redis to 18.3.3 Nov 14, 2023
@trux-bot trux-bot bot force-pushed the renovate/redis-18.x branch from ed29e2e to 112019e Compare November 14, 2023 10:11
@trux-bot
Copy link
Contributor Author

trux-bot bot commented Nov 14, 2023

Helm Release: kubernetes/apps/databases/redis-sentinel/app/helmrelease.yaml

data.start-node.sh  (v1/ConfigMap/default/redis-scripts)
  ± value change
    - #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/liblog.sh
      . /opt/bitnami/scripts/libvalidations.sh
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      
      if [ -n "$REDIS_EXTERNAL_MASTER_HOST" ]; then
          REDIS_SERVICE="$REDIS_EXTERNAL_MASTER_HOST"
      else
          REDIS_SERVICE="redis.default.svc.cluster.local"
      fi
      
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      validate_quorum() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel master redis-master"
          else
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel master redis-master"
          fi
          info "about to run the command: $quorum_info_command"
          eval $quorum_info_command | grep -Fq "s_down"
      }
      
      trigger_manual_failover() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel failover redis-master"
          else
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel failover redis-master"
          fi
      
          info "about to run the command: $failover_command"
          eval $failover_command
      }
      
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
      
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 1
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      [[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
      
      # check if there is a master
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      master_port_in_persisted_conf="$REDIS_MASTER_PORT_NUMBER"
      master_in_sentinel="$(get_sentinel_master_info)"
      redisRetVal=$?
      
      if [[ $redisRetVal -ne 0 ]]; then
          if [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 1: No active sentinel and in previous sentinel.conf we were the master --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 2: No active sentinel and in previous sentinel.conf we were not master --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
              REDIS_MASTER_HOST=${master_in_persisted_conf}
              REDIS_MASTER_PORT_NUMBER=${master_port_in_persisted_conf}
          fi
      else
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "Current master: REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      
          if [[ "$REDIS_MASTER_HOST" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 3: Active sentinel and master it is this node --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 4: Active sentinel and master is not this node --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
          fi
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/replica.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/redis.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
      fi
      
      echo "" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-port $REDISPORT" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis/etc/replica.conf
      ARGS=("--port" "${REDIS_PORT}")
      
      if [[ "$REDIS_REPLICATION_MODE" = "slave" ]] || [[ "$REDIS_REPLICATION_MODE" = "replica" ]]; then
          ARGS+=("--replicaof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
      fi
      ARGS+=("--protected-mode" "no")
      ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
      ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
      exec redis-server "${ARGS[@]}"
      
  
    + #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/liblog.sh
      . /opt/bitnami/scripts/libvalidations.sh
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      
      if [ -n "$REDIS_EXTERNAL_MASTER_HOST" ]; then
          REDIS_SERVICE="$REDIS_EXTERNAL_MASTER_HOST"
      else
          REDIS_SERVICE="redis.default.svc.cluster.local"
      fi
      
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      validate_quorum() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel master redis-master"
          else
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel master redis-master"
          fi
          info "about to run the command: $quorum_info_command"
          eval $quorum_info_command | grep -Fq "s_down"
      }
      
      trigger_manual_failover() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel failover redis-master"
          else
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel failover redis-master"
          fi
      
          info "about to run the command: $failover_command"
          eval $failover_command
      }
      
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
      
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 5
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      [[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
      
      # check if there is a master
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      master_port_in_persisted_conf="$REDIS_MASTER_PORT_NUMBER"
      master_in_sentinel="$(get_sentinel_master_info)"
      redisRetVal=$?
      
      if [[ $redisRetVal -ne 0 ]]; then
          if [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 1: No active sentinel and in previous sentinel.conf we were the master --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 2: No active sentinel and in previous sentinel.conf we were not master --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
              REDIS_MASTER_HOST=${master_in_persisted_conf}
              REDIS_MASTER_PORT_NUMBER=${master_port_in_persisted_conf}
          fi
      else
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "Current master: REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      
          if [[ "$REDIS_MASTER_HOST" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 3: Active sentinel and master it is this node --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 4: Active sentinel and master is not this node --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
          fi
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/replica.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/redis.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
      fi
      
      echo "" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-port $REDISPORT" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis/etc/replica.conf
      ARGS=("--port" "${REDIS_PORT}")
      
      if [[ "$REDIS_REPLICATION_MODE" = "slave" ]] || [[ "$REDIS_REPLICATION_MODE" = "replica" ]]; then
          ARGS+=("--replicaof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
      fi
      ARGS+=("--protected-mode" "no")
      ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
      ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
      exec redis-server "${ARGS[@]}"
      
  
  

data.start-sentinel.sh  (v1/ConfigMap/default/redis-scripts)
  ± value change
    - #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/libvalidations.sh
      . /opt/bitnami/scripts/libfile.sh
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      REDIS_SERVICE="redis.default.svc.cluster.local"
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      SERVPORT=$(get_port "$HOSTNAME" "SENTINEL")
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      
      sentinel_conf_set() {
          local -r key="${1:?missing key}"
          local value="${2:-}"
      
          # Sanitize inputs
          value="${value//\\/\\\\}"
          value="${value//&/\\&}"
          value="${value//\?/\\?}"
          [[ "$value" = "" ]] && value="\"$value\""
      
          replace_in_file "/opt/bitnami/redis-sentinel/etc/sentinel.conf" "^#*\s*${key} .*" "${key} ${value}" false
      }
      sentinel_conf_add() {
          echo $'\n'"$@" >> "/opt/bitnami/redis-sentinel/etc/sentinel.conf"
      }
      host_id() {
          echo "$1" | openssl sha1 | awk '{print $2}'
      }
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_SENTINEL_TLS_CERT_FILE} --key ${REDIS_SENTINEL_TLS_KEY_FILE} --cacert ${REDIS_SENTINEL_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 1
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      if ! get_sentinel_master_info && [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
          # No master found, lets create a master node
          export REDIS_REPLICATION_MODE="master"
      
          REDIS_MASTER_HOST=$(get_full_hostname "$HOSTNAME")
          REDIS_MASTER_PORT_NUMBER="$REDISPORT"
      else
          export REDIS_REPLICATION_MODE="replica"
      
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "printing REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      cp /opt/bitnami/redis-sentinel/mounted-etc/sentinel.conf /opt/bitnami/redis-sentinel/etc/sentinel.conf
      printf "\nsentinel myid %s" "$(host_id "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      
      if [[ -z "$REDIS_MASTER_HOST" ]] || [[ -z "$REDIS_MASTER_PORT_NUMBER" ]]
      then
          # Prevent incorrect configuration to be written to sentinel.conf
          error "Redis master host is configured incorrectly (host: $REDIS_MASTER_HOST, port: $REDIS_MASTER_PORT_NUMBER)"
          exit 1
      fi
      
      sentinel_conf_set "sentinel monitor" "redis-master "$REDIS_MASTER_HOST" "$REDIS_MASTER_PORT_NUMBER" 2"
      
      add_known_sentinel() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$hostname" && -n "$ip" && "$hostname" != "$HOSTNAME" ]]; then
              sentinel_conf_add "sentinel known-sentinel redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "SENTINEL") $(host_id "$hostname")"
          fi
      }
      add_known_replica() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$ip" && "$(get_full_hostname "$hostname")" != "$REDIS_MASTER_HOST" ]]; then
              sentinel_conf_add "sentinel known-replica redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "REDIS")"
          fi
      }
      
      # Add available hosts on the network as known replicas & sentinels
      for node in $(seq 0 $((3-1))); do
          hostname="redis-node-$node"
          ip="$(getent hosts "$hostname.$HEADLESS_SERVICE" | awk '{ print $1 }')"
          add_known_sentinel "$hostname" "$ip"
          add_known_replica "$hostname" "$ip"
      done
      
      echo "" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel resolve-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-port $SERVPORT" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      exec redis-server /opt/bitnami/redis-sentinel/etc/sentinel.conf --sentinel
      
  
    + #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/libvalidations.sh
      . /opt/bitnami/scripts/libfile.sh
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      REDIS_SERVICE="redis.default.svc.cluster.local"
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      SERVPORT=$(get_port "$HOSTNAME" "SENTINEL")
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      
      sentinel_conf_set() {
          local -r key="${1:?missing key}"
          local value="${2:-}"
      
          # Sanitize inputs
          value="${value//\\/\\\\}"
          value="${value//&/\\&}"
          value="${value//\?/\\?}"
          [[ "$value" = "" ]] && value="\"$value\""
      
          replace_in_file "/opt/bitnami/redis-sentinel/etc/sentinel.conf" "^#*\s*${key} .*" "${key} ${value}" false
      }
      sentinel_conf_add() {
          echo $'\n'"$@" >> "/opt/bitnami/redis-sentinel/etc/sentinel.conf"
      }
      host_id() {
          echo "$1" | openssl sha1 | awk '{print $2}'
      }
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_SENTINEL_TLS_CERT_FILE} --key ${REDIS_SENTINEL_TLS_KEY_FILE} --cacert ${REDIS_SENTINEL_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 5
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      if ! get_sentinel_master_info && [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
          # No master found, lets create a master node
          export REDIS_REPLICATION_MODE="master"
      
          REDIS_MASTER_HOST=$(get_full_hostname "$HOSTNAME")
          REDIS_MASTER_PORT_NUMBER="$REDISPORT"
      else
          export REDIS_REPLICATION_MODE="replica"
      
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "printing REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      cp /opt/bitnami/redis-sentinel/mounted-etc/sentinel.conf /opt/bitnami/redis-sentinel/etc/sentinel.conf
      printf "\nsentinel myid %s" "$(host_id "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      
      if [[ -z "$REDIS_MASTER_HOST" ]] || [[ -z "$REDIS_MASTER_PORT_NUMBER" ]]
      then
          # Prevent incorrect configuration to be written to sentinel.conf
          error "Redis master host is configured incorrectly (host: $REDIS_MASTER_HOST, port: $REDIS_MASTER_PORT_NUMBER)"
          exit 1
      fi
      
      sentinel_conf_set "sentinel monitor" "redis-master "$REDIS_MASTER_HOST" "$REDIS_MASTER_PORT_NUMBER" 2"
      
      add_known_sentinel() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$hostname" && -n "$ip" && "$hostname" != "$HOSTNAME" ]]; then
              sentinel_conf_add "sentinel known-sentinel redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "SENTINEL") $(host_id "$hostname")"
          fi
      }
      add_known_replica() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$ip" && "$(get_full_hostname "$hostname")" != "$REDIS_MASTER_HOST" ]]; then
              sentinel_conf_add "sentinel known-replica redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "REDIS")"
          fi
      }
      
      # Add available hosts on the network as known replicas & sentinels
      for node in $(seq 0 $((3-1))); do
          hostname="redis-node-$node"
          ip="$(getent hosts "$hostname.$HEADLESS_SERVICE" | awk '{ print $1 }')"
          add_known_sentinel "$hostname" "$ip"
          add_known_replica "$hostname" "$ip"
      done
      
      echo "" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel resolve-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-port $SERVPORT" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      exec redis-server /opt/bitnami/redis-sentinel/etc/sentinel.conf --sentinel
      
  
  

spec.template.spec.containers.redis.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis:7.2.3-debian-11-r0
    + docker.io/bitnami/redis:7.2.3-debian-11-r1

spec.template.spec.containers.sentinel.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis-sentinel:7.2.3-debian-11-r0
    + docker.io/bitnami/redis-sentinel:7.2.3-debian-11-r1

spec.template.spec.containers.metrics.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis-exporter:1.55.0-debian-11-r0
    + docker.io/bitnami/redis-exporter:1.55.0-debian-11-r2

@trux-bot trux-bot bot force-pushed the renovate/redis-18.x branch from 112019e to 97f372b Compare November 16, 2023 14:12
@trux-bot trux-bot bot changed the title feat(helm-chart): update helm release redis to 18.3.3 feat(helm-chart): update helm release redis to 18.4.0 Nov 16, 2023
@trux-bot
Copy link
Contributor Author

trux-bot bot commented Nov 16, 2023

Helm Release: kubernetes/apps/databases/redis-sentinel/app/helmrelease.yaml

data.start-node.sh  (v1/ConfigMap/default/redis-scripts)
  ± value change
    - #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/liblog.sh
      . /opt/bitnami/scripts/libvalidations.sh
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      
      if [ -n "$REDIS_EXTERNAL_MASTER_HOST" ]; then
          REDIS_SERVICE="$REDIS_EXTERNAL_MASTER_HOST"
      else
          REDIS_SERVICE="redis.default.svc.cluster.local"
      fi
      
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      validate_quorum() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel master redis-master"
          else
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel master redis-master"
          fi
          info "about to run the command: $quorum_info_command"
          eval $quorum_info_command | grep -Fq "s_down"
      }
      
      trigger_manual_failover() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel failover redis-master"
          else
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel failover redis-master"
          fi
      
          info "about to run the command: $failover_command"
          eval $failover_command
      }
      
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
      
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 1
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      [[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
      
      # check if there is a master
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      master_port_in_persisted_conf="$REDIS_MASTER_PORT_NUMBER"
      master_in_sentinel="$(get_sentinel_master_info)"
      redisRetVal=$?
      
      if [[ $redisRetVal -ne 0 ]]; then
          if [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 1: No active sentinel and in previous sentinel.conf we were the master --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 2: No active sentinel and in previous sentinel.conf we were not master --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
              REDIS_MASTER_HOST=${master_in_persisted_conf}
              REDIS_MASTER_PORT_NUMBER=${master_port_in_persisted_conf}
          fi
      else
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "Current master: REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      
          if [[ "$REDIS_MASTER_HOST" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 3: Active sentinel and master it is this node --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 4: Active sentinel and master is not this node --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
          fi
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/replica.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/redis.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
      fi
      
      echo "" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-port $REDISPORT" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis/etc/replica.conf
      ARGS=("--port" "${REDIS_PORT}")
      
      if [[ "$REDIS_REPLICATION_MODE" = "slave" ]] || [[ "$REDIS_REPLICATION_MODE" = "replica" ]]; then
          ARGS+=("--replicaof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
      fi
      ARGS+=("--protected-mode" "no")
      ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
      ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
      exec redis-server "${ARGS[@]}"
      
  
    + #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/liblog.sh
      . /opt/bitnami/scripts/libvalidations.sh
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      
      if [ -n "$REDIS_EXTERNAL_MASTER_HOST" ]; then
          REDIS_SERVICE="$REDIS_EXTERNAL_MASTER_HOST"
      else
          REDIS_SERVICE="redis.default.svc.cluster.local"
      fi
      
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      validate_quorum() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel master redis-master"
          else
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel master redis-master"
          fi
          info "about to run the command: $quorum_info_command"
          eval $quorum_info_command | grep -Fq "s_down"
      }
      
      trigger_manual_failover() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel failover redis-master"
          else
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel failover redis-master"
          fi
      
          info "about to run the command: $failover_command"
          eval $failover_command
      }
      
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
      
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 5
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      [[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
      
      # check if there is a master
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      master_port_in_persisted_conf="$REDIS_MASTER_PORT_NUMBER"
      master_in_sentinel="$(get_sentinel_master_info)"
      redisRetVal=$?
      
      if [[ $redisRetVal -ne 0 ]]; then
          if [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 1: No active sentinel and in previous sentinel.conf we were the master --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 2: No active sentinel and in previous sentinel.conf we were not master --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
              REDIS_MASTER_HOST=${master_in_persisted_conf}
              REDIS_MASTER_PORT_NUMBER=${master_port_in_persisted_conf}
          fi
      else
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "Current master: REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      
          if [[ "$REDIS_MASTER_HOST" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 3: Active sentinel and master it is this node --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 4: Active sentinel and master is not this node --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
          fi
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/replica.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/redis.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
      fi
      
      echo "" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-port $REDISPORT" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis/etc/replica.conf
      ARGS=("--port" "${REDIS_PORT}")
      
      if [[ "$REDIS_REPLICATION_MODE" = "slave" ]] || [[ "$REDIS_REPLICATION_MODE" = "replica" ]]; then
          ARGS+=("--replicaof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
      fi
      ARGS+=("--protected-mode" "no")
      ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
      ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
      exec redis-server "${ARGS[@]}"
      
  
  

data.start-sentinel.sh  (v1/ConfigMap/default/redis-scripts)
  ± value change
    - #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/libvalidations.sh
      . /opt/bitnami/scripts/libfile.sh
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      REDIS_SERVICE="redis.default.svc.cluster.local"
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      SERVPORT=$(get_port "$HOSTNAME" "SENTINEL")
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      
      sentinel_conf_set() {
          local -r key="${1:?missing key}"
          local value="${2:-}"
      
          # Sanitize inputs
          value="${value//\\/\\\\}"
          value="${value//&/\\&}"
          value="${value//\?/\\?}"
          [[ "$value" = "" ]] && value="\"$value\""
      
          replace_in_file "/opt/bitnami/redis-sentinel/etc/sentinel.conf" "^#*\s*${key} .*" "${key} ${value}" false
      }
      sentinel_conf_add() {
          echo $'\n'"$@" >> "/opt/bitnami/redis-sentinel/etc/sentinel.conf"
      }
      host_id() {
          echo "$1" | openssl sha1 | awk '{print $2}'
      }
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_SENTINEL_TLS_CERT_FILE} --key ${REDIS_SENTINEL_TLS_KEY_FILE} --cacert ${REDIS_SENTINEL_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 1
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      if ! get_sentinel_master_info && [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
          # No master found, lets create a master node
          export REDIS_REPLICATION_MODE="master"
      
          REDIS_MASTER_HOST=$(get_full_hostname "$HOSTNAME")
          REDIS_MASTER_PORT_NUMBER="$REDISPORT"
      else
          export REDIS_REPLICATION_MODE="replica"
      
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "printing REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      cp /opt/bitnami/redis-sentinel/mounted-etc/sentinel.conf /opt/bitnami/redis-sentinel/etc/sentinel.conf
      printf "\nsentinel myid %s" "$(host_id "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      
      if [[ -z "$REDIS_MASTER_HOST" ]] || [[ -z "$REDIS_MASTER_PORT_NUMBER" ]]
      then
          # Prevent incorrect configuration to be written to sentinel.conf
          error "Redis master host is configured incorrectly (host: $REDIS_MASTER_HOST, port: $REDIS_MASTER_PORT_NUMBER)"
          exit 1
      fi
      
      sentinel_conf_set "sentinel monitor" "redis-master "$REDIS_MASTER_HOST" "$REDIS_MASTER_PORT_NUMBER" 2"
      
      add_known_sentinel() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$hostname" && -n "$ip" && "$hostname" != "$HOSTNAME" ]]; then
              sentinel_conf_add "sentinel known-sentinel redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "SENTINEL") $(host_id "$hostname")"
          fi
      }
      add_known_replica() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$ip" && "$(get_full_hostname "$hostname")" != "$REDIS_MASTER_HOST" ]]; then
              sentinel_conf_add "sentinel known-replica redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "REDIS")"
          fi
      }
      
      # Add available hosts on the network as known replicas & sentinels
      for node in $(seq 0 $((3-1))); do
          hostname="redis-node-$node"
          ip="$(getent hosts "$hostname.$HEADLESS_SERVICE" | awk '{ print $1 }')"
          add_known_sentinel "$hostname" "$ip"
          add_known_replica "$hostname" "$ip"
      done
      
      echo "" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel resolve-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-port $SERVPORT" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      exec redis-server /opt/bitnami/redis-sentinel/etc/sentinel.conf --sentinel
      
  
    + #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/libvalidations.sh
      . /opt/bitnami/scripts/libfile.sh
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      REDIS_SERVICE="redis.default.svc.cluster.local"
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      SERVPORT=$(get_port "$HOSTNAME" "SENTINEL")
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      
      sentinel_conf_set() {
          local -r key="${1:?missing key}"
          local value="${2:-}"
      
          # Sanitize inputs
          value="${value//\\/\\\\}"
          value="${value//&/\\&}"
          value="${value//\?/\\?}"
          [[ "$value" = "" ]] && value="\"$value\""
      
          replace_in_file "/opt/bitnami/redis-sentinel/etc/sentinel.conf" "^#*\s*${key} .*" "${key} ${value}" false
      }
      sentinel_conf_add() {
          echo $'\n'"$@" >> "/opt/bitnami/redis-sentinel/etc/sentinel.conf"
      }
      host_id() {
          echo "$1" | openssl sha1 | awk '{print $2}'
      }
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_SENTINEL_TLS_CERT_FILE} --key ${REDIS_SENTINEL_TLS_KEY_FILE} --cacert ${REDIS_SENTINEL_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 5
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      if ! get_sentinel_master_info && [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
          # No master found, lets create a master node
          export REDIS_REPLICATION_MODE="master"
      
          REDIS_MASTER_HOST=$(get_full_hostname "$HOSTNAME")
          REDIS_MASTER_PORT_NUMBER="$REDISPORT"
      else
          export REDIS_REPLICATION_MODE="replica"
      
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "printing REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      cp /opt/bitnami/redis-sentinel/mounted-etc/sentinel.conf /opt/bitnami/redis-sentinel/etc/sentinel.conf
      printf "\nsentinel myid %s" "$(host_id "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      
      if [[ -z "$REDIS_MASTER_HOST" ]] || [[ -z "$REDIS_MASTER_PORT_NUMBER" ]]
      then
          # Prevent incorrect configuration to be written to sentinel.conf
          error "Redis master host is configured incorrectly (host: $REDIS_MASTER_HOST, port: $REDIS_MASTER_PORT_NUMBER)"
          exit 1
      fi
      
      sentinel_conf_set "sentinel monitor" "redis-master "$REDIS_MASTER_HOST" "$REDIS_MASTER_PORT_NUMBER" 2"
      
      add_known_sentinel() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$hostname" && -n "$ip" && "$hostname" != "$HOSTNAME" ]]; then
              sentinel_conf_add "sentinel known-sentinel redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "SENTINEL") $(host_id "$hostname")"
          fi
      }
      add_known_replica() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$ip" && "$(get_full_hostname "$hostname")" != "$REDIS_MASTER_HOST" ]]; then
              sentinel_conf_add "sentinel known-replica redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "REDIS")"
          fi
      }
      
      # Add available hosts on the network as known replicas & sentinels
      for node in $(seq 0 $((3-1))); do
          hostname="redis-node-$node"
          ip="$(getent hosts "$hostname.$HEADLESS_SERVICE" | awk '{ print $1 }')"
          add_known_sentinel "$hostname" "$ip"
          add_known_replica "$hostname" "$ip"
      done
      
      echo "" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel resolve-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-port $SERVPORT" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      exec redis-server /opt/bitnami/redis-sentinel/etc/sentinel.conf --sentinel
      
  
  

spec.template.spec.containers.redis.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis:7.2.3-debian-11-r0
    + docker.io/bitnami/redis:7.2.3-debian-11-r1

spec.template.spec.containers.sentinel.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis-sentinel:7.2.3-debian-11-r0
    + docker.io/bitnami/redis-sentinel:7.2.3-debian-11-r1

spec.template.spec.containers.metrics.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis-exporter:1.55.0-debian-11-r0
    + docker.io/bitnami/redis-exporter:1.55.0-debian-11-r2

| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| helm       | redis   | 18.2.1 | 18.5.0 |
@trux-bot trux-bot bot force-pushed the renovate/redis-18.x branch from 97f372b to de99c2e Compare December 11, 2023 14:10
@trux-bot trux-bot bot changed the title feat(helm-chart): update helm release redis to 18.4.0 feat(helm-chart): update helm release redis to 18.5.0 Dec 11, 2023
@trux-bot
Copy link
Contributor Author

trux-bot bot commented Dec 11, 2023

Helm Release: kubernetes/apps/databases/redis-sentinel/app/helmrelease.yaml

data.start-node.sh  (v1/ConfigMap/default/redis-scripts)
  ± value change
    - #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/liblog.sh
      . /opt/bitnami/scripts/libvalidations.sh
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      
      if [ -n "$REDIS_EXTERNAL_MASTER_HOST" ]; then
          REDIS_SERVICE="$REDIS_EXTERNAL_MASTER_HOST"
      else
          REDIS_SERVICE="redis.default.svc.cluster.local"
      fi
      
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      validate_quorum() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel master redis-master"
          else
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel master redis-master"
          fi
          info "about to run the command: $quorum_info_command"
          eval $quorum_info_command | grep -Fq "s_down"
      }
      
      trigger_manual_failover() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel failover redis-master"
          else
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel failover redis-master"
          fi
      
          info "about to run the command: $failover_command"
          eval $failover_command
      }
      
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
      
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 1
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      [[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
      
      # check if there is a master
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      master_port_in_persisted_conf="$REDIS_MASTER_PORT_NUMBER"
      master_in_sentinel="$(get_sentinel_master_info)"
      redisRetVal=$?
      
      if [[ $redisRetVal -ne 0 ]]; then
          if [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 1: No active sentinel and in previous sentinel.conf we were the master --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 2: No active sentinel and in previous sentinel.conf we were not master --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
              REDIS_MASTER_HOST=${master_in_persisted_conf}
              REDIS_MASTER_PORT_NUMBER=${master_port_in_persisted_conf}
          fi
      else
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "Current master: REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      
          if [[ "$REDIS_MASTER_HOST" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 3: Active sentinel and master it is this node --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 4: Active sentinel and master is not this node --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
          fi
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/replica.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/redis.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
      fi
      
      echo "" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-port $REDISPORT" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis/etc/replica.conf
      ARGS=("--port" "${REDIS_PORT}")
      
      if [[ "$REDIS_REPLICATION_MODE" = "slave" ]] || [[ "$REDIS_REPLICATION_MODE" = "replica" ]]; then
          ARGS+=("--replicaof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
      fi
      ARGS+=("--protected-mode" "no")
      ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
      ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
      exec redis-server "${ARGS[@]}"
      
  
    + #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/liblog.sh
      . /opt/bitnami/scripts/libvalidations.sh
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      
      if [ -n "$REDIS_EXTERNAL_MASTER_HOST" ]; then
          REDIS_SERVICE="$REDIS_EXTERNAL_MASTER_HOST"
      else
          REDIS_SERVICE="redis.default.svc.cluster.local"
      fi
      
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      validate_quorum() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel master redis-master"
          else
              quorum_info_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel master redis-master"
          fi
          info "about to run the command: $quorum_info_command"
          eval $quorum_info_command | grep -Fq "s_down"
      }
      
      trigger_manual_failover() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel failover redis-master"
          else
              failover_command="redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel failover redis-master"
          fi
      
          info "about to run the command: $failover_command"
          eval $failover_command
      }
      
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
      
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 5
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      [[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
      
      # check if there is a master
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      master_port_in_persisted_conf="$REDIS_MASTER_PORT_NUMBER"
      master_in_sentinel="$(get_sentinel_master_info)"
      redisRetVal=$?
      
      if [[ $redisRetVal -ne 0 ]]; then
          if [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 1: No active sentinel and in previous sentinel.conf we were the master --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 2: No active sentinel and in previous sentinel.conf we were not master --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
              REDIS_MASTER_HOST=${master_in_persisted_conf}
              REDIS_MASTER_PORT_NUMBER=${master_port_in_persisted_conf}
          fi
      else
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "Current master: REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      
          if [[ "$REDIS_MASTER_HOST" == "$(get_full_hostname "$HOSTNAME")" ]]; then
              # Case 3: Active sentinel and master it is this node --> MASTER
              info "Configuring the node as master"
              export REDIS_REPLICATION_MODE="master"
          else
              # Case 4: Active sentinel and master is not this node --> REPLICA
              info "Configuring the node as replica"
              export REDIS_REPLICATION_MODE="replica"
          fi
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/replica.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
      fi
      
      if [[ -f /opt/bitnami/redis/mounted-etc/redis.conf ]];then
          cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
      fi
      
      echo "" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-port $REDISPORT" >> /opt/bitnami/redis/etc/replica.conf
      echo "replica-announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis/etc/replica.conf
      ARGS=("--port" "${REDIS_PORT}")
      
      if [[ "$REDIS_REPLICATION_MODE" = "slave" ]] || [[ "$REDIS_REPLICATION_MODE" = "replica" ]]; then
          ARGS+=("--replicaof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
      fi
      ARGS+=("--protected-mode" "no")
      ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
      ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
      exec redis-server "${ARGS[@]}"
      
  
  

data.start-sentinel.sh  (v1/ConfigMap/default/redis-scripts)
  ± value change
    - #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/libvalidations.sh
      . /opt/bitnami/scripts/libfile.sh
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      REDIS_SERVICE="redis.default.svc.cluster.local"
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      SERVPORT=$(get_port "$HOSTNAME" "SENTINEL")
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      
      sentinel_conf_set() {
          local -r key="${1:?missing key}"
          local value="${2:-}"
      
          # Sanitize inputs
          value="${value//\\/\\\\}"
          value="${value//&/\\&}"
          value="${value//\?/\\?}"
          [[ "$value" = "" ]] && value="\"$value\""
      
          replace_in_file "/opt/bitnami/redis-sentinel/etc/sentinel.conf" "^#*\s*${key} .*" "${key} ${value}" false
      }
      sentinel_conf_add() {
          echo $'\n'"$@" >> "/opt/bitnami/redis-sentinel/etc/sentinel.conf"
      }
      host_id() {
          echo "$1" | openssl sha1 | awk '{print $2}'
      }
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_SENTINEL_TLS_CERT_FILE} --key ${REDIS_SENTINEL_TLS_KEY_FILE} --cacert ${REDIS_SENTINEL_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 1
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      if ! get_sentinel_master_info && [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
          # No master found, lets create a master node
          export REDIS_REPLICATION_MODE="master"
      
          REDIS_MASTER_HOST=$(get_full_hostname "$HOSTNAME")
          REDIS_MASTER_PORT_NUMBER="$REDISPORT"
      else
          export REDIS_REPLICATION_MODE="replica"
      
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "printing REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      cp /opt/bitnami/redis-sentinel/mounted-etc/sentinel.conf /opt/bitnami/redis-sentinel/etc/sentinel.conf
      printf "\nsentinel myid %s" "$(host_id "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      
      if [[ -z "$REDIS_MASTER_HOST" ]] || [[ -z "$REDIS_MASTER_PORT_NUMBER" ]]
      then
          # Prevent incorrect configuration to be written to sentinel.conf
          error "Redis master host is configured incorrectly (host: $REDIS_MASTER_HOST, port: $REDIS_MASTER_PORT_NUMBER)"
          exit 1
      fi
      
      sentinel_conf_set "sentinel monitor" "redis-master "$REDIS_MASTER_HOST" "$REDIS_MASTER_PORT_NUMBER" 2"
      
      add_known_sentinel() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$hostname" && -n "$ip" && "$hostname" != "$HOSTNAME" ]]; then
              sentinel_conf_add "sentinel known-sentinel redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "SENTINEL") $(host_id "$hostname")"
          fi
      }
      add_known_replica() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$ip" && "$(get_full_hostname "$hostname")" != "$REDIS_MASTER_HOST" ]]; then
              sentinel_conf_add "sentinel known-replica redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "REDIS")"
          fi
      }
      
      # Add available hosts on the network as known replicas & sentinels
      for node in $(seq 0 $((3-1))); do
          hostname="redis-node-$node"
          ip="$(getent hosts "$hostname.$HEADLESS_SERVICE" | awk '{ print $1 }')"
          add_known_sentinel "$hostname" "$ip"
          add_known_replica "$hostname" "$ip"
      done
      
      echo "" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel resolve-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-port $SERVPORT" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      exec redis-server /opt/bitnami/redis-sentinel/etc/sentinel.conf --sentinel
      
  
    + #!/bin/bash
      
      . /opt/bitnami/scripts/libos.sh
      . /opt/bitnami/scripts/libvalidations.sh
      . /opt/bitnami/scripts/libfile.sh
      
      HEADLESS_SERVICE="redis-headless.default.svc.cluster.local"
      REDIS_SERVICE="redis.default.svc.cluster.local"
      
      get_port() {
          hostname="$1"
          type="$2"
      
          port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
          port=${!port_var}
      
          if [ -z "$port" ]; then
              case $type in
                  "SENTINEL")
                      echo 26379
                      ;;
                  "REDIS")
                      echo 6379
                      ;;
              esac
          else
              echo $port
          fi
      }
      
      get_full_hostname() {
          hostname="$1"
          full_hostname="${hostname}.${HEADLESS_SERVICE}"
          echo "${full_hostname}"
      }
      
      SERVPORT=$(get_port "$HOSTNAME" "SENTINEL")
      REDISPORT=$(get_port "$HOSTNAME" "REDIS")
      SENTINEL_SERVICE_PORT=$(get_port "redis" "SENTINEL")
      
      sentinel_conf_set() {
          local -r key="${1:?missing key}"
          local value="${2:-}"
      
          # Sanitize inputs
          value="${value//\\/\\\\}"
          value="${value//&/\\&}"
          value="${value//\?/\\?}"
          [[ "$value" = "" ]] && value="\"$value\""
      
          replace_in_file "/opt/bitnami/redis-sentinel/etc/sentinel.conf" "^#*\s*${key} .*" "${key} ${value}" false
      }
      sentinel_conf_add() {
          echo $'\n'"$@" >> "/opt/bitnami/redis-sentinel/etc/sentinel.conf"
      }
      host_id() {
          echo "$1" | openssl sha1 | awk '{print $2}'
      }
      get_sentinel_master_info() {
          if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_SENTINEL_TLS_CERT_FILE} --key ${REDIS_SENTINEL_TLS_KEY_FILE} --cacert ${REDIS_SENTINEL_TLS_CA_FILE} sentinel get-master-addr-by-name redis-master"
          else
              sentinel_info_command="timeout 10 redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name redis-master"
          fi
          info "about to run the command: $sentinel_info_command"
          retry_while "eval $sentinel_info_command" 2 5
      }
      
      [[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
      
      master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
      if ! get_sentinel_master_info && [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
          # No master found, lets create a master node
          export REDIS_REPLICATION_MODE="master"
      
          REDIS_MASTER_HOST=$(get_full_hostname "$HOSTNAME")
          REDIS_MASTER_PORT_NUMBER="$REDISPORT"
      else
          export REDIS_REPLICATION_MODE="replica"
      
          # Fetches current master's host and port
          REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
          info "printing REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
          REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
          REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
      fi
      
      if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
        REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
        REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
      fi
      
      cp /opt/bitnami/redis-sentinel/mounted-etc/sentinel.conf /opt/bitnami/redis-sentinel/etc/sentinel.conf
      printf "\nsentinel myid %s" "$(host_id "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      
      if [[ -z "$REDIS_MASTER_HOST" ]] || [[ -z "$REDIS_MASTER_PORT_NUMBER" ]]
      then
          # Prevent incorrect configuration to be written to sentinel.conf
          error "Redis master host is configured incorrectly (host: $REDIS_MASTER_HOST, port: $REDIS_MASTER_PORT_NUMBER)"
          exit 1
      fi
      
      sentinel_conf_set "sentinel monitor" "redis-master "$REDIS_MASTER_HOST" "$REDIS_MASTER_PORT_NUMBER" 2"
      
      add_known_sentinel() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$hostname" && -n "$ip" && "$hostname" != "$HOSTNAME" ]]; then
              sentinel_conf_add "sentinel known-sentinel redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "SENTINEL") $(host_id "$hostname")"
          fi
      }
      add_known_replica() {
          hostname="$1"
          ip="$2"
      
          if [[ -n "$ip" && "$(get_full_hostname "$hostname")" != "$REDIS_MASTER_HOST" ]]; then
              sentinel_conf_add "sentinel known-replica redis-master $(get_full_hostname "$hostname") $(get_port "$hostname" "REDIS")"
          fi
      }
      
      # Add available hosts on the network as known replicas & sentinels
      for node in $(seq 0 $((3-1))); do
          hostname="redis-node-$node"
          ip="$(getent hosts "$hostname.$HEADLESS_SERVICE" | awk '{ print $1 }')"
          add_known_sentinel "$hostname" "$ip"
          add_known_replica "$hostname" "$ip"
      done
      
      echo "" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel resolve-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-port $SERVPORT" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      echo "sentinel announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
      exec redis-server /opt/bitnami/redis-sentinel/etc/sentinel.conf --sentinel
      
  
  

spec.template.spec.containers.redis.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis:7.2.3-debian-11-r0
    + docker.io/bitnami/redis:7.2.3-debian-11-r1

spec.template.spec.containers.sentinel.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis-sentinel:7.2.3-debian-11-r0
    + docker.io/bitnami/redis-sentinel:7.2.3-debian-11-r1

spec.template.spec.containers.metrics.image  (apps/v1/StatefulSet/default/redis-node)
  ± value change
    - docker.io/bitnami/redis-exporter:1.55.0-debian-11-r0
    + docker.io/bitnami/redis-exporter:1.55.0-debian-11-r2

@truxnell truxnell merged commit 668d94b into main Dec 18, 2023
3 checks passed
@truxnell truxnell deleted the renovate/redis-18.x branch December 18, 2023 10:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant