Skip to content

Commit

Permalink
feat: support external hostname
Browse files Browse the repository at this point in the history
Signed-off-by: Jia-wei Yu <yoga.yu.169@gmail.com>
  • Loading branch information
yo-ga committed Jul 29, 2023
1 parent d8f76f6 commit db87eda
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions bitnami/redis-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ The command removes all the Kubernetes components associated with the chart and
| `cluster.nodes` | The number of master nodes should always be >= 3, otherwise cluster creation will fail | `6` |
| `cluster.replicas` | Number of replicas for every master in the cluster | `1` |
| `cluster.externalAccess.enabled` | Enable access to the Redis | `false` |
| `cluster.externalAccess.hostMode` | Set cluster preferred endpoint type as hostname | `false` |
| `cluster.externalAccess.service.type` | Type for the services used to expose every Pod | `LoadBalancer` |
| `cluster.externalAccess.service.port` | Port for the services used to expose every Pod | `6379` |
| `cluster.externalAccess.service.loadBalancerIP` | Array of load balancer IPs for each Redis&reg; node. Length must be the same as cluster.nodes | `[]` |
Expand Down
25 changes: 24 additions & 1 deletion bitnami/redis-cluster/templates/redis-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ spec:
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else if .Values.redis.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.redis.args "context" $) | nindent 12 }}
{{- else if and .Values.cluster.externalAccess.enabled .Values.cluster.externalAccess.hostMode }}
args:
- |
# Backwards compatibility change
if ! [[ -f /opt/bitnami/redis/etc/redis.conf ]]; then
cp /opt/bitnami/redis/etc/redis-default.conf /opt/bitnami/redis/etc/redis.conf
fi
pod_index=($(echo "$POD_NAME" | tr "-" "\n"))
pod_index="${pod_index[-1]}"
ips=($(echo "{{ .Values.cluster.externalAccess.service.loadBalancerIP }}" | cut -d [ -f2 | cut -d ] -f 1))
export REDIS_CLUSTER_ANNOUNCE_HOST="${ips[$pod_index]}"
export REDIS_NODES="${ips[@]}"
export REDIS_CLUSTER_PREFERRED_ENDPOINT_TYPE=hostname
{{- if .Values.cluster.init }}
if [[ "$pod_index" == "0" ]]; then
export REDIS_CLUSTER_CREATOR="yes"
export REDIS_CLUSTER_REPLICAS="{{ .Values.cluster.replicas }}"
fi
{{- end }}
/opt/bitnami/scripts/redis-cluster/entrypoint.sh /opt/bitnami/scripts/redis-cluster/run.sh
{{- else if .Values.cluster.externalAccess.enabled }}
args:
- |
Expand Down Expand Up @@ -148,7 +168,10 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- if .Values.cluster.externalAccess.enabled }}
{{- if and .Values.cluster.externalAccess.enabled .Values.cluster.externalAccess.hostMode }}
- name: REDIS_CLUSTER_DYNAMIC_IPS
value: "yes"
{{- else if .Values.cluster.externalAccess.enabled }}
- name: REDIS_CLUSTER_DYNAMIC_IPS
value: "no"
{{- else }}
Expand Down
4 changes: 4 additions & 0 deletions bitnami/redis-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,10 @@ cluster:
## @param cluster.externalAccess.enabled Enable access to the Redis
##
enabled: false
## @param cluster.externalAccess.hostMode Set cluster preferred endpoint type as hostname
## ref: https://github.com/redis/redis/pull/9530
##
hostMode: false
service:
## @param cluster.externalAccess.service.type Type for the services used to expose every Pod
## At this moment only LoadBalancer is supported
Expand Down

0 comments on commit db87eda

Please sign in to comment.