Skip to content

Commit

Permalink
[bitnami/redis] Allow option to disable hostnames usage when configur…
Browse files Browse the repository at this point in the history
…ing nodes (#14599)

* [bitnami/redis] Allow option to disable hostnames usage when configuring nodes

Signed-off-by: jotamartos <jotamartos@vmware.com>

* Remove empty line

Co-authored-by: Carlos Rodríguez Hernández <carlosrh@vmware.com>
Signed-off-by: Juan José Martos <jotamartos@gmail.com>

---------

Signed-off-by: jotamartos <jotamartos@vmware.com>
Signed-off-by: Juan José Martos <jotamartos@gmail.com>
Co-authored-by: Carlos Rodríguez Hernández <carlosrh@vmware.com>
  • Loading branch information
jotamartos and carrodher authored Feb 2, 2023
1 parent c2c88be commit 0343396
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bitnami/redis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ maintainers:
name: redis
sources:
- https://github.com/bitnami/containers/tree/main/bitnami/redis
version: 17.6.0
version: 17.7.0
1 change: 1 addition & 0 deletions bitnami/redis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ The command removes all the Kubernetes components associated with the chart and
| `secretAnnotations` | Annotations to add to secret | `{}` |
| `clusterDomain` | Kubernetes cluster domain name | `cluster.local` |
| `extraDeploy` | Array of extra objects to deploy with the release | `[]` |
| `useHostnames` | Use hostnames internally when announcing replication | `true` |
| `diagnosticMode.enabled` | Enable diagnostic mode (all probes will be disabled and the command will be overridden) | `false` |
| `diagnosticMode.command` | Command to override all containers in the deployment | `["sleep"]` |
| `diagnosticMode.args` | Args to override all containers in the deployment | `["infinity"]` |
Expand Down
62 changes: 47 additions & 15 deletions bitnami/redis/templates/scripts-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,17 @@ data:
hostname="$1"
{{- if .Values.useExternalDNS.enabled }}
echo "${hostname}.{{- include "redis.externalDNS.suffix" . }}"
full_hostname="${hostname}.{{- include "redis.externalDNS.suffix" . }}"
{{- else if eq .Values.sentinel.service.type "NodePort" }}
echo "${hostname}.{{- .Release.Namespace }}"
full_hostname="${hostname}.{{- .Release.Namespace }}"
{{- else }}
echo "${hostname}.${HEADLESS_SERVICE}"
full_hostname="${hostname}.${HEADLESS_SERVICE}"
{{- end }}
{{- if .Values.useHostnames }}
echo "${full_hostname}"
{{- else }}
getent hosts "${full_hostname}" | awk '{ print $1 ; exit }'
{{- end }}
}
Expand Down Expand Up @@ -262,11 +268,17 @@ data:
hostname="$1"
{{- if .Values.useExternalDNS.enabled }}
echo "${hostname}.{{- include "redis.externalDNS.suffix" . }}"
full_hostname="${hostname}.{{- include "redis.externalDNS.suffix" . }}"
{{- else if eq .Values.sentinel.service.type "NodePort" }}
echo "${hostname}.{{- .Release.Namespace }}"
full_hostname="${hostname}.{{- .Release.Namespace }}"
{{- else }}
echo "${hostname}.${HEADLESS_SERVICE}"
full_hostname="${hostname}.${HEADLESS_SERVICE}"
{{- end }}
{{- if .Values.useHostnames }}
echo "${full_hostname}"
{{- else }}
getent hosts "${full_hostname}" | awk '{ print $1 ; exit }'
{{- end }}
}
Expand Down Expand Up @@ -426,13 +438,20 @@ data:
hostname="$1"
{{- if .Values.useExternalDNS.enabled }}
echo "${hostname}.{{- include "redis.externalDNS.suffix" . }}"
full_hostname="${hostname}.{{- include "redis.externalDNS.suffix" . }}"
{{- else if eq .Values.sentinel.service.type "NodePort" }}
echo "${hostname}.{{- .Release.Namespace }}"
full_hostname="${hostname}.{{- .Release.Namespace }}"
{{- else }}
full_hostname="${hostname}.${HEADLESS_SERVICE}"
{{- end }}
{{- if .Values.useHostnames }}
echo "${full_hostname}"
{{- else }}
echo "${hostname}.${HEADLESS_SERVICE}"
getent hosts "${full_hostname}" | awk '{ print $1 ; exit }'
{{- end }}
}
run_sentinel_command() {
if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
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 "$@"
Expand Down Expand Up @@ -492,13 +511,20 @@ data:
hostname="$1"
{{- if .Values.useExternalDNS.enabled }}
echo "${hostname}.{{- include "redis.externalDNS.suffix" . }}"
full_hostname="${hostname}.{{- include "redis.externalDNS.suffix" . }}"
{{- else if eq .Values.sentinel.service.type "NodePort" }}
echo "${hostname}.{{- .Release.Namespace }}"
full_hostname="${hostname}.{{- .Release.Namespace }}"
{{- else }}
full_hostname="${hostname}.${HEADLESS_SERVICE}"
{{- end }}
{{- if .Values.useHostnames }}
echo "${full_hostname}"
{{- else }}
echo "${hostname}.${HEADLESS_SERVICE}"
getent hosts "${full_hostname}" | awk '{ print $1 ; exit }'
{{- end }}
}
run_sentinel_command() {
if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
{{ .Values.auth.sentinel | ternary "" "env -u REDISCLI_AUTH " -}} 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 "$@"
Expand Down Expand Up @@ -614,11 +640,17 @@ data:
hostname="$1"
{{- if .Values.useExternalDNS.enabled }}
echo "${hostname}.{{- include "redis.externalDNS.suffix" . }}"
full_hostname="${hostname}.{{- include "redis.externalDNS.suffix" . }}"
{{- else if eq .Values.sentinel.service.type "NodePort" }}
echo "${hostname}.{{- .Release.Namespace }}"
full_hostname="${hostname}.{{- .Release.Namespace }}"
{{- else }}
full_hostname="${hostname}.${HEADLESS_SERVICE}"
{{- end }}
{{- if .Values.useHostnames }}
echo "${full_hostname}"
{{- else }}
echo "${hostname}.${HEADLESS_SERVICE}"
getent hosts "${full_hostname}" | awk '{ print $1 ; exit }'
{{- end }}
}
Expand Down
3 changes: 3 additions & 0 deletions bitnami/redis/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ clusterDomain: cluster.local
## @param extraDeploy Array of extra objects to deploy with the release
##
extraDeploy: []
## @param useHostnames Use hostnames internally when announcing replication
###
useHostnames: true

## Enable diagnostic mode in the deployment
##
Expand Down

0 comments on commit 0343396

Please sign in to comment.