Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bitnami/redis] Enables Redis to utilize external-dns #8570

Merged
merged 14 commits into from
Jan 20, 2022
3 changes: 1 addition & 2 deletions bitnami/redis/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@ maintainers:
name: redis
sources:
- https://github.com/bitnami/bitnami-docker-redis
- http://redis.io/
version: 16.0.1
version: 16.1.0
34 changes: 34 additions & 0 deletions bitnami/redis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,16 @@ The command removes all the Kubernetes components associated with the chart and
| `sysctl.resources.requests` | The requested resources for the init container | `{}` |


### useExternalDNS Parameters

| Name | Description | Value |
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| `useExternalDNS.enabled` | Enable various syntax that would enable external-dns to work. Note this requires a working installation of `external-dns` to be usable. | `false` |
| `useExternalDNS.additionalAnnotations` | Extra annotations to be utilized when `external-dns` is enabled. | `{}` |
| `useExternalDNS.annotationKey` | The annotation key utilized when `external-dns` is enabled. | `external-dns.alpha.kubernetes.io/` |
| `useExternalDNS.suffix` | The DNS suffix utilized when `external-dns` is enabled. Note that we prepend the suffix with the full name of the release. | `""` |


Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```bash
Expand Down Expand Up @@ -490,6 +500,30 @@ Bitnami will release a new chart updating its containers if a new version of the

To modify the application version used in this chart, specify a different version of the image using the `image.tag` parameter and/or a different repository using the `image.repository` parameter. Refer to the [chart documentation for more information on these parameters and how to use them with images from a private registry](https://docs.bitnami.com/kubernetes/infrastructure/redis/configuration/change-image-version/).

### External DNS

This chart is equipped to allow leveraging the ExternalDNS project. Doing so will enable ExternalDNS to publish the FQDN for each instance, in the format of `<pod-name>.<release-name>.<dns-suffix>`.
Example, when using the following configuration:

```yaml
useExternalDNS:
enabled: true
suffix: prod.example.org
additionalAnnotations:
ttl: 10
```

On a cluster where the name of the Helm release is `a`, the hostname of a Pod is generated as: `a-redis-node-0.a-redis.prod.example.org`. The IP of that FQDN will match that of the associated Pod. This modifies the following parameters of the Redis/Sentinel configuration using this new FQDN:

* `replica-announce-ip`
* `known-sentinel`
* `known-replica`
* `announce-ip`

:warning: This requires a working installation of `external-dns` to be fully functional. :warning:

See the [official ExternalDNS documentation](https://github.com/kubernetes-sigs/external-dns) for additional configuration options.

### Cluster topologies

#### Default: Master-Replicas
Expand Down
15 changes: 15 additions & 0 deletions bitnami/redis/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,18 @@ redis: tls.enabled
enable auto-generated certificates.
{{- end -}}
{{- end -}}

{{/* Define the suffix utilized for external-dns */}}
{{- define "redis.externalDNS.suffix" -}}
{{ printf "%s.%s" (include "common.names.fullname" .) .Values.useExternalDNS.suffix }}
{{- end -}}

{{/* Compile all annotations utilized for external-dns */}}
{{- define "redis.externalDNS.annotations" -}}
{{- if .Values.useExternalDNS.enabled }}
{{ .Values.useExternalDNS.annotationKey }}hostname: {{ include "redis.externalDNS.suffix" . }}
{{- range $key, $val := .Values.useExternalDNS.additionalAnnotations }}
{{ $.Values.useExternalDNS.annotationKey }}{{ $key }}: {{ $val | quote }}
{{- end }}
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion bitnami/redis/templates/headless-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ metadata:
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
annotations:
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
{{- include "redis.externalDNS.annotations" . | nindent 4 }}
spec:
type: ClusterIP
clusterIP: None
Expand Down
16 changes: 12 additions & 4 deletions bitnami/redis/templates/scripts-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ data:
get_full_hostname() {
hostname="$1"

{{- if eq .Values.sentinel.service.type "NodePort" }}
{{- if .Values.useExternalDNS.enabled }}
echo "${hostname}.{{- include "redis.externalDNS.suffix" . }}"
{{- else if eq .Values.sentinel.service.type "NodePort" }}
echo "${hostname}.{{- .Release.Namespace }}"
{{- else }}
echo "${hostname}.${HEADLESS_SERVICE}"
Expand Down Expand Up @@ -232,7 +234,9 @@ data:
get_full_hostname() {
hostname="$1"

{{- if eq .Values.sentinel.service.type "NodePort" }}
{{- if .Values.useExternalDNS.enabled }}
echo "${hostname}.{{- include "redis.externalDNS.suffix" . }}"
{{- else if eq .Values.sentinel.service.type "NodePort" }}
echo "${hostname}.{{- .Release.Namespace }}"
{{- else }}
echo "${hostname}.${HEADLESS_SERVICE}"
Expand Down Expand Up @@ -361,7 +365,9 @@ data:
get_full_hostname() {
hostname="$1"

{{- if eq .Values.sentinel.service.type "NodePort" }}
{{- if .Values.useExternalDNS.enabled }}
echo "${hostname}.{{- include "redis.externalDNS.suffix" . }}"
{{- else if eq .Values.sentinel.service.type "NodePort" }}
echo "${hostname}.{{- .Release.Namespace }}"
{{- else }}
echo "${hostname}.${HEADLESS_SERVICE}"
Expand Down Expand Up @@ -506,7 +512,9 @@ data:
get_full_hostname() {
hostname="$1"

{{- if eq .Values.sentinel.service.type "NodePort" }}
{{- if .Values.useExternalDNS.enabled }}
echo "${hostname}.{{- include "redis.externalDNS.suffix" . }}"
{{- else if eq .Values.sentinel.service.type "NodePort" }}
echo "${hostname}.{{- .Release.Namespace }}"
{{- else }}
echo "${hostname}.${HEADLESS_SERVICE}"
Expand Down
13 changes: 13 additions & 0 deletions bitnami/redis/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1448,3 +1448,16 @@ sysctl:
resources:
limits: {}
requests: {}

## @section useExternalDNS Parameters
##
## @param useExternalDNS.enabled Enable various syntax that would enable external-dns to work. Note this requires a working installation of `external-dns` to be usable.
## @param useExternalDNS.additionalAnnotations Extra annotations to be utilized when `external-dns` is enabled.
## @param useExternalDNS.annotationKey The annotation key utilized when `external-dns` is enabled.
## @param useExternalDNS.suffix The DNS suffix utilized when `external-dns` is enabled. Note that we prepend the suffix with the full name of the release.
##
useExternalDNS:
enabled: false
suffix: ""
annotationKey: external-dns.alpha.kubernetes.io/
additionalAnnotations: {}