swarm
This commit is contained in:
200
helm/redis/templates/NOTES.txt
Normal file
200
helm/redis/templates/NOTES.txt
Normal file
@ -0,0 +1,200 @@
|
||||
CHART NAME: {{ .Chart.Name }}
|
||||
CHART VERSION: {{ .Chart.Version }}
|
||||
APP VERSION: {{ .Chart.AppVersion }}
|
||||
|
||||
** Please be patient while the chart is being deployed **
|
||||
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:
|
||||
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}
|
||||
|
||||
Get the list of pods by executing:
|
||||
|
||||
kubectl get pods --namespace {{ .Release.Namespace }} -l app.kubernetes.io/instance={{ .Release.Name }}
|
||||
|
||||
Access the pod you want to debug by executing
|
||||
|
||||
kubectl exec --namespace {{ .Release.Namespace }} -ti <NAME OF THE POD> -- bash
|
||||
|
||||
In order to replicate the container startup scripts execute this command:
|
||||
|
||||
For Redis:
|
||||
|
||||
/opt/bitnami/scripts/redis/entrypoint.sh /opt/bitnami/scripts/redis/run.sh
|
||||
|
||||
{{- if .Values.sentinel.enabled }}
|
||||
|
||||
For Redis Sentinel:
|
||||
|
||||
/opt/bitnami/scripts/redis-sentinel/entrypoint.sh /opt/bitnami/scripts/redis-sentinel/run.sh
|
||||
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
|
||||
{{- if contains .Values.master.service.type "LoadBalancer" }}
|
||||
{{- if not .Values.auth.enabled }}
|
||||
{{ if and (not .Values.networkPolicy.enabled) (.Values.networkPolicy.allowExternal) }}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
WARNING
|
||||
|
||||
By specifying "master.service.type=LoadBalancer" and "auth.enabled=false" you have
|
||||
most likely exposed the Redis™ service externally without any authentication
|
||||
mechanism.
|
||||
|
||||
For security reasons, we strongly suggest that you switch to "ClusterIP" or
|
||||
"NodePort". As alternative, you can also switch to "auth.enabled=true"
|
||||
providing a valid password on "password" parameter.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if eq .Values.architecture "replication" }}
|
||||
{{- if .Values.sentinel.enabled }}
|
||||
|
||||
Redis™ can be accessed via port {{ .Values.sentinel.service.port }} on the following DNS name from within your cluster:
|
||||
|
||||
{{ template "common.names.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }} for read only operations
|
||||
|
||||
For read/write operations, first access the Redis™ Sentinel cluster, which is available in port {{ .Values.sentinel.service.sentinelPort }} using the same domain name above.
|
||||
|
||||
{{- else }}
|
||||
|
||||
Redis™ can be accessed on the following DNS names from within your cluster:
|
||||
|
||||
{{ printf "%s-master.%s.svc.%s" (include "common.names.fullname" .) .Release.Namespace .Values.clusterDomain }} for read/write operations (port {{ .Values.master.service.port }})
|
||||
{{ printf "%s-replicas.%s.svc.%s" (include "common.names.fullname" .) .Release.Namespace .Values.clusterDomain }} for read-only operations (port {{ .Values.replica.service.port }})
|
||||
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
|
||||
Redis™ can be accessed via port {{ .Values.master.service.port }} on the following DNS name from within your cluster:
|
||||
|
||||
{{ template "common.names.fullname" . }}-master.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
|
||||
|
||||
{{- end }}
|
||||
|
||||
{{ if .Values.auth.enabled }}
|
||||
|
||||
To get your password run:
|
||||
|
||||
export REDIS_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "redis.secretName" . }} -o jsonpath="{.data.redis-password}" | base64 --decode)
|
||||
|
||||
{{- end }}
|
||||
|
||||
To connect to your Redis™ server:
|
||||
|
||||
1. Run a Redis™ pod that you can use as a client:
|
||||
|
||||
kubectl run --namespace {{ .Release.Namespace }} redis-client --restart='Never' {{ if .Values.auth.enabled }} --env REDISCLI_AUTH=$REDIS_PASSWORD {{ end }} --image {{ template "redis.image" . }} --command -- sleep infinity
|
||||
|
||||
{{- if .Values.tls.enabled }}
|
||||
|
||||
Copy your TLS certificates to the pod:
|
||||
|
||||
kubectl cp --namespace {{ .Release.Namespace }} /path/to/client.cert redis-client:/tmp/client.cert
|
||||
kubectl cp --namespace {{ .Release.Namespace }} /path/to/client.key redis-client:/tmp/client.key
|
||||
kubectl cp --namespace {{ .Release.Namespace }} /path/to/CA.cert redis-client:/tmp/CA.cert
|
||||
|
||||
{{- end }}
|
||||
|
||||
Use the following command to attach to the pod:
|
||||
|
||||
kubectl exec --tty -i redis-client \
|
||||
{{- if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}--labels="{{ template "common.names.fullname" . }}-client=true" \{{- end }}
|
||||
--namespace {{ .Release.Namespace }} -- bash
|
||||
|
||||
2. Connect using the Redis™ CLI:
|
||||
|
||||
{{- if eq .Values.architecture "replication" }}
|
||||
{{- if .Values.sentinel.enabled }}
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h {{ template "common.names.fullname" . }} -p {{ .Values.sentinel.service.port }}{{ if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }} # Read only operations
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h {{ template "common.names.fullname" . }} -p {{ .Values.sentinel.service.sentinelPort }}{{ if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }} # Sentinel access
|
||||
{{- else }}
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h {{ printf "%s-master" (include "common.names.fullname" .) }}{{ if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h {{ printf "%s-replicas" (include "common.names.fullname" .) }}{{ if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h {{ template "common.names.fullname" . }}-master{{ if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}
|
||||
|
||||
Note: Since NetworkPolicy is enabled, only pods with label {{ template "common.names.fullname" . }}-client=true" will be able to connect to redis.
|
||||
|
||||
{{- else }}
|
||||
|
||||
To connect to your database from outside the cluster execute the following commands:
|
||||
|
||||
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled }}
|
||||
{{- if contains "NodePort" .Values.sentinel.service.type }}
|
||||
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "common.names.fullname" . }})
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h $NODE_IP -p $NODE_PORT {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||
|
||||
{{- else if contains "LoadBalancer" .Values.sentinel.service.type }}
|
||||
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "common.names.fullname" . }}'
|
||||
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "common.names.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h $SERVICE_IP -p {{ .Values.sentinel.service.port }} {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||
|
||||
{{- else if contains "ClusterIP" .Values.sentinel.service.type }}
|
||||
|
||||
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "common.names.fullname" . }} {{ .Values.sentinel.service.port }}:{{ .Values.sentinel.service.port }} &
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h 127.0.0.1 -p {{ .Values.sentinel.service.port }} {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- if contains "NodePort" .Values.master.service.type }}
|
||||
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ printf "%s-master" (include "common.names.fullname" .) }})
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h $NODE_IP -p $NODE_PORT {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||
|
||||
{{- else if contains "LoadBalancer" .Values.master.service.type }}
|
||||
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "common.names.fullname" . }}'
|
||||
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ printf "%s-master" (include "common.names.fullname" .) }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h $SERVICE_IP -p {{ .Values.master.service.port }} {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||
|
||||
{{- else if contains "ClusterIP" .Values.master.service.type }}
|
||||
|
||||
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ printf "%s-master" (include "common.names.fullname" .) }} {{ .Values.master.service.port }}:{{ .Values.master.service.port }} &
|
||||
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h 127.0.0.1 -p {{ .Values.master.service.port }} {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- include "redis.checkRollingTags" . }}
|
||||
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}
|
||||
{{- include "common.warnings.rollingTag" .Values.sysctl.image }}
|
||||
{{- include "redis.validateValues" . }}
|
||||
{{- $requiredPassword := list -}}
|
||||
{{- $secretName := include "redis.secretName" . -}}
|
||||
{{- $secretPasswordKey := include "redis.secretPasswordKey" . -}}
|
||||
{{- if and .Values.auth.enabled (not .Values.auth.existingSecret) (not .Values.global.redis.password) -}}
|
||||
{{- $requiredRedisPassword := dict "valueKey" "auth.password" "secret" $secretName "field" $secretPasswordKey -}}
|
||||
{{- $requiredPassword = append $requiredPassword $requiredRedisPassword -}}
|
||||
{{- end -}}
|
||||
{{- $requiredRedisPasswordErrors := include "common.validations.values.multiple.empty" (dict "required" $requiredPassword "context" $) -}}
|
||||
{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" (list $requiredRedisPasswordErrors) "context" $) -}}
|
||||
|
||||
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled (eq .Values.sentinel.service.type "NodePort") (not .Release.IsUpgrade ) }}
|
||||
{{- if $.Values.sentinel.service.nodePorts.sentinel }}
|
||||
No need to upgrade, ports and nodeports have been set from values
|
||||
{{- else }}
|
||||
#!#!#!#!#!#!#!# IMPORTANT #!#!#!#!#!#!#!#
|
||||
YOU NEED TO PERFORM AN UPGRADE FOR THE SERVICES AND WORKLOAD TO BE CREATED
|
||||
{{- end }}
|
||||
{{- end }}
|
261
helm/redis/templates/_helpers.tpl
Normal file
261
helm/redis/templates/_helpers.tpl
Normal file
@ -0,0 +1,261 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
|
||||
{{/*
|
||||
Return the proper Redis image name
|
||||
*/}}
|
||||
{{- define "redis.image" -}}
|
||||
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the proper Redis Sentinel image name
|
||||
*/}}
|
||||
{{- define "redis.sentinel.image" -}}
|
||||
{{ include "common.images.image" (dict "imageRoot" .Values.sentinel.image "global" .Values.global) }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the proper image name (for the metrics image)
|
||||
*/}}
|
||||
{{- define "redis.metrics.image" -}}
|
||||
{{ include "common.images.image" (dict "imageRoot" .Values.metrics.image "global" .Values.global) }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the proper image name (for the init container volume-permissions image)
|
||||
*/}}
|
||||
{{- define "redis.volumePermissions.image" -}}
|
||||
{{ include "common.images.image" (dict "imageRoot" .Values.volumePermissions.image "global" .Values.global) }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return sysctl image
|
||||
*/}}
|
||||
{{- define "redis.sysctl.image" -}}
|
||||
{{ include "common.images.image" (dict "imageRoot" .Values.sysctl.image "global" .Values.global) }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the proper Docker Image Registry Secret Names
|
||||
*/}}
|
||||
{{- define "redis.imagePullSecrets" -}}
|
||||
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.sentinel.image .Values.metrics.image .Values.volumePermissions.image .Values.sysctl.image) "global" .Values.global) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the appropriate apiVersion for networkpolicy.
|
||||
*/}}
|
||||
{{- define "networkPolicy.apiVersion" -}}
|
||||
{{- if semverCompare ">=1.4-0, <1.7-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
{{- print "extensions/v1beta1" -}}
|
||||
{{- else -}}
|
||||
{{- print "networking.k8s.io/v1" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the appropriate apiGroup for PodSecurityPolicy.
|
||||
*/}}
|
||||
{{- define "podSecurityPolicy.apiGroup" -}}
|
||||
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
{{- print "policy" -}}
|
||||
{{- else -}}
|
||||
{{- print "extensions" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return true if a TLS secret object should be created
|
||||
*/}}
|
||||
{{- define "redis.createTlsSecret" -}}
|
||||
{{- if and .Values.tls.enabled .Values.tls.autoGenerated (and (not .Values.tls.existingSecret) (not .Values.tls.certificatesSecret)) }}
|
||||
{{- true -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the secret containing Redis TLS certificates
|
||||
*/}}
|
||||
{{- define "redis.tlsSecretName" -}}
|
||||
{{- $secretName := coalesce .Values.tls.existingSecret .Values.tls.certificatesSecret -}}
|
||||
{{- if $secretName -}}
|
||||
{{- printf "%s" (tpl $secretName $) -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-crt" (include "common.names.fullname" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the path to the cert file.
|
||||
*/}}
|
||||
{{- define "redis.tlsCert" -}}
|
||||
{{- if (include "redis.createTlsSecret" . ) -}}
|
||||
{{- printf "/opt/bitnami/redis/certs/%s" "tls.crt" -}}
|
||||
{{- else -}}
|
||||
{{- required "Certificate filename is required when TLS in enabled" .Values.tls.certFilename | printf "/opt/bitnami/redis/certs/%s" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the path to the cert key file.
|
||||
*/}}
|
||||
{{- define "redis.tlsCertKey" -}}
|
||||
{{- if (include "redis.createTlsSecret" . ) -}}
|
||||
{{- printf "/opt/bitnami/redis/certs/%s" "tls.key" -}}
|
||||
{{- else -}}
|
||||
{{- required "Certificate Key filename is required when TLS in enabled" .Values.tls.certKeyFilename | printf "/opt/bitnami/redis/certs/%s" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the path to the CA cert file.
|
||||
*/}}
|
||||
{{- define "redis.tlsCACert" -}}
|
||||
{{- if (include "redis.createTlsSecret" . ) -}}
|
||||
{{- printf "/opt/bitnami/redis/certs/%s" "ca.crt" -}}
|
||||
{{- else -}}
|
||||
{{- required "Certificate CA filename is required when TLS in enabled" .Values.tls.certCAFilename | printf "/opt/bitnami/redis/certs/%s" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the path to the DH params file.
|
||||
*/}}
|
||||
{{- define "redis.tlsDHParams" -}}
|
||||
{{- if .Values.tls.dhParamsFilename -}}
|
||||
{{- printf "/opt/bitnami/redis/certs/%s" .Values.tls.dhParamsFilename -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "redis.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
{{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else -}}
|
||||
{{ default "default" .Values.serviceAccount.name }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return the configuration configmap name
|
||||
*/}}
|
||||
{{- define "redis.configmapName" -}}
|
||||
{{- if .Values.existingConfigmap -}}
|
||||
{{- printf "%s" (tpl .Values.existingConfigmap $) -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-configuration" (include "common.names.fullname" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return true if a configmap object should be created
|
||||
*/}}
|
||||
{{- define "redis.createConfigmap" -}}
|
||||
{{- if empty .Values.existingConfigmap }}
|
||||
{{- true -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Get the password secret.
|
||||
*/}}
|
||||
{{- define "redis.secretName" -}}
|
||||
{{- if .Values.auth.existingSecret -}}
|
||||
{{- printf "%s" .Values.auth.existingSecret -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s" (include "common.names.fullname" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Get the password key to be retrieved from Redis™ secret.
|
||||
*/}}
|
||||
{{- define "redis.secretPasswordKey" -}}
|
||||
{{- if and .Values.auth.existingSecret .Values.auth.existingSecretPasswordKey -}}
|
||||
{{- printf "%s" .Values.auth.existingSecretPasswordKey -}}
|
||||
{{- else -}}
|
||||
{{- printf "redis-password" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Return Redis™ password
|
||||
*/}}
|
||||
{{- define "redis.password" -}}
|
||||
{{- if not (empty .Values.global.redis.password) }}
|
||||
{{- .Values.global.redis.password -}}
|
||||
{{- else if not (empty .Values.auth.password) -}}
|
||||
{{- .Values.auth.password -}}
|
||||
{{- else -}}
|
||||
{{- randAlphaNum 10 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Check if there are rolling tags in the images */}}
|
||||
{{- define "redis.checkRollingTags" -}}
|
||||
{{- include "common.warnings.rollingTag" .Values.image }}
|
||||
{{- include "common.warnings.rollingTag" .Values.sentinel.image }}
|
||||
{{- include "common.warnings.rollingTag" .Values.metrics.image }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Compile all warnings into a single message, and call fail.
|
||||
*/}}
|
||||
{{- define "redis.validateValues" -}}
|
||||
{{- $messages := list -}}
|
||||
{{- $messages := append $messages (include "redis.validateValues.spreadConstraints" .) -}}
|
||||
{{- $messages := append $messages (include "redis.validateValues.architecture" .) -}}
|
||||
{{- $messages := append $messages (include "redis.validateValues.podSecurityPolicy.create" .) -}}
|
||||
{{- $messages := append $messages (include "redis.validateValues.tls" .) -}}
|
||||
{{- $messages := without $messages "" -}}
|
||||
{{- $message := join "\n" $messages -}}
|
||||
|
||||
{{- if $message -}}
|
||||
{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Validate values of Redis™ - spreadConstrainsts K8s version */}}
|
||||
{{- define "redis.validateValues.spreadConstraints" -}}
|
||||
{{- if and (semverCompare "<1.16-0" .Capabilities.KubeVersion.GitVersion) .Values.replica.spreadConstraints -}}
|
||||
redis: spreadConstraints
|
||||
Pod Topology Spread Constraints are only available on K8s >= 1.16
|
||||
Find more information at https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Validate values of Redis™ - must provide a valid architecture */}}
|
||||
{{- define "redis.validateValues.architecture" -}}
|
||||
{{- if and (ne .Values.architecture "standalone") (ne .Values.architecture "replication") -}}
|
||||
redis: architecture
|
||||
Invalid architecture selected. Valid values are "standalone" and
|
||||
"replication". Please set a valid architecture (--set architecture="xxxx")
|
||||
{{- end -}}
|
||||
{{- if and .Values.sentinel.enabled (not (eq .Values.architecture "replication")) }}
|
||||
redis: architecture
|
||||
Using redis sentinel on standalone mode is not supported.
|
||||
To deploy redis sentinel, please select the "replication" mode
|
||||
(--set "architecture=replication,sentinel.enabled=true")
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Validate values of Redis™ - PodSecurityPolicy create */}}
|
||||
{{- define "redis.validateValues.podSecurityPolicy.create" -}}
|
||||
{{- if and .Values.podSecurityPolicy.create (not .Values.podSecurityPolicy.enabled) }}
|
||||
redis: podSecurityPolicy.create
|
||||
In order to create PodSecurityPolicy, you also need to enable
|
||||
podSecurityPolicy.enabled field
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Validate values of Redis™ - TLS enabled */}}
|
||||
{{- define "redis.validateValues.tls" -}}
|
||||
{{- if and .Values.tls.enabled (not .Values.tls.autoGenerated) (not .Values.tls.existingSecret) (not .Values.tls.certificatesSecret) }}
|
||||
redis: tls.enabled
|
||||
In order to enable TLS, you also need to provide
|
||||
an existing secret containing the TLS certificates or
|
||||
enable auto-generated certificates.
|
||||
{{- end -}}
|
||||
{{- end -}}
|
60
helm/redis/templates/configmap.yaml
Normal file
60
helm/redis/templates/configmap.yaml
Normal file
@ -0,0 +1,60 @@
|
||||
{{- if (include "redis.createConfigmap" .) }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ printf "%s-configuration" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
redis.conf: |-
|
||||
# User-supplied common configuration:
|
||||
{{- if .Values.commonConfiguration }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonConfiguration "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
# End of common configuration
|
||||
master.conf: |-
|
||||
dir {{ .Values.master.persistence.path }}
|
||||
# User-supplied master configuration:
|
||||
{{- if .Values.master.configuration }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.master.configuration "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.disableCommands }}
|
||||
{{- range .Values.master.disableCommands }}
|
||||
rename-command {{ . }} ""
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
# End of master configuration
|
||||
replica.conf: |-
|
||||
dir {{ .Values.replica.persistence.path }}
|
||||
slave-read-only yes
|
||||
# User-supplied replica configuration:
|
||||
{{- if .Values.replica.configuration }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.configuration "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.disableCommands }}
|
||||
{{- range .Values.replica.disableCommands }}
|
||||
rename-command {{ . }} ""
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
# End of replica configuration
|
||||
{{- if .Values.sentinel.enabled }}
|
||||
sentinel.conf: |-
|
||||
dir "/tmp"
|
||||
port {{ .Values.sentinel.containerPort }}
|
||||
sentinel monitor {{ .Values.sentinel.masterSet }} {{ template "common.names.fullname" . }}-node-0.{{ template "common.names.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }} {{ .Values.sentinel.service.port }} {{ .Values.sentinel.quorum }}
|
||||
sentinel down-after-milliseconds {{ .Values.sentinel.masterSet }} {{ .Values.sentinel.downAfterMilliseconds }}
|
||||
sentinel failover-timeout {{ .Values.sentinel.masterSet }} {{ .Values.sentinel.failoverTimeout }}
|
||||
sentinel parallel-syncs {{ .Values.sentinel.masterSet }} {{ .Values.sentinel.parallelSyncs }}
|
||||
# User-supplied sentinel configuration:
|
||||
{{- if .Values.sentinel.configuration }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.configuration "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
# End of sentinel configuration
|
||||
{{- end }}
|
||||
{{- end }}
|
4
helm/redis/templates/extra-list.yaml
Normal file
4
helm/redis/templates/extra-list.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
{{- range .Values.extraDeploy }}
|
||||
---
|
||||
{{ include "common.tplvalues.render" (dict "value" . "context" $) }}
|
||||
{{- end }}
|
28
helm/redis/templates/headless-svc.yaml
Normal file
28
helm/redis/templates/headless-svc.yaml
Normal file
@ -0,0 +1,28 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ printf "%s-headless" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: ClusterIP
|
||||
clusterIP: None
|
||||
{{- if .Values.sentinel.enabled }}
|
||||
publishNotReadyAddresses: true
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: tcp-redis
|
||||
port: {{ if .Values.sentinel.enabled }}{{ .Values.sentinel.service.port }}{{ else }}{{ .Values.master.service.port }}{{ end }}
|
||||
targetPort: redis
|
||||
{{- if .Values.sentinel.enabled }}
|
||||
- name: tcp-sentinel
|
||||
port: {{ .Values.sentinel.service.sentinelPort }}
|
||||
targetPort: redis-sentinel
|
||||
{{- end }}
|
||||
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
|
170
helm/redis/templates/health-configmap.yaml
Normal file
170
helm/redis/templates/health-configmap.yaml
Normal file
@ -0,0 +1,170 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ printf "%s-health" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
ping_readiness_local.sh: |-
|
||||
#!/bin/bash
|
||||
|
||||
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
|
||||
response=$(
|
||||
timeout -s 3 $1 \
|
||||
redis-cli \
|
||||
-h localhost \
|
||||
{{- if .Values.tls.enabled }}
|
||||
-p $REDIS_TLS_PORT \
|
||||
--tls \
|
||||
--cacert {{ template "redis.tlsCACert" . }} \
|
||||
{{- if .Values.tls.authClients }}
|
||||
--cert {{ template "redis.tlsCert" . }} \
|
||||
--key {{ template "redis.tlsCertKey" . }} \
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
-p $REDIS_PORT \
|
||||
{{- end }}
|
||||
ping
|
||||
)
|
||||
if [ "$response" != "PONG" ]; then
|
||||
echo "$response"
|
||||
exit 1
|
||||
fi
|
||||
ping_liveness_local.sh: |-
|
||||
#!/bin/bash
|
||||
|
||||
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
|
||||
response=$(
|
||||
timeout -s 3 $1 \
|
||||
redis-cli \
|
||||
-h localhost \
|
||||
{{- if .Values.tls.enabled }}
|
||||
-p $REDIS_TLS_PORT \
|
||||
--tls \
|
||||
--cacert {{ template "redis.tlsCACert" . }} \
|
||||
{{- if .Values.tls.authClients }}
|
||||
--cert {{ template "redis.tlsCert" . }} \
|
||||
--key {{ template "redis.tlsCertKey" . }} \
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
-p $REDIS_PORT \
|
||||
{{- end }}
|
||||
ping
|
||||
)
|
||||
if [ "$response" != "PONG" ] && [ "$response" != "LOADING Redis is loading the dataset in memory" ]; then
|
||||
echo "$response"
|
||||
exit 1
|
||||
fi
|
||||
{{- if .Values.sentinel.enabled }}
|
||||
ping_sentinel.sh: |-
|
||||
#!/bin/bash
|
||||
|
||||
{{- if .Values.auth.sentinel }}
|
||||
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
|
||||
{{- end }}
|
||||
response=$(
|
||||
timeout -s 3 $1 \
|
||||
redis-cli \
|
||||
-h localhost \
|
||||
{{- if .Values.tls.enabled }}
|
||||
-p $REDIS_SENTINEL_TLS_PORT_NUMBER \
|
||||
--tls \
|
||||
--cacert {{ template "redis.tlsCACert" . }} \
|
||||
{{- if .Values.tls.authClients }}
|
||||
--cert {{ template "redis.tlsCert" . }} \
|
||||
--key {{ template "redis.tlsCertKey" . }} \
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
-p $REDIS_SENTINEL_PORT \
|
||||
{{- end }}
|
||||
ping
|
||||
)
|
||||
if [ "$response" != "PONG" ]; then
|
||||
echo "$response"
|
||||
exit 1
|
||||
fi
|
||||
parse_sentinels.awk: |-
|
||||
/ip/ {FOUND_IP=1}
|
||||
/port/ {FOUND_PORT=1}
|
||||
/runid/ {FOUND_RUNID=1}
|
||||
!/ip|port|runid/ {
|
||||
if (FOUND_IP==1) {
|
||||
IP=$1; FOUND_IP=0;
|
||||
}
|
||||
else if (FOUND_PORT==1) {
|
||||
PORT=$1;
|
||||
FOUND_PORT=0;
|
||||
} else if (FOUND_RUNID==1) {
|
||||
printf "\nsentinel known-sentinel {{ .Values.sentinel.masterSet }} %s %s %s", IP, PORT, $0; FOUND_RUNID=0;
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
ping_readiness_master.sh: |-
|
||||
#!/bin/bash
|
||||
|
||||
[[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
|
||||
[[ -n "$REDIS_MASTER_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_MASTER_PASSWORD"
|
||||
response=$(
|
||||
timeout -s 3 $1 \
|
||||
redis-cli \
|
||||
-h $REDIS_MASTER_HOST \
|
||||
-p $REDIS_MASTER_PORT_NUMBER \
|
||||
{{- if .Values.tls.enabled }}
|
||||
--tls \
|
||||
--cacert {{ template "redis.tlsCACert" . }} \
|
||||
{{- if .Values.tls.authClients }}
|
||||
--cert {{ template "redis.tlsCert" . }} \
|
||||
--key {{ template "redis.tlsCertKey" . }} \
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ping
|
||||
)
|
||||
if [ "$response" != "PONG" ]; then
|
||||
echo "$response"
|
||||
exit 1
|
||||
fi
|
||||
ping_liveness_master.sh: |-
|
||||
#!/bin/bash
|
||||
|
||||
[[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
|
||||
[[ -n "$REDIS_MASTER_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_MASTER_PASSWORD"
|
||||
response=$(
|
||||
timeout -s 3 $1 \
|
||||
redis-cli \
|
||||
-h $REDIS_MASTER_HOST \
|
||||
-p $REDIS_MASTER_PORT_NUMBER \
|
||||
{{- if .Values.tls.enabled }}
|
||||
--tls \
|
||||
--cacert {{ template "redis.tlsCACert" . }} \
|
||||
{{- if .Values.tls.authClients }}
|
||||
--cert {{ template "redis.tlsCert" . }} \
|
||||
--key {{ template "redis.tlsCertKey" . }} \
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ping
|
||||
)
|
||||
if [ "$response" != "PONG" ] && [ "$response" != "LOADING Redis is loading the dataset in memory" ]; then
|
||||
echo "$response"
|
||||
exit 1
|
||||
fi
|
||||
ping_readiness_local_and_master.sh: |-
|
||||
script_dir="$(dirname "$0")"
|
||||
exit_status=0
|
||||
"$script_dir/ping_readiness_local.sh" $1 || exit_status=$?
|
||||
"$script_dir/ping_readiness_master.sh" $1 || exit_status=$?
|
||||
exit $exit_status
|
||||
ping_liveness_local_and_master.sh: |-
|
||||
script_dir="$(dirname "$0")"
|
||||
exit_status=0
|
||||
"$script_dir/ping_liveness_local.sh" $1 || exit_status=$?
|
||||
"$script_dir/ping_liveness_master.sh" $1 || exit_status=$?
|
||||
exit $exit_status
|
46
helm/redis/templates/master/psp.yaml
Normal file
46
helm/redis/templates/master/psp.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
{{- $pspAvailable := (semverCompare "<1.25-0" (include "common.capabilities.kubeVersion" .)) -}}
|
||||
{{- if and $pspAvailable .Values.podSecurityPolicy.create }}
|
||||
apiVersion: policy/v1beta1
|
||||
kind: PodSecurityPolicy
|
||||
metadata:
|
||||
name: {{ printf "%s-master" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
allowPrivilegeEscalation: false
|
||||
fsGroup:
|
||||
rule: 'MustRunAs'
|
||||
ranges:
|
||||
- min: {{ .Values.master.podSecurityContext.fsGroup }}
|
||||
max: {{ .Values.master.podSecurityContext.fsGroup }}
|
||||
hostIPC: false
|
||||
hostNetwork: false
|
||||
hostPID: false
|
||||
privileged: false
|
||||
readOnlyRootFilesystem: false
|
||||
requiredDropCapabilities:
|
||||
- ALL
|
||||
runAsUser:
|
||||
rule: 'MustRunAs'
|
||||
ranges:
|
||||
- min: {{ .Values.master.containerSecurityContext.runAsUser }}
|
||||
max: {{ .Values.master.containerSecurityContext.runAsUser }}
|
||||
seLinux:
|
||||
rule: 'RunAsAny'
|
||||
supplementalGroups:
|
||||
rule: 'MustRunAs'
|
||||
ranges:
|
||||
- min: {{ .Values.master.containerSecurityContext.runAsUser }}
|
||||
max: {{ .Values.master.containerSecurityContext.runAsUser }}
|
||||
volumes:
|
||||
- 'configMap'
|
||||
- 'secret'
|
||||
- 'emptyDir'
|
||||
- 'persistentVolumeClaim'
|
||||
{{- end }}
|
46
helm/redis/templates/master/service.yaml
Normal file
46
helm/redis/templates/master/service.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
{{- if not .Values.sentinel.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ printf "%s-master" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
app.kubernetes.io/component: master
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.master.service.annotations .Values.commonAnnotations }}
|
||||
annotations:
|
||||
{{- if .Values.master.service.annotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.master.service.annotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.master.service.type }}
|
||||
{{ if eq .Values.master.service.type "LoadBalancer" }}
|
||||
externalTrafficPolicy: {{ .Values.master.service.externalTrafficPolicy }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.master.service.type "LoadBalancer") .Values.master.service.loadBalancerIP }}
|
||||
loadBalancerIP: {{ .Values.master.service.loadBalancerIP }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.master.service.type "LoadBalancer") .Values.master.service.loadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges: {{- toYaml .Values.master.service.loadBalancerSourceRanges | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.master.service.type "ClusterIP") .Values.master.service.clusterIP }}
|
||||
clusterIP: {{ .Values.master.service.clusterIP }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: tcp-redis
|
||||
port: {{ .Values.master.service.port }}
|
||||
targetPort: redis
|
||||
{{- if and (or (eq .Values.master.service.type "NodePort") (eq .Values.master.service.type "LoadBalancer")) .Values.master.service.nodePort }}
|
||||
nodePort: {{ .Values.master.service.nodePort }}
|
||||
{{- else if eq .Values.master.service.type "ClusterIP" }}
|
||||
nodePort: null
|
||||
{{- end }}
|
||||
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: master
|
||||
{{- end }}
|
443
helm/redis/templates/master/statefulset.yaml
Normal file
443
helm/redis/templates/master/statefulset.yaml
Normal file
@ -0,0 +1,443 @@
|
||||
{{- if or (not (eq .Values.architecture "replication")) (not .Values.sentinel.enabled) }}
|
||||
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ printf "%s-master" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
app.kubernetes.io/component: master
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: master
|
||||
serviceName: {{ printf "%s-headless" (include "common.names.fullname" .) }}
|
||||
{{- if .Values.master.updateStrategy }}
|
||||
updateStrategy: {{- toYaml .Values.master.updateStrategy | nindent 4 }}
|
||||
{{- end }}
|
||||
template:
|
||||
metadata:
|
||||
labels: {{- include "common.labels.standard" . | nindent 8 }}
|
||||
app.kubernetes.io/component: master
|
||||
{{- if .Values.master.podLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.master.podLabels "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.podLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podLabels "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
{{- if (include "redis.createConfigmap" .) }}
|
||||
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
|
||||
{{- end }}
|
||||
checksum/health: {{ include (print $.Template.BasePath "/health-configmap.yaml") . | sha256sum }}
|
||||
checksum/scripts: {{ include (print $.Template.BasePath "/scripts-configmap.yaml") . | sha256sum }}
|
||||
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
|
||||
{{- if .Values.master.podAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.master.podAnnotations "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "redis.imagePullSecrets" . | nindent 6 }}
|
||||
{{- if .Values.master.hostAliases }}
|
||||
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.master.hostAliases "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.podSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.master.podSecurityContext "enabled" | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "redis.serviceAccountName" . }}
|
||||
{{- if .Values.master.priorityClassName }}
|
||||
priorityClassName: {{ .Values.master.priorityClassName | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.affinity }}
|
||||
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.master.affinity "context" $) | nindent 8 }}
|
||||
{{- else }}
|
||||
affinity:
|
||||
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.master.podAffinityPreset "component" "master" "context" $) | nindent 10 }}
|
||||
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.master.podAntiAffinityPreset "component" "master" "context" $) | nindent 10 }}
|
||||
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.master.nodeAffinityPreset.type "key" .Values.master.nodeAffinityPreset.key "values" .Values.master.nodeAffinityPreset.values) | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.nodeSelector }}
|
||||
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.master.nodeSelector "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.tolerations }}
|
||||
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.master.tolerations "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.spreadConstraints }}
|
||||
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.master.spreadConstraints "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.shareProcessNamespace }}
|
||||
shareProcessNamespace: {{ .Values.master.shareProcessNamespace }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.schedulerName }}
|
||||
schedulerName: {{ .Values.master.schedulerName | quote }}
|
||||
{{- end }}
|
||||
terminationGracePeriodSeconds: {{ .Values.master.terminationGracePeriodSeconds }}
|
||||
containers:
|
||||
- name: redis
|
||||
image: {{ template "redis.image" . }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
||||
{{- if .Values.master.lifecycleHooks }}
|
||||
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.master.lifecycleHooks "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.containerSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.master.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||
{{- else if .Values.master.command }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.master.command "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
command:
|
||||
- /bin/bash
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||
{{- else if .Values.master.args }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.master.args "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
args:
|
||||
- -c
|
||||
- /opt/bitnami/scripts/start-scripts/start-master.sh
|
||||
{{- end }}
|
||||
env:
|
||||
- name: BITNAMI_DEBUG
|
||||
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
|
||||
- name: REDIS_REPLICATION_MODE
|
||||
value: master
|
||||
- name: ALLOW_EMPTY_PASSWORD
|
||||
value: {{ ternary "no" "yes" .Values.auth.enabled | quote }}
|
||||
{{- if .Values.auth.enabled }}
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: REDIS_PASSWORD_FILE
|
||||
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||
{{- else }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "redis.secretName" . }}
|
||||
key: {{ template "redis.secretPasswordKey" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
- name: REDIS_TLS_ENABLED
|
||||
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: REDIS_TLS_PORT
|
||||
value: {{ .Values.master.containerPort | quote }}
|
||||
- name: REDIS_TLS_AUTH_CLIENTS
|
||||
value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
|
||||
- name: REDIS_TLS_CERT_FILE
|
||||
value: {{ template "redis.tlsCert" . }}
|
||||
- name: REDIS_TLS_KEY_FILE
|
||||
value: {{ template "redis.tlsCertKey" . }}
|
||||
- name: REDIS_TLS_CA_FILE
|
||||
value: {{ template "redis.tlsCACert" . }}
|
||||
{{- if .Values.tls.dhParamsFilename }}
|
||||
- name: REDIS_TLS_DH_PARAMS_FILE
|
||||
value: {{ template "redis.tlsDHParams" . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
- name: REDIS_PORT
|
||||
value: {{ .Values.master.containerPort | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.extraEnvVars }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.master.extraEnvVars "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.master.extraEnvVarsCM .Values.master.extraEnvVarsSecret }}
|
||||
envFrom:
|
||||
{{- if .Values.master.extraEnvVarsCM }}
|
||||
- configMapRef:
|
||||
name: {{ .Values.master.extraEnvVarsCM }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.extraEnvVarsSecret }}
|
||||
- secretRef:
|
||||
name: {{ .Values.master.extraEnvVarsSecret }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: redis
|
||||
containerPort: {{ .Values.master.containerPort }}
|
||||
{{- if not .Values.diagnosticMode.enabled }}
|
||||
{{- if .Values.master.livenessProbe.enabled }}
|
||||
livenessProbe:
|
||||
initialDelaySeconds: {{ .Values.master.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.master.livenessProbe.periodSeconds }}
|
||||
# One second longer than command timeout should prevent generation of zombie processes.
|
||||
timeoutSeconds: {{ add1 .Values.master.livenessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.master.livenessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.master.livenessProbe.failureThreshold }}
|
||||
exec:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- /health/ping_liveness_local.sh {{ .Values.master.livenessProbe.timeoutSeconds }}
|
||||
{{- else if .Values.master.customLivenessProbe }}
|
||||
livenessProbe: {{- toYaml .Values.master.customLivenessProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.readinessProbe.enabled }}
|
||||
readinessProbe:
|
||||
initialDelaySeconds: {{ .Values.master.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.master.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ add1 .Values.master.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.master.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.master.readinessProbe.failureThreshold }}
|
||||
exec:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- /health/ping_readiness_local.sh {{ .Values.master.readinessProbe.timeoutSeconds }}
|
||||
{{- else if .Values.master.customReadinessProbe }}
|
||||
readinessProbe: {{- toYaml .Values.master.customReadinessProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.resources }}
|
||||
resources: {{- toYaml .Values.master.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: start-scripts
|
||||
mountPath: /opt/bitnami/scripts/start-scripts
|
||||
- name: health
|
||||
mountPath: /health
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: redis-password
|
||||
mountPath: /opt/bitnami/redis/secrets/
|
||||
{{- end }}
|
||||
- name: redis-data
|
||||
mountPath: {{ .Values.master.persistence.path }}
|
||||
subPath: {{ .Values.master.persistence.subPath }}
|
||||
- name: config
|
||||
mountPath: /opt/bitnami/redis/mounted-etc
|
||||
- name: redis-tmp-conf
|
||||
mountPath: /opt/bitnami/redis/etc/
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: redis-certificates
|
||||
mountPath: /opt/bitnami/redis/certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.master.extraVolumeMounts }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.master.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.enabled }}
|
||||
- name: metrics
|
||||
image: {{ include "redis.metrics.image" . }}
|
||||
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
|
||||
{{- if .Values.metrics.containerSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.metrics.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f '/secrets/redis-password' ]]; then
|
||||
export REDIS_PASSWORD=$(cat /secrets/redis-password)
|
||||
fi
|
||||
redis_exporter{{- range $key, $value := .Values.metrics.extraArgs }} --{{ $key }}={{ $value }}{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
env:
|
||||
- name: REDIS_ALIAS
|
||||
value: {{ template "common.names.fullname" . }}
|
||||
{{- if .Values.auth.enabled }}
|
||||
- name: REDIS_USER
|
||||
value: default
|
||||
{{- if (not .Values.auth.usePasswordFiles) }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "redis.secretName" . }}
|
||||
key: {{ template "redis.secretPasswordKey" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: REDIS_ADDR
|
||||
value: rediss://{{ .Values.metrics.redisTargetHost }}:{{ .Values.master.containerPort }}
|
||||
{{- if .Values.tls.authClients }}
|
||||
- name: REDIS_EXPORTER_TLS_CLIENT_KEY_FILE
|
||||
value: {{ template "redis.tlsCertKey" . }}
|
||||
- name: REDIS_EXPORTER_TLS_CLIENT_CERT_FILE
|
||||
value: {{ template "redis.tlsCert" . }}
|
||||
{{- end }}
|
||||
- name: REDIS_EXPORTER_TLS_CA_CERT_FILE
|
||||
value: {{ template "redis.tlsCACert" . }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 9121
|
||||
{{- if .Values.metrics.resources }}
|
||||
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: redis-password
|
||||
mountPath: /secrets/
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: redis-certificates
|
||||
mountPath: /opt/bitnami/redis/certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.extraVolumeMounts }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.sidecars }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.master.sidecars "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- $needsVolumePermissions := and .Values.volumePermissions.enabled .Values.master.persistence.enabled .Values.master.podSecurityContext.enabled .Values.master.containerSecurityContext.enabled }}
|
||||
{{- if or .Values.master.initContainers $needsVolumePermissions .Values.sysctl.enabled }}
|
||||
initContainers:
|
||||
{{- if .Values.master.initContainers }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.master.initContainers "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if $needsVolumePermissions }}
|
||||
- name: volume-permissions
|
||||
image: {{ include "redis.volumePermissions.image" . }}
|
||||
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
|
||||
command:
|
||||
- /bin/bash
|
||||
- -ec
|
||||
- |
|
||||
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||
chown -R `id -u`:`id -G | cut -d " " -f2` {{ .Values.master.persistence.path }}
|
||||
{{- else }}
|
||||
chown -R {{ .Values.master.containerSecurityContext.runAsUser }}:{{ .Values.master.podSecurityContext.fsGroup }} {{ .Values.master.persistence.path }}
|
||||
{{- end }}
|
||||
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||
securityContext: {{- omit .Values.volumePermissions.containerSecurityContext "runAsUser" | toYaml | nindent 12 }}
|
||||
{{- else }}
|
||||
securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.volumePermissions.resources }}
|
||||
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: redis-data
|
||||
mountPath: {{ .Values.master.persistence.path }}
|
||||
subPath: {{ .Values.master.persistence.subPath }}
|
||||
{{- end }}
|
||||
{{- if .Values.sysctl.enabled }}
|
||||
- name: init-sysctl
|
||||
image: {{ include "redis.sysctl.image" . }}
|
||||
imagePullPolicy: {{ default "" .Values.sysctl.image.pullPolicy | quote }}
|
||||
securityContext:
|
||||
privileged: true
|
||||
runAsUser: 0
|
||||
{{- if .Values.sysctl.command }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.sysctl.command "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.sysctl.resources }}
|
||||
resources: {{- toYaml .Values.sysctl.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.sysctl.mountHostSys }}
|
||||
volumeMounts:
|
||||
- name: host-sys
|
||||
mountPath: /host-sys
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: start-scripts
|
||||
configMap:
|
||||
name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
|
||||
defaultMode: 0755
|
||||
- name: health
|
||||
configMap:
|
||||
name: {{ printf "%s-health" (include "common.names.fullname" .) }}
|
||||
defaultMode: 0755
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: redis-password
|
||||
secret:
|
||||
secretName: {{ template "redis.secretName" . }}
|
||||
items:
|
||||
- key: {{ template "redis.secretPasswordKey" . }}
|
||||
path: redis-password
|
||||
{{- end }}
|
||||
- name: config
|
||||
configMap:
|
||||
name: {{ include "redis.configmapName" . }}
|
||||
{{- if .Values.sysctl.mountHostSys }}
|
||||
- name: host-sys
|
||||
hostPath:
|
||||
path: /sys
|
||||
{{- end }}
|
||||
- name: redis-tmp-conf
|
||||
{{- if .Values.master.persistence.medium }}
|
||||
emptyDir: {
|
||||
medium: {{ .Values.master.persistence.medium | quote }}
|
||||
}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
- name: tmp
|
||||
{{- if .Values.master.persistence.medium }}
|
||||
emptyDir: {
|
||||
medium: {{ .Values.master.persistence.medium | quote }}
|
||||
}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: redis-certificates
|
||||
secret:
|
||||
secretName: {{ include "redis.tlsSecretName" . }}
|
||||
defaultMode: 256
|
||||
{{- end }}
|
||||
{{- if .Values.master.extraVolumes }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.master.extraVolumes "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.extraVolumes }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumes "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if not .Values.master.persistence.enabled }}
|
||||
- name: redis-data
|
||||
{{- if .Values.master.persistence.medium }}
|
||||
emptyDir: {
|
||||
medium: {{ .Values.master.persistence.medium | quote }}
|
||||
}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- else if .Values.master.persistence.existingClaim }}
|
||||
- name: redis-data
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ printf "%s" (tpl .Values.master.persistence.existingClaim .) }}
|
||||
{{- else }}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: redis-data
|
||||
labels: {{- include "common.labels.matchLabels" . | nindent 10 }}
|
||||
app.kubernetes.io/component: master
|
||||
{{- if .Values.master.persistence.annotations }}
|
||||
annotations: {{- toYaml .Values.master.persistence.annotations | nindent 10 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
accessModes:
|
||||
{{- range .Values.master.persistence.accessModes }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.master.persistence.size | quote }}
|
||||
{{- if .Values.master.persistence.selector }}
|
||||
selector: {{- include "common.tplvalues.render" (dict "value" .Values.master.persistence.selector "context" $) | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.persistence.dataSource }}
|
||||
dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.master.persistence.dataSource "context" $) | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- include "common.storage.class" (dict "persistence" .Values.master.persistence "global" .Values.global) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
38
helm/redis/templates/metrics-svc.yaml
Normal file
38
helm/redis/templates/metrics-svc.yaml
Normal file
@ -0,0 +1,38 @@
|
||||
{{- if .Values.metrics.enabled }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ printf "%s-metrics" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
app.kubernetes.io/component: metrics
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.metrics.service.annotations .Values.commonAnnotations }}
|
||||
annotations:
|
||||
{{- if .Values.metrics.service.annotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.service.annotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.metrics.service.type }}
|
||||
{{- if eq .Values.metrics.service.type "LoadBalancer" }}
|
||||
externalTrafficPolicy: {{ .Values.metrics.service.externalTrafficPolicy }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.metrics.service.type "LoadBalancer") .Values.metrics.service.loadBalancerIP }}
|
||||
loadBalancerIP: {{ .Values.metrics.service.loadBalancerIP }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.metrics.service.type "LoadBalancer") .Values.metrics.service.loadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges: {{- toYaml .Values.metrics.service.loadBalancerSourceRanges | nindent 4 }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: http-metrics
|
||||
port: {{ .Values.metrics.service.port }}
|
||||
protocol: TCP
|
||||
targetPort: metrics
|
||||
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
|
||||
{{- end }}
|
78
helm/redis/templates/networkpolicy.yaml
Normal file
78
helm/redis/templates/networkpolicy.yaml
Normal file
@ -0,0 +1,78 @@
|
||||
{{- if .Values.networkPolicy.enabled }}
|
||||
kind: NetworkPolicy
|
||||
apiVersion: {{ template "networkPolicy.apiVersion" . }}
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
|
||||
policyTypes:
|
||||
- Ingress
|
||||
{{- if or (eq .Values.architecture "replication") .Values.networkPolicy.extraEgress }}
|
||||
- Egress
|
||||
egress:
|
||||
{{- if eq .Values.architecture "replication" }}
|
||||
# Allow dns resolution
|
||||
- ports:
|
||||
- port: 53
|
||||
protocol: UDP
|
||||
# Allow outbound connections to other cluster pods
|
||||
- ports:
|
||||
- port: {{ .Values.master.containerPort }}
|
||||
{{- if .Values.sentinel.enabled }}
|
||||
- port: {{ .Values.sentinel.containerPort }}
|
||||
{{- end }}
|
||||
to:
|
||||
- podSelector:
|
||||
matchLabels: {{- include "common.labels.matchLabels" . | nindent 14 }}
|
||||
{{- end }}
|
||||
{{- if .Values.networkPolicy.extraEgress }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ingress:
|
||||
# Allow inbound connections
|
||||
- ports:
|
||||
- port: {{ .Values.master.containerPort }}
|
||||
{{- if .Values.sentinel.enabled }}
|
||||
- port: {{ .Values.sentinel.containerPort }}
|
||||
{{- end }}
|
||||
{{- if not .Values.networkPolicy.allowExternal }}
|
||||
from:
|
||||
- podSelector:
|
||||
matchLabels:
|
||||
{{ template "common.names.fullname" . }}-client: "true"
|
||||
- podSelector:
|
||||
matchLabels: {{- include "common.labels.matchLabels" . | nindent 14 }}
|
||||
{{- if .Values.networkPolicy.ingressNSMatchLabels }}
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
{{- range $key, $value := .Values.networkPolicy.ingressNSMatchLabels }}
|
||||
{{ $key | quote }}: {{ $value | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.networkPolicy.ingressNSPodMatchLabels }}
|
||||
podSelector:
|
||||
matchLabels:
|
||||
{{- range $key, $value := .Values.networkPolicy.ingressNSPodMatchLabels }}
|
||||
{{ $key | quote }}: {{ $value | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.enabled }}
|
||||
# Allow prometheus scrapes for metrics
|
||||
- ports:
|
||||
- port: 9121
|
||||
{{- end }}
|
||||
{{- if .Values.networkPolicy.extraIngress }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
23
helm/redis/templates/pdb.yaml
Normal file
23
helm/redis/templates/pdb.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
{{- if .Values.pdb.create }}
|
||||
apiVersion: {{ include "common.capabilities.policy.apiVersion" . }}
|
||||
kind: PodDisruptionBudget
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if .Values.pdb.minAvailable }}
|
||||
minAvailable: {{ .Values.pdb.minAvailable }}
|
||||
{{- end }}
|
||||
{{- if .Values.pdb.maxUnavailable }}
|
||||
maxUnavailable: {{ .Values.pdb.maxUnavailable }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
|
||||
{{- end }}
|
27
helm/redis/templates/prometheusrule.yaml
Normal file
27
helm/redis/templates/prometheusrule.yaml
Normal file
@ -0,0 +1,27 @@
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}
|
||||
{{- if .Values.metrics.prometheusRule.namespace }}
|
||||
namespace: {{ .Values.metrics.prometheusRule.namespace }}
|
||||
{{- else }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
{{- end }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.metrics.prometheusRule.additionalLabels }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.prometheusRule.additionalLabels "context" $) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- with .Values.metrics.prometheusRule.rules }}
|
||||
groups:
|
||||
- name: {{ template "common.names.name" $ }}
|
||||
rules: {{- tpl (toYaml .) $ | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
35
helm/redis/templates/replicas/hpa.yaml
Normal file
35
helm/redis/templates/replicas/hpa.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
{{- if and .Values.replica.autoscaling.enabled (not .Values.sentinel.enabled) }}
|
||||
apiVersion: autoscaling/v2beta1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ printf "%s-replicas" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
app.kubernetes.io/component: replica
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
|
||||
kind: StatefulSet
|
||||
name: {{ printf "%s-replicas" (include "common.names.fullname" .) }}
|
||||
minReplicas: {{ .Values.replica.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.replica.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
{{- if .Values.replica.autoscaling.targetCPU }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
targetAverageUtilization: {{ .Values.replica.autoscaling.targetCPU }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.autoscaling.targetMemory }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
targetAverageUtilization: {{ .Values.replica.autoscaling.targetMemory }}
|
||||
{{- end }}
|
||||
{{- end }}
|
46
helm/redis/templates/replicas/service.yaml
Normal file
46
helm/redis/templates/replicas/service.yaml
Normal file
@ -0,0 +1,46 @@
|
||||
{{- if and (eq .Values.architecture "replication") (not .Values.sentinel.enabled) }}
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ printf "%s-replicas" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
app.kubernetes.io/component: replica
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.replica.service.annotations .Values.commonAnnotations }}
|
||||
annotations:
|
||||
{{- if .Values.replica.service.annotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.service.annotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.replica.service.type }}
|
||||
{{- if eq .Values.replica.service.type "LoadBalancer" }}
|
||||
externalTrafficPolicy: {{ .Values.replica.service.externalTrafficPolicy }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.replica.service.type "LoadBalancer") .Values.replica.service.loadBalancerIP }}
|
||||
loadBalancerIP: {{ .Values.replica.service.loadBalancerIP }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.replica.service.type "LoadBalancer") .Values.replica.service.loadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges: {{- toYaml .Values.replica.service.loadBalancerSourceRanges | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.replica.service.type "ClusterIP") .Values.replica.service.clusterIP }}
|
||||
clusterIP: {{ .Values.replica.service.clusterIP }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: tcp-redis
|
||||
port: {{ .Values.replica.service.port }}
|
||||
targetPort: redis
|
||||
{{- if and (or (eq .Values.replica.service.type "NodePort") (eq .Values.replica.service.type "LoadBalancer")) .Values.replica.service.nodePort }}
|
||||
nodePort: {{ .Values.replica.service.nodePort }}
|
||||
{{- else if eq .Values.replica.service.type "ClusterIP" }}
|
||||
nodePort: null
|
||||
{{- end }}
|
||||
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: replica
|
||||
{{- end }}
|
443
helm/redis/templates/replicas/statefulset.yaml
Normal file
443
helm/redis/templates/replicas/statefulset.yaml
Normal file
@ -0,0 +1,443 @@
|
||||
{{- if and (eq .Values.architecture "replication") (not .Values.sentinel.enabled) }}
|
||||
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ printf "%s-replicas" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
app.kubernetes.io/component: replica
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if not .Values.replica.autoscaling.enabled }}
|
||||
replicas: {{ .Values.replica.replicaCount }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: replica
|
||||
serviceName: {{ printf "%s-headless" (include "common.names.fullname" .) }}
|
||||
{{- if .Values.replica.updateStrategy }}
|
||||
updateStrategy: {{- toYaml .Values.replica.updateStrategy | nindent 4 }}
|
||||
{{- end }}
|
||||
template:
|
||||
metadata:
|
||||
labels: {{- include "common.labels.standard" . | nindent 8 }}
|
||||
app.kubernetes.io/component: replica
|
||||
{{- if .Values.replica.podLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.podLabels "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.podLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podLabels "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
{{- if (include "redis.createConfigmap" .) }}
|
||||
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
|
||||
{{- end }}
|
||||
checksum/health: {{ include (print $.Template.BasePath "/health-configmap.yaml") . | sha256sum }}
|
||||
checksum/scripts: {{ include (print $.Template.BasePath "/scripts-configmap.yaml") . | sha256sum }}
|
||||
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
|
||||
{{- if .Values.replica.podAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.podAnnotations "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "redis.imagePullSecrets" . | nindent 6 }}
|
||||
{{- if .Values.replica.hostAliases }}
|
||||
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.replica.hostAliases "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.podSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.replica.podSecurityContext "enabled" | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "redis.serviceAccountName" . }}
|
||||
{{- if .Values.replica.priorityClassName }}
|
||||
priorityClassName: {{ .Values.replica.priorityClassName | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.affinity }}
|
||||
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.replica.affinity "context" $) | nindent 8 }}
|
||||
{{- else }}
|
||||
affinity:
|
||||
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAffinityPreset "component" "replica" "context" $) | nindent 10 }}
|
||||
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAntiAffinityPreset "component" "replica" "context" $) | nindent 10 }}
|
||||
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.replica.nodeAffinityPreset.type "key" .Values.replica.nodeAffinityPreset.key "values" .Values.replica.nodeAffinityPreset.values) | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.nodeSelector }}
|
||||
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.replica.nodeSelector "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.tolerations }}
|
||||
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.replica.tolerations "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.spreadConstraints }}
|
||||
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.replica.spreadConstraints "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.shareProcessNamespace }}
|
||||
shareProcessNamespace: {{ .Values.replica.shareProcessNamespace }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.schedulerName }}
|
||||
schedulerName: {{ .Values.replica.schedulerName | quote }}
|
||||
{{- end }}
|
||||
terminationGracePeriodSeconds: {{ .Values.replica.terminationGracePeriodSeconds }}
|
||||
containers:
|
||||
- name: redis
|
||||
image: {{ template "redis.image" . }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
||||
{{- if not .Values.diagnosticMode.enabled }}
|
||||
{{- if .Values.replica.lifecycleHooks }}
|
||||
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.replica.lifecycleHooks "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.containerSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.replica.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||
{{- else if .Values.replica.command }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.replica.command "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
command:
|
||||
- /bin/bash
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||
{{- else if .Values.replica.args }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.replica.args "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
args:
|
||||
- -c
|
||||
- /opt/bitnami/scripts/start-scripts/start-replica.sh
|
||||
{{- end }}
|
||||
env:
|
||||
- name: BITNAMI_DEBUG
|
||||
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
|
||||
- name: REDIS_REPLICATION_MODE
|
||||
value: slave
|
||||
- name: REDIS_MASTER_HOST
|
||||
value: {{ template "common.names.fullname" . }}-master-0.{{ template "common.names.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
|
||||
- name: REDIS_MASTER_PORT_NUMBER
|
||||
value: {{ .Values.master.containerPort | quote }}
|
||||
- name: ALLOW_EMPTY_PASSWORD
|
||||
value: {{ ternary "no" "yes" .Values.auth.enabled | quote }}
|
||||
{{- if .Values.auth.enabled }}
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: REDIS_PASSWORD_FILE
|
||||
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||
- name: REDIS_MASTER_PASSWORD_FILE
|
||||
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||
{{- else }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "redis.secretName" . }}
|
||||
key: {{ template "redis.secretPasswordKey" . }}
|
||||
- name: REDIS_MASTER_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "redis.secretName" . }}
|
||||
key: {{ template "redis.secretPasswordKey" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
- name: REDIS_TLS_ENABLED
|
||||
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: REDIS_TLS_PORT
|
||||
value: {{ .Values.replica.containerPort | quote }}
|
||||
- name: REDIS_TLS_AUTH_CLIENTS
|
||||
value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
|
||||
- name: REDIS_TLS_CERT_FILE
|
||||
value: {{ template "redis.tlsCert" . }}
|
||||
- name: REDIS_TLS_KEY_FILE
|
||||
value: {{ template "redis.tlsCertKey" . }}
|
||||
- name: REDIS_TLS_CA_FILE
|
||||
value: {{ template "redis.tlsCACert" . }}
|
||||
{{- if .Values.tls.dhParamsFilename }}
|
||||
- name: REDIS_TLS_DH_PARAMS_FILE
|
||||
value: {{ template "redis.tlsDHParams" . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
- name: REDIS_PORT
|
||||
value: {{ .Values.replica.containerPort | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.extraEnvVars }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.replica.extraEnvVars "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.replica.extraEnvVarsCM .Values.replica.extraEnvVarsSecret }}
|
||||
envFrom:
|
||||
{{- if .Values.replica.extraEnvVarsCM }}
|
||||
- configMapRef:
|
||||
name: {{ .Values.replica.extraEnvVarsCM }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.extraEnvVarsSecret }}
|
||||
- secretRef:
|
||||
name: {{ .Values.replica.extraEnvVarsSecret }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: redis
|
||||
containerPort: {{ .Values.replica.containerPort }}
|
||||
{{- if not .Values.diagnosticMode.enabled }}
|
||||
{{- if .Values.replica.livenessProbe.enabled }}
|
||||
livenessProbe:
|
||||
initialDelaySeconds: {{ .Values.replica.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.replica.livenessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ add1 .Values.replica.livenessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.replica.livenessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.replica.livenessProbe.failureThreshold}}
|
||||
exec:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- /health/ping_liveness_local_and_master.sh {{ .Values.replica.livenessProbe.timeoutSeconds }}
|
||||
{{- else if .Values.replica.customLivenessProbe }}
|
||||
livenessProbe: {{- toYaml .Values.replica.customLivenessProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.readinessProbe.enabled }}
|
||||
readinessProbe:
|
||||
initialDelaySeconds: {{ .Values.replica.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.replica.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ add1 .Values.replica.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.replica.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.replica.readinessProbe.failureThreshold }}
|
||||
exec:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- /health/ping_readiness_local_and_master.sh {{ .Values.replica.readinessProbe.timeoutSeconds }}
|
||||
{{- else if .Values.replica.customReadinessProbe }}
|
||||
readinessProbe: {{- toYaml .Values.replica.customReadinessProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.resources }}
|
||||
resources: {{- toYaml .Values.replica.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: start-scripts
|
||||
mountPath: /opt/bitnami/scripts/start-scripts
|
||||
- name: health
|
||||
mountPath: /health
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: redis-password
|
||||
mountPath: /opt/bitnami/redis/secrets/
|
||||
{{- end }}
|
||||
- name: redis-data
|
||||
mountPath: /data
|
||||
subPath: {{ .Values.replica.persistence.subPath }}
|
||||
- name: config
|
||||
mountPath: /opt/bitnami/redis/mounted-etc
|
||||
- name: redis-tmp-conf
|
||||
mountPath: /opt/bitnami/redis/etc
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: redis-certificates
|
||||
mountPath: /opt/bitnami/redis/certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.replica.extraVolumeMounts }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.enabled }}
|
||||
- name: metrics
|
||||
image: {{ include "redis.metrics.image" . }}
|
||||
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
|
||||
{{- if .Values.metrics.containerSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.metrics.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f '/secrets/redis-password' ]]; then
|
||||
export REDIS_PASSWORD=$(cat /secrets/redis-password)
|
||||
fi
|
||||
redis_exporter{{- range $key, $value := .Values.metrics.extraArgs }} --{{ $key }}={{ $value }}{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
env:
|
||||
- name: REDIS_ALIAS
|
||||
value: {{ template "common.names.fullname" . }}
|
||||
{{- if .Values.auth.enabled }}
|
||||
- name: REDIS_USER
|
||||
value: default
|
||||
{{- if (not .Values.auth.usePasswordFiles) }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "redis.secretName" . }}
|
||||
key: {{ template "redis.secretPasswordKey" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: REDIS_ADDR
|
||||
value: rediss://{{ .Values.metrics.redisTargetHost }}:{{ .Values.replica.containerPort }}
|
||||
{{- if .Values.tls.authClients }}
|
||||
- name: REDIS_EXPORTER_TLS_CLIENT_KEY_FILE
|
||||
value: {{ template "redis.tlsCertKey" . }}
|
||||
- name: REDIS_EXPORTER_TLS_CLIENT_CERT_FILE
|
||||
value: {{ template "redis.tlsCert" . }}
|
||||
{{- end }}
|
||||
- name: REDIS_EXPORTER_TLS_CA_CERT_FILE
|
||||
value: {{ template "redis.tlsCACert" . }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 9121
|
||||
{{- if .Values.metrics.resources }}
|
||||
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: redis-password
|
||||
mountPath: /secrets/
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: redis-certificates
|
||||
mountPath: /opt/bitnami/redis/certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.extraVolumeMounts }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.sidecars }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.replica.sidecars "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- $needsVolumePermissions := and .Values.volumePermissions.enabled .Values.replica.persistence.enabled .Values.replica.podSecurityContext.enabled .Values.replica.containerSecurityContext.enabled }}
|
||||
{{- if or .Values.replica.initContainers $needsVolumePermissions .Values.sysctl.enabled }}
|
||||
initContainers:
|
||||
{{- if .Values.replica.initContainers }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.replica.initContainers "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if $needsVolumePermissions }}
|
||||
- name: volume-permissions
|
||||
image: {{ include "redis.volumePermissions.image" . }}
|
||||
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
|
||||
command:
|
||||
- /bin/bash
|
||||
- -ec
|
||||
- |
|
||||
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||
chown -R `id -u`:`id -G | cut -d " " -f2` {{ .Values.replica.persistence.path }}
|
||||
{{- else }}
|
||||
chown -R {{ .Values.replica.containerSecurityContext.runAsUser }}:{{ .Values.replica.podSecurityContext.fsGroup }} {{ .Values.replica.persistence.path }}
|
||||
{{- end }}
|
||||
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||
securityContext: {{- omit .Values.volumePermissions.containerSecurityContext "runAsUser" | toYaml | nindent 12 }}
|
||||
{{- else }}
|
||||
securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.volumePermissions.resources }}
|
||||
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: redis-data
|
||||
mountPath: {{ .Values.replica.persistence.path }}
|
||||
subPath: {{ .Values.replica.persistence.subPath }}
|
||||
{{- end }}
|
||||
{{- if .Values.sysctl.enabled }}
|
||||
- name: init-sysctl
|
||||
image: {{ include "redis.sysctl.image" . }}
|
||||
imagePullPolicy: {{ default "" .Values.sysctl.image.pullPolicy | quote }}
|
||||
securityContext:
|
||||
privileged: true
|
||||
runAsUser: 0
|
||||
{{- if .Values.sysctl.command }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.sysctl.command "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.sysctl.resources }}
|
||||
resources: {{- toYaml .Values.sysctl.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.sysctl.mountHostSys }}
|
||||
volumeMounts:
|
||||
- name: host-sys
|
||||
mountPath: /host-sys
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: start-scripts
|
||||
configMap:
|
||||
name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
|
||||
defaultMode: 0755
|
||||
- name: health
|
||||
configMap:
|
||||
name: {{ printf "%s-health" (include "common.names.fullname" .) }}
|
||||
defaultMode: 0755
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: redis-password
|
||||
secret:
|
||||
secretName: {{ template "redis.secretName" . }}
|
||||
items:
|
||||
- key: {{ template "redis.secretPasswordKey" . }}
|
||||
path: redis-password
|
||||
{{- end }}
|
||||
- name: config
|
||||
configMap:
|
||||
name: {{ include "redis.configmapName" . }}
|
||||
{{- if .Values.sysctl.mountHostSys }}
|
||||
- name: host-sys
|
||||
hostPath:
|
||||
path: /sys
|
||||
{{- end }}
|
||||
- name: redis-tmp-conf
|
||||
{{- if .Values.replica.persistence.medium }}
|
||||
emptyDir: {
|
||||
medium: {{ .Values.replica.persistence.medium | quote }}
|
||||
}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: redis-certificates
|
||||
secret:
|
||||
secretName: {{ include "redis.tlsSecretName" . }}
|
||||
defaultMode: 256
|
||||
{{- end }}
|
||||
{{- if .Values.replica.extraVolumes }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumes "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.extraVolumes }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumes "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if not .Values.replica.persistence.enabled }}
|
||||
- name: redis-data
|
||||
{{- if .Values.replica.persistence.medium }}
|
||||
emptyDir: {
|
||||
medium: {{ .Values.replica.persistence.medium | quote }}
|
||||
}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: redis-data
|
||||
labels: {{- include "common.labels.matchLabels" . | nindent 10 }}
|
||||
app.kubernetes.io/component: replica
|
||||
{{- if .Values.replica.persistence.annotations }}
|
||||
annotations: {{- toYaml .Values.replica.persistence.annotations | nindent 10 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
accessModes:
|
||||
{{- range .Values.replica.persistence.accessModes }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.replica.persistence.size | quote }}
|
||||
{{- if .Values.replica.persistence.selector }}
|
||||
selector: {{- include "common.tplvalues.render" (dict "value" .Values.replica.persistence.selector "context" $) | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.persistence.dataSource }}
|
||||
dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.replica.persistence.dataSource "context" $) | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- include "common.storage.class" (dict "persistence" .Values.replica.persistence "global" .Values.global) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
28
helm/redis/templates/role.yaml
Normal file
28
helm/redis/templates/role.yaml
Normal file
@ -0,0 +1,28 @@
|
||||
{{- if .Values.rbac.create }}
|
||||
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
|
||||
kind: Role
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- $pspAvailable := (semverCompare "<1.25-0" (include "common.capabilities.kubeVersion" .)) -}}
|
||||
{{- if and $pspAvailable .Values.podSecurityPolicy.enabled }}
|
||||
- apiGroups:
|
||||
- '{{ template "podSecurityPolicy.apiGroup" . }}'
|
||||
resources:
|
||||
- 'podsecuritypolicies'
|
||||
verbs:
|
||||
- 'use'
|
||||
resourceNames: [{{ template "common.names.fullname" . }}]
|
||||
{{- end }}
|
||||
{{- if .Values.rbac.rules }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.rbac.rules "context" $ ) | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
21
helm/redis/templates/rolebinding.yaml
Normal file
21
helm/redis/templates/rolebinding.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
{{- if .Values.rbac.create }}
|
||||
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ template "common.names.fullname" . }}
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ template "redis.serviceAccountName" . }}
|
||||
{{- end }}
|
607
helm/redis/templates/scripts-configmap.yaml
Normal file
607
helm/redis/templates/scripts-configmap.yaml
Normal file
@ -0,0 +1,607 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled }}
|
||||
start-node.sh: |
|
||||
#!/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 {{ .Values.sentinel.containerPort }}
|
||||
;;
|
||||
"REDIS")
|
||||
echo {{ .Values.master.containerPort }}
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo $port
|
||||
fi
|
||||
}
|
||||
|
||||
get_full_hostname() {
|
||||
hostname="$1"
|
||||
|
||||
{{- if eq .Values.sentinel.service.type "NodePort" }}
|
||||
echo "${hostname}.{{- .Release.Namespace }}"
|
||||
{{- else }}
|
||||
echo "${hostname}.${HEADLESS_SERVICE}"
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
REDISPORT=$(get_port "$HOSTNAME" "REDIS")
|
||||
|
||||
myip=$(hostname -i)
|
||||
|
||||
# If there are more than one IP, use the first IPv4 address
|
||||
if [[ "$myip" = *" "* ]]; then
|
||||
myip=$(echo $myip | awk '{if ( match($0,/([0-9]+\.)([0-9]+\.)([0-9]+\.)[0-9]+/) ) { print substr($0,RSTART,RLENGTH); } }')
|
||||
fi
|
||||
|
||||
HEADLESS_SERVICE="{{ template "common.names.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
|
||||
REDIS_SERVICE="{{ template "common.names.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
|
||||
SENTINEL_SERVICE_PORT=$(get_port "{{ include "common.names.fullname" . }}" "TCP_SENTINEL")
|
||||
|
||||
not_exists_dns_entry() {
|
||||
if [[ -z "$(getent ahosts "$HEADLESS_SERVICE" | grep "^${myip}" )" ]]; then
|
||||
warn "$HEADLESS_SERVICE does not contain the IP of this pod: ${myip}"
|
||||
return 1
|
||||
fi
|
||||
debug "$HEADLESS_SERVICE has my IP: ${myip}"
|
||||
return 0
|
||||
}
|
||||
|
||||
validate_quorum() {
|
||||
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
|
||||
quorum_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}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 {{ .Values.sentinel.masterSet }}"
|
||||
else
|
||||
quorum_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel master {{ .Values.sentinel.masterSet }}"
|
||||
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="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}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 {{ .Values.sentinel.masterSet }}"
|
||||
else
|
||||
failover_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel failover {{ .Values.sentinel.masterSet }}"
|
||||
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="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}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 {{ .Values.sentinel.masterSet }}"
|
||||
else
|
||||
sentinel_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name {{ .Values.sentinel.masterSet }}"
|
||||
fi
|
||||
|
||||
info "about to run the command: $sentinel_info_command"
|
||||
eval $sentinel_info_command
|
||||
}
|
||||
|
||||
{{- if and .Values.replica.containerSecurityContext.runAsUser (eq (.Values.replica.containerSecurityContext.runAsUser | int) 0) }}
|
||||
useradd redis
|
||||
chown -R redis {{ .Values.replica.persistence.path }}
|
||||
{{- end }}
|
||||
|
||||
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||
[[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
|
||||
|
||||
# Waits for DNS to add this ip to the service DNS entry
|
||||
retry_while not_exists_dns_entry
|
||||
|
||||
if [[ -z "$(getent ahosts "$HEADLESS_SERVICE" | grep -v "^${myip}")" ]]; then
|
||||
# Only node available on the network, master by default
|
||||
export REDIS_REPLICATION_MODE="master"
|
||||
else
|
||||
export REDIS_REPLICATION_MODE="slave"
|
||||
|
||||
{{- if and .Values.sentinel.automateClusterRecovery (le (int .Values.sentinel.downAfterMilliseconds) 2000) }}
|
||||
retry_count=1
|
||||
while validate_quorum
|
||||
do
|
||||
info "sleeping, waiting for Redis master to come up"
|
||||
sleep 1s
|
||||
if ! ((retry_count % 11)); then
|
||||
info "Trying to manually failover"
|
||||
failover_result=$(trigger_manual_failover)
|
||||
|
||||
debug "Failover result: $failover_result"
|
||||
fi
|
||||
|
||||
((retry_count+=1))
|
||||
done
|
||||
info "Redis master is up now"
|
||||
{{- end }}
|
||||
|
||||
# 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 [[ "$REDIS_REPLICATION_MODE" = "master" ]]; then
|
||||
debug "Starting as master node"
|
||||
if [[ ! -f /opt/bitnami/redis/etc/master.conf ]]; then
|
||||
cp /opt/bitnami/redis/mounted-etc/master.conf /opt/bitnami/redis/etc/master.conf
|
||||
fi
|
||||
else
|
||||
debug "Starting as replica node"
|
||||
if [[ ! -f /opt/bitnami/redis/etc/replica.conf ]];then
|
||||
cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -f /opt/bitnami/redis/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
|
||||
|
||||
{{- if .Values.tls.enabled }}
|
||||
ARGS=("--port" "0")
|
||||
ARGS+=("--tls-port" "${REDIS_TLS_PORT}")
|
||||
ARGS+=("--tls-cert-file" "${REDIS_TLS_CERT_FILE}")
|
||||
ARGS+=("--tls-key-file" "${REDIS_TLS_KEY_FILE}")
|
||||
ARGS+=("--tls-ca-cert-file" "${REDIS_TLS_CA_FILE}")
|
||||
ARGS+=("--tls-auth-clients" "${REDIS_TLS_AUTH_CLIENTS}")
|
||||
ARGS+=("--tls-replication" "yes")
|
||||
{{- if .Values.tls.dhParamsFilename }}
|
||||
ARGS+=("--tls-dh-params-file" "${REDIS_TLS_DH_PARAMS_FILE}")
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
ARGS=("--port" "${REDIS_PORT}")
|
||||
{{- end }}
|
||||
|
||||
if [[ "$REDIS_REPLICATION_MODE" = "slave" ]]; then
|
||||
ARGS+=("--slaveof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
|
||||
fi
|
||||
|
||||
{{- if .Values.auth.enabled }}
|
||||
ARGS+=("--requirepass" "${REDIS_PASSWORD}")
|
||||
ARGS+=("--masterauth" "${REDIS_MASTER_PASSWORD}")
|
||||
{{- else }}
|
||||
ARGS+=("--protected-mode" "no")
|
||||
{{- end }}
|
||||
if [[ "$REDIS_REPLICATION_MODE" = "master" ]]; then
|
||||
ARGS+=("--include" "/opt/bitnami/redis/etc/master.conf")
|
||||
else
|
||||
ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
|
||||
fi
|
||||
ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
|
||||
{{- if .Values.replica.extraFlags }}
|
||||
{{- range .Values.replica.extraFlags }}
|
||||
ARGS+=({{ . | quote }})
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if .Values.replica.preExecCmds }}
|
||||
{{- .Values.replica.preExecCmds | nindent 4}}
|
||||
{{- end }}
|
||||
|
||||
{{- if .Values.replica.command }}
|
||||
exec {{ .Values.replica.command }} "${ARGS[@]}"
|
||||
{{- else }}
|
||||
exec redis-server "${ARGS[@]}"
|
||||
{{- end }}
|
||||
|
||||
start-sentinel.sh: |
|
||||
#!/bin/bash
|
||||
|
||||
. /opt/bitnami/scripts/libos.sh
|
||||
. /opt/bitnami/scripts/libvalidations.sh
|
||||
. /opt/bitnami/scripts/libfile.sh
|
||||
|
||||
HEADLESS_SERVICE="{{ template "common.names.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
|
||||
REDIS_SERVICE="{{ template "common.names.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
|
||||
|
||||
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 {{ .Values.sentinel.containerPort }}
|
||||
;;
|
||||
"REDIS")
|
||||
echo {{ .Values.master.containerPort }}
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo $port
|
||||
fi
|
||||
}
|
||||
|
||||
get_full_hostname() {
|
||||
hostname="$1"
|
||||
|
||||
{{- if eq .Values.sentinel.service.type "NodePort" }}
|
||||
echo "${hostname}.{{- .Release.Namespace }}"
|
||||
{{- else }}
|
||||
echo "${hostname}.${HEADLESS_SERVICE}"
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
SERVPORT=$(get_port "$HOSTNAME" "SENTINEL")
|
||||
REDISPORT=$(get_port "$HOSTNAME" "REDIS")
|
||||
SENTINEL_SERVICE_PORT=$(get_port "{{ include "common.names.fullname" . }}" "TCP_SENTINEL")
|
||||
|
||||
myip=$(hostname -i)
|
||||
|
||||
# If there are more than one IP, use the first IPv4 address
|
||||
if [[ "$myip" = *" "* ]]; then
|
||||
myip=$(echo $myip | awk '{if ( match($0,/([0-9]+\.)([0-9]+\.)([0-9]+\.)[0-9]+/) ) { print substr($0,RSTART,RLENGTH); } }')
|
||||
fi
|
||||
|
||||
|
||||
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}'
|
||||
}
|
||||
not_exists_dns_entry() {
|
||||
if [[ -z "$(getent ahosts "$HEADLESS_SERVICE" | grep "^${myip}" )" ]]; then
|
||||
warn "$HEADLESS_SERVICE does not contain the IP of this pod: ${myip}"
|
||||
return 1
|
||||
fi
|
||||
debug "$HEADLESS_SERVICE has my IP: ${myip}"
|
||||
return 0
|
||||
}
|
||||
get_sentinel_master_info() {
|
||||
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
|
||||
sentinel_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}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 {{ .Values.sentinel.masterSet }}"
|
||||
else
|
||||
sentinel_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name {{ .Values.sentinel.masterSet }}"
|
||||
fi
|
||||
|
||||
info "about to run the command: $sentinel_info_command"
|
||||
eval $sentinel_info_command
|
||||
}
|
||||
|
||||
# Waits for DNS to add this ip to the service DNS entry
|
||||
retry_while not_exists_dns_entry
|
||||
|
||||
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||
|
||||
cp /opt/bitnami/redis-sentinel/mounted-etc/sentinel.conf /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||
{{- if .Values.auth.enabled }}
|
||||
printf "\nsentinel auth-pass %s %s" "{{ .Values.sentinel.masterSet }}" "$REDIS_PASSWORD" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||
{{- if and .Values.auth.enabled .Values.auth.sentinel }}
|
||||
printf "\nrequirepass %s" "$REDIS_PASSWORD" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
printf "\nsentinel myid %s" "$(host_id "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||
|
||||
if ! $(get_sentinel_master_info); 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="slave"
|
||||
|
||||
# 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
|
||||
|
||||
sentinel_conf_set "sentinel monitor" "{{ .Values.sentinel.masterSet }} "$REDIS_MASTER_HOST" "$REDIS_MASTER_PORT_NUMBER" {{ .Values.sentinel.quorum }}"
|
||||
|
||||
add_known_sentinel() {
|
||||
hostname="$1"
|
||||
ip="$2"
|
||||
|
||||
if [[ -n "$hostname" && -n "$ip" && "$hostname" != "$HOSTNAME" ]]; then
|
||||
sentinel_conf_add "sentinel known-sentinel {{ .Values.sentinel.masterSet }} $(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 {{ .Values.sentinel.masterSet }} $(get_full_hostname "$hostname") $(get_port "$hostname" "REDIS")"
|
||||
fi
|
||||
}
|
||||
|
||||
# Add available hosts on the network as known replicas & sentinels
|
||||
for node in $(seq 0 $(({{ .Values.replica.replicaCount }}-1))); do
|
||||
hostname="{{ template "common.names.fullname" . }}-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
|
||||
|
||||
{{- if .Values.tls.enabled }}
|
||||
ARGS=("--port" "0")
|
||||
ARGS+=("--tls-port" "${REDIS_SENTINEL_TLS_PORT_NUMBER}")
|
||||
ARGS+=("--tls-cert-file" "${REDIS_SENTINEL_TLS_CERT_FILE}")
|
||||
ARGS+=("--tls-key-file" "${REDIS_SENTINEL_TLS_KEY_FILE}")
|
||||
ARGS+=("--tls-ca-cert-file" "${REDIS_SENTINEL_TLS_CA_FILE}")
|
||||
ARGS+=("--tls-replication" "yes")
|
||||
ARGS+=("--tls-auth-clients" "${REDIS_SENTINEL_TLS_AUTH_CLIENTS}")
|
||||
{{- if .Values.tls.dhParamsFilename }}
|
||||
ARGS+=("--tls-dh-params-file" "${REDIS_SENTINEL_TLS_DH_PARAMS_FILE}")
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.sentinel.preExecCmds }}
|
||||
{{ .Values.sentinel.preExecCmds | nindent 4 }}
|
||||
{{- end }}
|
||||
exec redis-server /opt/bitnami/redis-sentinel/etc/sentinel.conf --sentinel {{- if .Values.tls.enabled }} "${ARGS[@]}" {{- end }}
|
||||
prestop-sentinel.sh: |
|
||||
#!/bin/bash
|
||||
|
||||
. /opt/bitnami/scripts/libvalidations.sh
|
||||
. /opt/bitnami/scripts/libos.sh
|
||||
|
||||
HEADLESS_SERVICE="{{ template "common.names.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
|
||||
SENTINEL_SERVICE_ENV_NAME={{ printf "%s%s" (upper (include "common.names.fullname" .)| replace "-" "_") "_SERVICE_PORT_TCP_SENTINEL" }}
|
||||
SENTINEL_SERVICE_PORT=${!SENTINEL_SERVICE_ENV_NAME}
|
||||
|
||||
get_full_hostname() {
|
||||
hostname="$1"
|
||||
|
||||
{{- if eq .Values.sentinel.service.type "NodePort" }}
|
||||
echo "${hostname}.{{- .Release.Namespace }}"
|
||||
{{- else }}
|
||||
echo "${hostname}.${HEADLESS_SERVICE}"
|
||||
{{- 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 "$@"
|
||||
else
|
||||
redis-cli -h "$REDIS_SERVICE" -p "$SENTINEL_SERVICE_PORT" sentinel "$@"
|
||||
fi
|
||||
}
|
||||
failover_finished() {
|
||||
REDIS_SENTINEL_INFO=($(run_sentinel_command get-master-addr-by-name "{{ .Values.sentinel.masterSet }}"))
|
||||
REDIS_MASTER_HOST="${REDIS_SENTINEL_INFO[0]}"
|
||||
[[ "$REDIS_MASTER_HOST" != "$(get_full_hostname $HOSTNAME)" ]]
|
||||
}
|
||||
|
||||
REDIS_SERVICE="{{ include "common.names.fullname" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
|
||||
|
||||
# redis-cli automatically consumes credentials from the REDISCLI_AUTH variable
|
||||
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
|
||||
[[ -f "$REDIS_PASSWORD_FILE" ]] && export REDISCLI_AUTH="$(< "${REDIS_PASSWORD_FILE}")"
|
||||
|
||||
if ! failover_finished; then
|
||||
echo "I am the master pod and you are stopping me. Starting sentinel failover"
|
||||
# if I am the master, issue a command to failover once and then wait for the failover to finish
|
||||
run_sentinel_command failover "{{ .Values.sentinel.masterSet }}"
|
||||
if retry_while "failover_finished" "{{ sub .Values.sentinel.terminationGracePeriodSeconds 10 }}" 1; then
|
||||
echo "Master has been successfuly failed over to a different pod."
|
||||
exit 0
|
||||
else
|
||||
echo "Master failover failed"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
prestop-redis.sh: |
|
||||
#!/bin/bash
|
||||
|
||||
. /opt/bitnami/scripts/libvalidations.sh
|
||||
. /opt/bitnami/scripts/libos.sh
|
||||
|
||||
run_redis_command() {
|
||||
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
|
||||
redis-cli -h 127.0.0.1 -p "$REDIS_TLS_PORT" --tls --cert "$REDIS_TLS_CERT_FILE" --key "$REDIS_TLS_KEY_FILE" --cacert "$REDIS_TLS_CA_FILE" "$@"
|
||||
else
|
||||
redis-cli -h 127.0.0.1 -p ${REDIS_PORT} "$@"
|
||||
fi
|
||||
}
|
||||
failover_finished() {
|
||||
REDIS_ROLE=$(run_redis_command role | head -1)
|
||||
[[ "$REDIS_ROLE" != "master" ]]
|
||||
}
|
||||
|
||||
# redis-cli automatically consumes credentials from the REDISCLI_AUTH variable
|
||||
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
|
||||
[[ -f "$REDIS_PASSWORD_FILE" ]] && export REDISCLI_AUTH="$(< "${REDIS_PASSWORD_FILE}")"
|
||||
|
||||
if ! failover_finished; then
|
||||
echo "Waiting for sentinel to run failover for up to {{ sub .Values.sentinel.terminationGracePeriodSeconds 10 }}s"
|
||||
retry_while "failover_finished" "{{ sub .Values.sentinel.terminationGracePeriodSeconds 10 }}" 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
{{- else }}
|
||||
start-master.sh: |
|
||||
#!/bin/bash
|
||||
|
||||
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||
{{- if and .Values.master.containerSecurityContext.runAsUser (eq (.Values.master.containerSecurityContext.runAsUser | int) 0) }}
|
||||
useradd redis
|
||||
chown -R redis {{ .Values.master.persistence.path }}
|
||||
{{- end }}
|
||||
if [[ ! -f /opt/bitnami/redis/etc/master.conf ]];then
|
||||
cp /opt/bitnami/redis/mounted-etc/master.conf /opt/bitnami/redis/etc/master.conf
|
||||
fi
|
||||
if [[ ! -f /opt/bitnami/redis/etc/redis.conf ]];then
|
||||
cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
|
||||
fi
|
||||
{{- if .Values.tls.enabled }}
|
||||
ARGS=("--port" "0")
|
||||
ARGS+=("--tls-port" "${REDIS_TLS_PORT}")
|
||||
ARGS+=("--tls-cert-file" "${REDIS_TLS_CERT_FILE}")
|
||||
ARGS+=("--tls-key-file" "${REDIS_TLS_KEY_FILE}")
|
||||
ARGS+=("--tls-ca-cert-file" "${REDIS_TLS_CA_FILE}")
|
||||
ARGS+=("--tls-auth-clients" "${REDIS_TLS_AUTH_CLIENTS}")
|
||||
{{- if .Values.tls.dhParamsFilename }}
|
||||
ARGS+=("--tls-dh-params-file" "${REDIS_TLS_DH_PARAMS_FILE}")
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
ARGS=("--port" "${REDIS_PORT}")
|
||||
{{- end }}
|
||||
{{- if .Values.auth.enabled }}
|
||||
ARGS+=("--requirepass" "${REDIS_PASSWORD}")
|
||||
ARGS+=("--masterauth" "${REDIS_PASSWORD}")
|
||||
{{- else }}
|
||||
ARGS+=("--protected-mode" "no")
|
||||
{{- end }}
|
||||
ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
|
||||
ARGS+=("--include" "/opt/bitnami/redis/etc/master.conf")
|
||||
{{- if .Values.master.extraFlags }}
|
||||
{{- range .Values.master.extraFlags }}
|
||||
ARGS+=({{ . | quote }})
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.master.preExecCmds }}
|
||||
{{ .Values.master.preExecCmds | nindent 4}}
|
||||
{{- end }}
|
||||
{{- if .Values.master.command }}
|
||||
exec {{ .Values.master.command }} "${ARGS[@]}"
|
||||
{{- else }}
|
||||
exec redis-server "${ARGS[@]}"
|
||||
{{- end }}
|
||||
{{- if eq .Values.architecture "replication" }}
|
||||
start-replica.sh: |
|
||||
#!/bin/bash
|
||||
|
||||
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 {{ .Values.sentinel.containerPort }}
|
||||
;;
|
||||
"REDIS")
|
||||
echo {{ .Values.master.containerPort }}
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo $port
|
||||
fi
|
||||
}
|
||||
|
||||
get_full_hostname() {
|
||||
hostname="$1"
|
||||
|
||||
{{- if eq .Values.sentinel.service.type "NodePort" }}
|
||||
echo "${hostname}.{{- .Release.Namespace }}"
|
||||
{{- else }}
|
||||
echo "${hostname}.${HEADLESS_SERVICE}"
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
REDISPORT=$(get_port "$HOSTNAME" "REDIS")
|
||||
|
||||
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||
[[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
|
||||
{{- if and .Values.replica.containerSecurityContext.runAsUser (eq (.Values.replica.containerSecurityContext.runAsUser | int) 0) }}
|
||||
useradd redis
|
||||
chown -R redis {{ .Values.replica.persistence.path }}
|
||||
{{- end }}
|
||||
if [[ ! -f /opt/bitnami/redis/etc/replica.conf ]];then
|
||||
cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
|
||||
fi
|
||||
if [[ ! -f /opt/bitnami/redis/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
|
||||
|
||||
{{- if .Values.tls.enabled }}
|
||||
ARGS=("--port" "0")
|
||||
ARGS+=("--tls-port" "${REDIS_TLS_PORT}")
|
||||
ARGS+=("--tls-cert-file" "${REDIS_TLS_CERT_FILE}")
|
||||
ARGS+=("--tls-key-file" "${REDIS_TLS_KEY_FILE}")
|
||||
ARGS+=("--tls-ca-cert-file" "${REDIS_TLS_CA_FILE}")
|
||||
ARGS+=("--tls-auth-clients" "${REDIS_TLS_AUTH_CLIENTS}")
|
||||
ARGS+=("--tls-replication" "yes")
|
||||
{{- if .Values.tls.dhParamsFilename }}
|
||||
ARGS+=("--tls-dh-params-file" "${REDIS_TLS_DH_PARAMS_FILE}")
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
ARGS=("--port" "${REDIS_PORT}")
|
||||
{{- end }}
|
||||
ARGS+=("--slaveof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
|
||||
{{- if .Values.auth.enabled }}
|
||||
ARGS+=("--requirepass" "${REDIS_PASSWORD}")
|
||||
ARGS+=("--masterauth" "${REDIS_MASTER_PASSWORD}")
|
||||
{{- else }}
|
||||
ARGS+=("--protected-mode" "no")
|
||||
{{- end }}
|
||||
ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
|
||||
ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
|
||||
{{- if .Values.replica.extraFlags }}
|
||||
{{- range .Values.replica.extraFlags }}
|
||||
ARGS+=({{ . | quote }})
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.preExecCmds }}
|
||||
{{ .Values.replica.preExecCmds | nindent 4}}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.command }}
|
||||
exec {{ .Values.replica.command }} "${ARGS[@]}"
|
||||
{{- else }}
|
||||
exec redis-server "${ARGS[@]}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
17
helm/redis/templates/secret.yaml
Normal file
17
helm/redis/templates/secret.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
{{- if and .Values.auth.enabled (not .Values.auth.existingSecret) -}}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
type: Opaque
|
||||
data:
|
||||
redis-password: {{ include "redis.password" . | b64enc | quote }}
|
||||
{{- end -}}
|
35
helm/redis/templates/sentinel/hpa.yaml
Normal file
35
helm/redis/templates/sentinel/hpa.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
{{- if and .Values.replica.autoscaling.enabled .Values.sentinel.enabled }}
|
||||
apiVersion: autoscaling/v2beta1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ printf "%s-node" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
app.kubernetes.io/component: replica
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
|
||||
kind: StatefulSet
|
||||
name: {{ printf "%s-node" (include "common.names.fullname" .) }}
|
||||
minReplicas: {{ .Values.replica.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.replica.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
{{- if .Values.replica.autoscaling.targetCPU }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
targetAverageUtilization: {{ .Values.replica.autoscaling.targetCPU }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.autoscaling.targetMemory }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
targetAverageUtilization: {{ .Values.replica.autoscaling.targetMemory }}
|
||||
{{- end }}
|
||||
{{- end }}
|
71
helm/redis/templates/sentinel/node-services.yaml
Normal file
71
helm/redis/templates/sentinel/node-services.yaml
Normal file
@ -0,0 +1,71 @@
|
||||
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled (eq .Values.sentinel.service.type "NodePort") (or .Release.IsUpgrade .Values.sentinel.service.nodePorts.redis )}}
|
||||
|
||||
{{- range $i := until (int .Values.replica.replicaCount) }}
|
||||
|
||||
{{ $portsmap := (lookup "v1" "ConfigMap" $.Release.Namespace (printf "%s-%s" ( include "common.names.fullname" $ ) "ports-configmap")).data}}
|
||||
|
||||
{{ $sentinelport := 0}}
|
||||
{{ $redisport := 0}}
|
||||
{{- if $portsmap }}
|
||||
{{ $sentinelport = index $portsmap (printf "%s-node-%s-%s" (include "common.names.fullname" $) (toString $i) "sentinel")}}
|
||||
{{ $redisport = index $portsmap (printf "%s-node-%s-%s" (include "common.names.fullname" $) (toString $i) "redis")}}
|
||||
{{- else }}
|
||||
{{- end }}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" $ }}-node-{{$i}}
|
||||
namespace: {{ $.Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" $ | nindent 4 }}
|
||||
app.kubernetes.io/component: node
|
||||
{{- if $.Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" $.Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if or $.Values.sentinel.service.annotations $.Values.commonAnnotations }}
|
||||
annotations:
|
||||
{{- if $.Values.sentinel.service.annotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" $.Values.sentinel.service.annotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if $.Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- name: sentinel
|
||||
{{- if $.Values.sentinel.service.nodePorts.sentinel }}
|
||||
nodePort: {{ (add $.Values.sentinel.service.nodePorts.sentinel $i 1) }}
|
||||
port: {{ (add $.Values.sentinel.service.nodePorts.sentinel $i 1) }}
|
||||
{{- else}}
|
||||
nodePort: {{ $sentinelport }}
|
||||
port: {{ $sentinelport }}
|
||||
{{- end}}
|
||||
protocol: TCP
|
||||
targetPort: {{ $.Values.sentinel.containerPort }}
|
||||
- name: redis
|
||||
{{- if $.Values.sentinel.service.nodePorts.redis }}
|
||||
nodePort: {{ (add $.Values.sentinel.service.nodePorts.redis $i 1) }}
|
||||
port: {{ (add $.Values.sentinel.service.nodePorts.redis $i 1) }}
|
||||
{{- else}}
|
||||
nodePort: {{ $redisport }}
|
||||
port: {{ $redisport }}
|
||||
{{- end}}
|
||||
protocol: TCP
|
||||
targetPort: {{ $.Values.replica.containerPort }}
|
||||
- name: sentinel-internal
|
||||
nodePort: null
|
||||
port: {{ $.Values.sentinel.containerPort }}
|
||||
protocol: TCP
|
||||
targetPort: {{ $.Values.sentinel.containerPort }}
|
||||
- name: redis-internal
|
||||
nodePort: null
|
||||
port: {{ $.Values.replica.containerPort }}
|
||||
protocol: TCP
|
||||
targetPort: {{ $.Values.replica.containerPort }}
|
||||
selector:
|
||||
statefulset.kubernetes.io/pod-name: {{ template "common.names.fullname" $ }}-node-{{$i}}
|
||||
{{- end }}
|
||||
{{- end }}
|
100
helm/redis/templates/sentinel/ports-configmap.yaml
Normal file
100
helm/redis/templates/sentinel/ports-configmap.yaml
Normal file
@ -0,0 +1,100 @@
|
||||
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled (eq .Values.sentinel.service.type "NodePort") (not .Values.sentinel.service.nodePorts.redis ) }}
|
||||
{{- /* create a list to keep track of ports we choose to use */}}
|
||||
{{ $chosenports := (list ) }}
|
||||
|
||||
{{- /* Get list of all used nodeports */}}
|
||||
{{ $usedports := (list ) }}
|
||||
{{- range $index, $service := (lookup "v1" "Service" "" "").items }}
|
||||
{{- range.spec.ports }}
|
||||
{{- if .nodePort}}
|
||||
{{- $usedports = (append $usedports .nodePort) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
comments that start with # are rendered in the output when you debug, so you can less and search for them
|
||||
Vars in the comment will be rendered out, so you can check their value this way.
|
||||
https://helm.sh/docs/chart_best_practices/templates/#comments-yaml-comments-vs-template-comments
|
||||
|
||||
remove the template comments and leave the yaml comments to help debug
|
||||
*/}}
|
||||
|
||||
{{- /* Sort the list */}}
|
||||
{{$usedports = $usedports | sortAlpha}}
|
||||
#usedports {{$usedports}}
|
||||
|
||||
{{- /* How many nodeports per service do we want to create, except for the main service which is always two */}}
|
||||
{{$numberofPortsPerNodeService := 2}}
|
||||
|
||||
{{- /* for every nodeport we want, loop though the used ports to get an unused port */}}
|
||||
{{- range $j := until (int (add (mul (int .Values.replica.replicaCount) $numberofPortsPerNodeService) 2)) }}
|
||||
{{- /* #j={{$j}} */}}
|
||||
{{- $nodeport := (add $j 30000)}}
|
||||
{{- $nodeportfound := false}}
|
||||
{{- range $i := $usedports }}
|
||||
{{- /* #i={{$i}}
|
||||
#nodeport={{$nodeport}}
|
||||
#usedports={{$usedports}} */}}
|
||||
{{- if and (has (toString $nodeport) $usedports) (eq $nodeportfound false) }}
|
||||
{{- /* nodeport conflicts with in use */}}
|
||||
{{- $nodeport = (add $nodeport 1) }}
|
||||
{{- else if and ( has $nodeport $chosenports) (eq $nodeportfound false)}}
|
||||
{{- /* nodeport already chosen, try another */}}
|
||||
{{- $nodeport = (add $nodeport 1) }}
|
||||
{{- else if (eq $nodeportfound false)}}
|
||||
{{- /* nodeport free to use: not already claimed and not in use */}}
|
||||
{{- /* select nodeport, and place into usedports */}}
|
||||
{{- $chosenports = (append $chosenports $nodeport) }}
|
||||
{{- $nodeportfound = true}}
|
||||
{{- else }}
|
||||
{{- /* nodeport has already been chosen and locked in, just work through the rest of the list to get to the next nodeport selection */}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if (eq $nodeportfound false)}}
|
||||
{{- $chosenports = (append $chosenports $nodeport) }}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
|
||||
{{- /* print the usedports and chosenports for debugging */}}
|
||||
#usedports {{$usedports}}
|
||||
#chosenports {{$chosenports}}}}
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}-ports-configmap
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations:
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
data:
|
||||
{{ $portsmap := (lookup "v1" "ConfigMap" $.Release.Namespace (printf "%s-%s" ( include "common.names.fullname" . ) "ports-configmap")).data}}
|
||||
{{- if $portsmap }}
|
||||
{{- /* configmap already exists, do not install again */ -}}
|
||||
{{- range $name, $value := $portsmap}}
|
||||
"{{$name}}": "{{$value}}"
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- /* configmap being set for first time */ -}}
|
||||
{{- range $index, $port := $chosenports }}
|
||||
{{- $nodenumber := (floor (div $index 2))}}
|
||||
{{- if (eq $index 0)}}
|
||||
"{{ template "common.names.fullname" $ }}-sentinel": "{{ $port }}"
|
||||
{{- else if (eq $index 1)}}
|
||||
"{{ template "common.names.fullname" $ }}-redis": "{{ $port }}"
|
||||
{{- else if (eq (mod $index 2) 0)}}
|
||||
"{{ template "common.names.fullname" $ }}-node-{{(sub $nodenumber 1)}}-sentinel": "{{ $port }}"
|
||||
{{- else if (eq (mod $index 2) 1)}}
|
||||
"{{ template "common.names.fullname" $ }}-node-{{(sub $nodenumber 1)}}-redis": "{{ $port }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
96
helm/redis/templates/sentinel/service.yaml
Normal file
96
helm/redis/templates/sentinel/service.yaml
Normal file
@ -0,0 +1,96 @@
|
||||
{{- if or .Release.IsUpgrade (ne .Values.sentinel.service.type "NodePort") .Values.sentinel.service.nodePorts.redis -}}
|
||||
|
||||
---
|
||||
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled }}
|
||||
{{ $portsmap := (lookup "v1" "ConfigMap" $.Release.Namespace (printf "%s-%s" ( include "common.names.fullname" . ) "ports-configmap")).data}}
|
||||
|
||||
{{ $sentinelport := 0}}
|
||||
{{ $redisport := 0}}
|
||||
{{- if $portsmap }}
|
||||
{{ $sentinelport = index $portsmap (printf "%s-%s" (include "common.names.fullname" $) "sentinel")}}
|
||||
{{ $redisport = index $portsmap (printf "%s-%s" (include "common.names.fullname" $) "redis")}}
|
||||
{{- else }}
|
||||
{{- end}}
|
||||
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
app.kubernetes.io/component: node
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.sentinel.service.annotations .Values.commonAnnotations }}
|
||||
annotations:
|
||||
{{- if .Values.sentinel.service.annotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.service.annotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
spec:
|
||||
type: {{ .Values.sentinel.service.type }}
|
||||
{{- if eq .Values.sentinel.service.type "LoadBalancer" }}
|
||||
externalTrafficPolicy: {{ .Values.sentinel.service.externalTrafficPolicy }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.sentinel.service.type "LoadBalancer") .Values.sentinel.service.loadBalancerIP }}
|
||||
loadBalancerIP: {{ .Values.sentinel.service.loadBalancerIP }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.sentinel.service.type "LoadBalancer") .Values.sentinel.service.loadBalancerSourceRanges }}
|
||||
loadBalancerSourceRanges: {{- toYaml .Values.sentinel.service.loadBalancerSourceRanges | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if and (eq .Values.sentinel.service.type "ClusterIP") .Values.sentinel.service.clusterIP }}
|
||||
clusterIP: {{ .Values.sentinel.service.clusterIP }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: tcp-redis
|
||||
{{- if and (or (eq .Values.sentinel.service.type "NodePort") (eq .Values.sentinel.service.type "LoadBalancer")) .Values.sentinel.service.nodePorts.redis }}
|
||||
port: {{ .Values.sentinel.service.nodePorts.redis }}
|
||||
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||
port: {{ $redisport }}
|
||||
{{- else}}
|
||||
port: {{ .Values.sentinel.service.port }}
|
||||
{{- end }}
|
||||
targetPort: {{ .Values.replica.containerPort }}
|
||||
{{- if and (or (eq .Values.sentinel.service.type "NodePort") (eq .Values.sentinel.service.type "LoadBalancer")) .Values.sentinel.service.nodePorts.redis }}
|
||||
nodePort: {{ .Values.sentinel.service.nodePorts.redis }}
|
||||
{{- else if eq .Values.sentinel.service.type "ClusterIP" }}
|
||||
nodePort: null
|
||||
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||
nodePort: {{ $redisport }}
|
||||
{{- end }}
|
||||
- name: tcp-sentinel
|
||||
{{- if and (or (eq .Values.sentinel.service.type "NodePort") (eq .Values.sentinel.service.type "LoadBalancer")) .Values.sentinel.service.nodePorts.sentinel }}
|
||||
port: {{ .Values.sentinel.service.nodePorts.sentinel }}
|
||||
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||
port: {{ $sentinelport }}
|
||||
{{- else}}
|
||||
port: {{ .Values.sentinel.service.sentinelPort }}
|
||||
{{- end }}
|
||||
targetPort: {{ .Values.sentinel.containerPort }}
|
||||
{{- if and (or (eq .Values.sentinel.service.type "NodePort") (eq .Values.sentinel.service.type "LoadBalancer")) .Values.sentinel.service.nodePorts.sentinel }}
|
||||
nodePort: {{ .Values.sentinel.service.nodePorts.sentinel }}
|
||||
{{- else if eq .Values.sentinel.service.type "ClusterIP" }}
|
||||
nodePort: null
|
||||
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||
nodePort: {{ $sentinelport }}
|
||||
{{- end }}
|
||||
{{- if eq .Values.sentinel.service.type "NodePort" }}
|
||||
- name: sentinel-internal
|
||||
nodePort: null
|
||||
port: {{ .Values.sentinel.containerPort }}
|
||||
protocol: TCP
|
||||
targetPort: {{ .Values.sentinel.containerPort }}
|
||||
- name: redis-internal
|
||||
nodePort: null
|
||||
port: {{ .Values.replica.containerPort }}
|
||||
protocol: TCP
|
||||
targetPort: {{ .Values.replica.containerPort }}
|
||||
{{- end }}
|
||||
selector: {{- include "common.labels.matchLabels" . | nindent 4 }}
|
||||
app.kubernetes.io/component: node
|
||||
{{- end }}
|
||||
{{- end }}
|
612
helm/redis/templates/sentinel/statefulset.yaml
Normal file
612
helm/redis/templates/sentinel/statefulset.yaml
Normal file
@ -0,0 +1,612 @@
|
||||
{{- if or .Release.IsUpgrade (ne .Values.sentinel.service.type "NodePort") .Values.sentinel.service.nodePorts.redis -}}
|
||||
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled }}
|
||||
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ printf "%s-node" (include "common.names.fullname" .) }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
app.kubernetes.io/component: node
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
replicas: {{ .Values.replica.replicaCount }}
|
||||
selector:
|
||||
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: node
|
||||
serviceName: {{ printf "%s-headless" (include "common.names.fullname" .) }}
|
||||
{{- if .Values.replica.updateStrategy }}
|
||||
updateStrategy: {{- toYaml .Values.replica.updateStrategy | nindent 4 }}
|
||||
{{- end }}
|
||||
template:
|
||||
metadata:
|
||||
labels: {{- include "common.labels.standard" . | nindent 8 }}
|
||||
app.kubernetes.io/component: node
|
||||
{{- if .Values.replica.podLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.podLabels "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.podLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podLabels "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
annotations:
|
||||
{{- if (include "redis.createConfigmap" .) }}
|
||||
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
|
||||
{{- end }}
|
||||
checksum/health: {{ include (print $.Template.BasePath "/health-configmap.yaml") . | sha256sum }}
|
||||
checksum/scripts: {{ include (print $.Template.BasePath "/scripts-configmap.yaml") . | sha256sum }}
|
||||
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
|
||||
{{- if .Values.replica.podAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.podAnnotations "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- include "redis.imagePullSecrets" . | nindent 6 }}
|
||||
{{- if .Values.replica.hostAliases }}
|
||||
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.replica.hostAliases "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.podSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.replica.podSecurityContext "enabled" | toYaml | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ template "redis.serviceAccountName" . }}
|
||||
{{- if .Values.replica.priorityClassName }}
|
||||
priorityClassName: {{ .Values.replica.priorityClassName | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.affinity }}
|
||||
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.replica.affinity "context" $) | nindent 8 }}
|
||||
{{- else }}
|
||||
affinity:
|
||||
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAffinityPreset "component" "node" "context" $) | nindent 10 }}
|
||||
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAntiAffinityPreset "component" "node" "context" $) | nindent 10 }}
|
||||
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.replica.nodeAffinityPreset.type "key" .Values.replica.nodeAffinityPreset.key "values" .Values.replica.nodeAffinityPreset.values) | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.nodeSelector }}
|
||||
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.replica.nodeSelector "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.tolerations }}
|
||||
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.replica.tolerations "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.spreadConstraints }}
|
||||
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.replica.spreadConstraints "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.shareProcessNamespace }}
|
||||
shareProcessNamespace: {{ .Values.replica.shareProcessNamespace }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.schedulerName }}
|
||||
schedulerName: {{ .Values.replica.schedulerName | quote }}
|
||||
{{- end }}
|
||||
terminationGracePeriodSeconds: {{ .Values.sentinel.terminationGracePeriodSeconds }}
|
||||
containers:
|
||||
- name: redis
|
||||
image: {{ template "redis.image" . }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
||||
{{- if not .Values.diagnosticMode.enabled }}
|
||||
{{- if .Values.replica.lifecycleHooks }}
|
||||
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.replica.lifecycleHooks "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.containerSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.replica.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||
{{- else if .Values.replica.command }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.replica.command "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
command:
|
||||
- /bin/bash
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||
{{- else if .Values.replica.args }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.replica.args "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
args:
|
||||
- -c
|
||||
- /opt/bitnami/scripts/start-scripts/start-node.sh
|
||||
{{- end }}
|
||||
env:
|
||||
- name: BITNAMI_DEBUG
|
||||
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
|
||||
- name: REDIS_MASTER_PORT_NUMBER
|
||||
value: {{ .Values.replica.containerPort | quote }}
|
||||
- name: ALLOW_EMPTY_PASSWORD
|
||||
value: {{ ternary "no" "yes" .Values.auth.enabled | quote }}
|
||||
{{- if .Values.auth.enabled }}
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: REDIS_PASSWORD_FILE
|
||||
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||
- name: REDIS_MASTER_PASSWORD_FILE
|
||||
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||
{{- else }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "redis.secretName" . }}
|
||||
key: {{ template "redis.secretPasswordKey" . }}
|
||||
- name: REDIS_MASTER_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "redis.secretName" . }}
|
||||
key: {{ template "redis.secretPasswordKey" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
- name: REDIS_TLS_ENABLED
|
||||
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: REDIS_TLS_PORT
|
||||
value: {{ .Values.replica.containerPort | quote }}
|
||||
- name: REDIS_TLS_AUTH_CLIENTS
|
||||
value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
|
||||
- name: REDIS_TLS_CERT_FILE
|
||||
value: {{ template "redis.tlsCert" . }}
|
||||
- name: REDIS_TLS_KEY_FILE
|
||||
value: {{ template "redis.tlsCertKey" . }}
|
||||
- name: REDIS_TLS_CA_FILE
|
||||
value: {{ template "redis.tlsCACert" . }}
|
||||
{{- if .Values.tls.dhParamsFilename }}
|
||||
- name: REDIS_TLS_DH_PARAMS_FILE
|
||||
value: {{ template "redis.tlsDHParams" . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
- name: REDIS_PORT
|
||||
value: {{ .Values.replica.containerPort | quote }}
|
||||
{{- end }}
|
||||
- name: REDIS_DATA_DIR
|
||||
value: {{ .Values.replica.persistence.path }}
|
||||
{{- if .Values.replica.extraEnvVars }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraEnvVars "context" $ ) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.replica.extraEnvVarsCM .Values.replica.extraEnvVarsSecret }}
|
||||
envFrom:
|
||||
{{- if .Values.replica.extraEnvVarsCM }}
|
||||
- configMapRef:
|
||||
name: {{ .Values.replica.extraEnvVarsCM }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.extraEnvVarsSecret }}
|
||||
- secretRef:
|
||||
name: {{ .Values.replica.extraEnvVarsSecret }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: redis
|
||||
containerPort: {{ .Values.replica.containerPort }}
|
||||
{{- if not .Values.diagnosticMode.enabled }}
|
||||
{{- if .Values.replica.livenessProbe.enabled }}
|
||||
livenessProbe:
|
||||
initialDelaySeconds: {{ .Values.replica.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.replica.livenessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.replica.livenessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.replica.livenessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.replica.livenessProbe.failureThreshold}}
|
||||
exec:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- /health/ping_liveness_local.sh {{ .Values.replica.livenessProbe.timeoutSeconds }}
|
||||
{{- else if .Values.replica.customLivenessProbe }}
|
||||
livenessProbe: {{- toYaml .Values.replica.customLivenessProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.readinessProbe.enabled }}
|
||||
readinessProbe:
|
||||
initialDelaySeconds: {{ .Values.replica.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.replica.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.replica.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.replica.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.replica.readinessProbe.failureThreshold }}
|
||||
exec:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- /health/ping_readiness_local.sh {{ .Values.replica.livenessProbe.timeoutSeconds }}
|
||||
{{- else if .Values.replica.customReadinessProbe }}
|
||||
readinessProbe: {{- toYaml .Values.replica.customReadinessProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.resources }}
|
||||
resources: {{- toYaml .Values.replica.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: start-scripts
|
||||
mountPath: /opt/bitnami/scripts/start-scripts
|
||||
- name: health
|
||||
mountPath: /health
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: redis-password
|
||||
mountPath: /opt/bitnami/redis/secrets/
|
||||
{{- end }}
|
||||
- name: redis-data
|
||||
mountPath: {{ .Values.replica.persistence.path }}
|
||||
subPath: {{ .Values.replica.persistence.subPath }}
|
||||
- name: config
|
||||
mountPath: /opt/bitnami/redis/mounted-etc
|
||||
- name: redis-tmp-conf
|
||||
mountPath: /opt/bitnami/redis/etc
|
||||
- name: tmp
|
||||
mountPath: /tmp
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: redis-certificates
|
||||
mountPath: /opt/bitnami/redis/certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.replica.extraVolumeMounts }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||
{{- end }}
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- /opt/bitnami/scripts/start-scripts/prestop-redis.sh
|
||||
- name: sentinel
|
||||
image: {{ template "redis.sentinel.image" . }}
|
||||
imagePullPolicy: {{ .Values.sentinel.image.pullPolicy | quote }}
|
||||
{{- if .Values.sentinel.lifecycleHooks }}
|
||||
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.lifecycleHooks "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.sentinel.containerSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.sentinel.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||
{{- else if .Values.sentinel.command }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.command "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
command:
|
||||
- /bin/bash
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||
{{- else if .Values.sentinel.args }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.args "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
args:
|
||||
- -c
|
||||
- /opt/bitnami/scripts/start-scripts/start-sentinel.sh
|
||||
{{- end }}
|
||||
env:
|
||||
- name: BITNAMI_DEBUG
|
||||
value: {{ ternary "true" "false" (or .Values.sentinel.image.debug .Values.diagnosticMode.enabled) | quote }}
|
||||
{{- if .Values.auth.enabled }}
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: REDIS_PASSWORD_FILE
|
||||
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||
{{- else }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "redis.secretName" . }}
|
||||
key: {{ template "redis.secretPasswordKey" . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
- name: ALLOW_EMPTY_PASSWORD
|
||||
value: "yes"
|
||||
{{- end }}
|
||||
- name: REDIS_SENTINEL_TLS_ENABLED
|
||||
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: REDIS_SENTINEL_TLS_PORT_NUMBER
|
||||
value: {{ .Values.sentinel.containerPort | quote }}
|
||||
- name: REDIS_SENTINEL_TLS_AUTH_CLIENTS
|
||||
value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
|
||||
- name: REDIS_SENTINEL_TLS_CERT_FILE
|
||||
value: {{ template "redis.tlsCert" . }}
|
||||
- name: REDIS_SENTINEL_TLS_KEY_FILE
|
||||
value: {{ template "redis.tlsCertKey" . }}
|
||||
- name: REDIS_SENTINEL_TLS_CA_FILE
|
||||
value: {{ template "redis.tlsCACert" . }}
|
||||
{{- if .Values.tls.dhParamsFilename }}
|
||||
- name: REDIS_SENTINEL_TLS_DH_PARAMS_FILE
|
||||
value: {{ template "redis.tls.dhParamsFilename" . }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
- name: REDIS_SENTINEL_PORT
|
||||
value: {{ .Values.sentinel.containerPort | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.sentinel.extraEnvVars }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.extraEnvVars "context" $ ) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.sentinel.extraEnvVarsCM .Values.sentinel.extraEnvVarsSecret }}
|
||||
envFrom:
|
||||
{{- if .Values.sentinel.extraEnvVarsCM }}
|
||||
- configMapRef:
|
||||
name: {{ .Values.sentinel.extraEnvVarsCM }}
|
||||
{{- end }}
|
||||
{{- if .Values.sentinel.extraEnvVarsSecret }}
|
||||
- secretRef:
|
||||
name: {{ .Values.sentinel.extraEnvVarsSecret }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: redis-sentinel
|
||||
containerPort: {{ .Values.sentinel.containerPort }}
|
||||
{{- if not .Values.diagnosticMode.enabled }}
|
||||
{{- if .Values.sentinel.livenessProbe.enabled }}
|
||||
livenessProbe:
|
||||
initialDelaySeconds: {{ .Values.sentinel.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.sentinel.livenessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.sentinel.livenessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.sentinel.livenessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.sentinel.livenessProbe.failureThreshold }}
|
||||
exec:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- /health/ping_sentinel.sh {{ .Values.sentinel.livenessProbe.timeoutSeconds }}
|
||||
{{- else if .Values.sentinel.customLivenessProbe }}
|
||||
livenessProbe: {{- toYaml .Values.sentinel.customLivenessProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if not .Values.diagnosticMode.enabled }}
|
||||
{{- if .Values.sentinel.readinessProbe.enabled}}
|
||||
readinessProbe:
|
||||
initialDelaySeconds: {{ .Values.sentinel.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.sentinel.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.sentinel.readinessProbe.timeoutSeconds }}
|
||||
successThreshold: {{ .Values.sentinel.readinessProbe.successThreshold }}
|
||||
failureThreshold: {{ .Values.sentinel.readinessProbe.failureThreshold }}
|
||||
exec:
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- /health/ping_sentinel.sh {{ .Values.sentinel.livenessProbe.timeoutSeconds }}
|
||||
{{- else if .Values.sentinel.customReadinessProbe }}
|
||||
readinessProbe: {{- toYaml .Values.sentinel.customReadinessProbe | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if not .Values.diagnosticMode.enabled }}
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- /opt/bitnami/scripts/start-scripts/prestop-sentinel.sh
|
||||
{{- end }}
|
||||
{{- if .Values.sentinel.resources }}
|
||||
resources: {{- toYaml .Values.sentinel.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: start-scripts
|
||||
mountPath: /opt/bitnami/scripts/start-scripts
|
||||
- name: health
|
||||
mountPath: /health
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: redis-password
|
||||
mountPath: /opt/bitnami/redis/secrets/
|
||||
{{- end }}
|
||||
- name: redis-data
|
||||
mountPath: {{ .Values.replica.persistence.path }}
|
||||
subPath: {{ .Values.replica.persistence.subPath }}
|
||||
- name: config
|
||||
mountPath: /opt/bitnami/redis-sentinel/mounted-etc
|
||||
- name: sentinel-tmp-conf
|
||||
mountPath: /opt/bitnami/redis-sentinel/etc
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: redis-certificates
|
||||
mountPath: /opt/bitnami/redis/certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- if .Values.sentinel.extraVolumeMounts }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.enabled }}
|
||||
- name: metrics
|
||||
image: {{ template "redis.metrics.image" . }}
|
||||
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
|
||||
{{- if .Values.metrics.containerSecurityContext.enabled }}
|
||||
securityContext: {{- omit .Values.metrics.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||
{{- else }}
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
- |
|
||||
if [[ -f '/secrets/redis-password' ]]; then
|
||||
export REDIS_PASSWORD=$(cat /secrets/redis-password)
|
||||
fi
|
||||
redis_exporter{{- range $key, $value := .Values.metrics.extraArgs }} --{{ $key }}={{ $value }}{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.diagnosticMode.enabled }}
|
||||
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
env:
|
||||
- name: REDIS_ALIAS
|
||||
value: {{ template "common.names.fullname" . }}
|
||||
{{- if .Values.auth.enabled }}
|
||||
- name: REDIS_USER
|
||||
value: default
|
||||
{{- if (not .Values.auth.usePasswordFiles) }}
|
||||
- name: REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ template "redis.secretName" . }}
|
||||
key: {{ template "redis.secretPasswordKey" . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: REDIS_ADDR
|
||||
value: rediss://{{ .Values.metrics.redisTargetHost }}:{{ .Values.replica.containerPort }}
|
||||
{{- if .Values.tls.authClients }}
|
||||
- name: REDIS_EXPORTER_TLS_CLIENT_KEY_FILE
|
||||
value: {{ template "redis.tlsCertKey" . }}
|
||||
- name: REDIS_EXPORTER_TLS_CLIENT_CERT_FILE
|
||||
value: {{ template "redis.tlsCert" . }}
|
||||
{{- end }}
|
||||
- name: REDIS_EXPORTER_TLS_CA_CERT_FILE
|
||||
value: {{ template "redis.tlsCACert" . }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 9121
|
||||
{{- if .Values.metrics.resources }}
|
||||
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: redis-password
|
||||
mountPath: /secrets/
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: redis-certificates
|
||||
mountPath: /opt/bitnami/redis/certs
|
||||
readOnly: true
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.sidecars }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.replica.sidecars "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- $needsVolumePermissions := and .Values.volumePermissions.enabled .Values.replica.persistence.enabled .Values.replica.podSecurityContext.enabled .Values.replica.containerSecurityContext.enabled }}
|
||||
{{- if or .Values.replica.initContainers $needsVolumePermissions .Values.sysctl.enabled }}
|
||||
initContainers:
|
||||
{{- if .Values.replica.initContainers }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.replica.initContainers "context" $) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if $needsVolumePermissions }}
|
||||
- name: volume-permissions
|
||||
image: {{ include "redis.volumePermissions.image" . }}
|
||||
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
|
||||
command:
|
||||
- /bin/bash
|
||||
- -ec
|
||||
- |
|
||||
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||
chown -R `id -u`:`id -G | cut -d " " -f2` {{ .Values.replica.persistence.path }}
|
||||
{{- else }}
|
||||
chown -R {{ .Values.replica.containerSecurityContext.runAsUser }}:{{ .Values.replica.podSecurityContext.fsGroup }} {{ .Values.replica.persistence.path }}
|
||||
{{- end }}
|
||||
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||
securityContext: {{- omit .Values.volumePermissions.containerSecurityContext "runAsUser" | toYaml | nindent 12 }}
|
||||
{{- else }}
|
||||
securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.volumePermissions.resources }}
|
||||
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
volumeMounts:
|
||||
- name: redis-data
|
||||
mountPath: {{ .Values.replica.persistence.path }}
|
||||
subPath: {{ .Values.replica.persistence.subPath }}
|
||||
{{- end }}
|
||||
{{- if .Values.sysctl.enabled }}
|
||||
- name: init-sysctl
|
||||
image: {{ include "redis.sysctl.image" . }}
|
||||
imagePullPolicy: {{ default "" .Values.sysctl.image.pullPolicy | quote }}
|
||||
securityContext:
|
||||
privileged: true
|
||||
runAsUser: 0
|
||||
{{- if .Values.sysctl.command }}
|
||||
command: {{- include "common.tplvalues.render" (dict "value" .Values.sysctl.command "context" $) | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.sysctl.resources }}
|
||||
resources: {{- toYaml .Values.sysctl.resources | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- if .Values.sysctl.mountHostSys }}
|
||||
volumeMounts:
|
||||
- name: host-sys
|
||||
mountPath: /host-sys
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
volumes:
|
||||
- name: start-scripts
|
||||
configMap:
|
||||
name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
|
||||
defaultMode: 0755
|
||||
- name: health
|
||||
configMap:
|
||||
name: {{ printf "%s-health" (include "common.names.fullname" .) }}
|
||||
defaultMode: 0755
|
||||
{{- if .Values.auth.usePasswordFiles }}
|
||||
- name: redis-password
|
||||
secret:
|
||||
secretName: {{ template "redis.secretName" . }}
|
||||
items:
|
||||
- key: {{ template "redis.secretPasswordKey" . }}
|
||||
path: redis-password
|
||||
{{- end }}
|
||||
- name: config
|
||||
configMap:
|
||||
name: {{ include "redis.configmapName" . }}
|
||||
{{- if .Values.sysctl.mountHostSys }}
|
||||
- name: host-sys
|
||||
hostPath:
|
||||
path: /sys
|
||||
{{- end }}
|
||||
- name: sentinel-tmp-conf
|
||||
{{- if .Values.replica.persistence.medium }}
|
||||
emptyDir: {
|
||||
medium: {{ .Values.replica.persistence.medium | quote }}
|
||||
}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
- name: redis-tmp-conf
|
||||
{{- if .Values.replica.persistence.medium }}
|
||||
emptyDir: {
|
||||
medium: {{ .Values.replica.persistence.medium | quote }}
|
||||
}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
- name: tmp
|
||||
{{- if .Values.replica.persistence.medium }}
|
||||
emptyDir: {
|
||||
medium: {{ .Values.replica.persistence.medium | quote }}
|
||||
}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- if .Values.replica.extraVolumes }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumes "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.sentinel.extraVolumes }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.extraVolumes "context" $ ) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- if .Values.tls.enabled }}
|
||||
- name: redis-certificates
|
||||
secret:
|
||||
secretName: {{ include "redis.tlsSecretName" . }}
|
||||
defaultMode: 256
|
||||
{{- end }}
|
||||
{{- if not .Values.replica.persistence.enabled }}
|
||||
- name: redis-data
|
||||
{{- if .Values.replica.persistence.medium }}
|
||||
emptyDir: {
|
||||
medium: {{ .Values.replica.persistence.medium | quote }}
|
||||
}
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: redis-data
|
||||
labels: {{- include "common.labels.matchLabels" . | nindent 10 }}
|
||||
app.kubernetes.io/component: node
|
||||
{{- if .Values.replica.persistence.annotations }}
|
||||
annotations: {{- toYaml .Values.replica.persistence.annotations | nindent 10 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
accessModes:
|
||||
{{- range .Values.replica.persistence.accessModes }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.replica.persistence.size | quote }}
|
||||
{{- if .Values.replica.persistence.selector }}
|
||||
selector: {{- include "common.tplvalues.render" ( dict "value" .Values.replica.persistence.selector "context" $) | nindent 10 }}
|
||||
{{- end }}
|
||||
{{- include "common.storage.class" (dict "persistence" .Values.replica.persistence "global" .Values.global) | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
21
helm/redis/templates/serviceaccount.yaml
Normal file
21
helm/redis/templates/serviceaccount.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
|
||||
metadata:
|
||||
name: {{ template "redis.serviceAccountName" . }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if or .Values.commonAnnotations .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- if or .Values.commonAnnotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.serviceAccount.annotations }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.serviceAccount.annotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
45
helm/redis/templates/servicemonitor.yaml
Normal file
45
helm/redis/templates/servicemonitor.yaml
Normal file
@ -0,0 +1,45 @@
|
||||
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}
|
||||
{{- if .Values.metrics.serviceMonitor.namespace }}
|
||||
namespace: {{ .Values.metrics.serviceMonitor.namespace }}
|
||||
{{- else }}
|
||||
namespace: {{ .Release.Namespace | quote }}
|
||||
{{- end }}
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.metrics.serviceMonitor.additionalLabels }}
|
||||
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.serviceMonitor.additionalLabels "context" $) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
endpoints:
|
||||
- port: http-metrics
|
||||
{{- if .Values.metrics.serviceMonitor.interval }}
|
||||
interval: {{ .Values.metrics.serviceMonitor.interval }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
|
||||
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.serviceMonitor.honorLabels }}
|
||||
honorLabels: {{ .Values.metrics.serviceMonitor.honorLabels }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.serviceMonitor.relabellings }}
|
||||
relabelings: {{- toYaml .Values.metrics.serviceMonitor.relabellings | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if .Values.metrics.serviceMonitor.metricRelabelings }}
|
||||
metricRelabelings: {{- toYaml .Values.metrics.serviceMonitor.metricRelabelings | nindent 6 }}
|
||||
{{- end }}
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- {{ .Release.Namespace }}
|
||||
selector:
|
||||
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
|
||||
app.kubernetes.io/component: metrics
|
||||
{{- end }}
|
26
helm/redis/templates/tls-secret.yaml
Normal file
26
helm/redis/templates/tls-secret.yaml
Normal file
@ -0,0 +1,26 @@
|
||||
{{- if (include "redis.createTlsSecret" .) }}
|
||||
{{- $ca := genCA "redis-ca" 365 }}
|
||||
{{- $releaseNamespace := .Release.Namespace }}
|
||||
{{- $clusterDomain := .Values.clusterDomain }}
|
||||
{{- $fullname := include "common.names.fullname" . }}
|
||||
{{- $serviceName := include "common.names.fullname" . }}
|
||||
{{- $headlessServiceName := printf "%s-headless" (include "common.names.fullname" .) }}
|
||||
{{- $altNames := list (printf "*.%s.%s.svc.%s" $serviceName $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $serviceName $releaseNamespace $clusterDomain) (printf "*.%s.%s.svc.%s" $headlessServiceName $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $headlessServiceName $releaseNamespace $clusterDomain) "127.0.0.1" "localhost" $fullname }}
|
||||
{{- $crt := genSignedCert $fullname nil $altNames 365 $ca }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "common.names.fullname" . }}-crt
|
||||
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
||||
{{- if .Values.commonLabels }}
|
||||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- if .Values.commonAnnotations }}
|
||||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||
{{- end }}
|
||||
type: kubernetes.io/tls
|
||||
data:
|
||||
ca.crt: {{ $ca.Cert | b64enc | quote }}
|
||||
tls.crt: {{ $crt.Cert | b64enc | quote }}
|
||||
tls.key: {{ $crt.Key | b64enc | quote }}
|
||||
{{- end }}
|
Reference in New Issue
Block a user