Files
charts/upstreamed/redis/templates/redis-slave-deployment.yaml
2018-09-24 10:36:19 +00:00

136 lines
5.3 KiB
YAML

{{- if .Values.cluster.enabled }}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "redis.fullname" . }}-slave
labels:
app: {{ template "redis.name" . }}
chart: {{ template "redis.chart" . }}
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
{{- if .Values.cluster.slaveCount }}
replicas: {{ .Values.cluster.slaveCount }}
{{- end }}
selector:
matchLabels:
release: "{{ .Release.Name }}"
role: slave
app: {{ template "redis.name" . }}
template:
metadata:
labels:
release: "{{ .Release.Name }}"
chart: {{ template "redis.chart" . }}
role: slave
app: {{ template "redis.name" . }}
{{- if (.Values.slave.podLabels | default .Values.master.podLabels) }}
{{ toYaml (.Values.slave.podLabels | default .Values.master.podLabels) | indent 8 }}
{{- end }}
annotations:
checksum/health: {{ include (print $.Template.BasePath "/health-configmap.yaml") . | sha256sum }}
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- if (.Values.slave.podAnnotations | default .Values.master.podAnnotations) }}
{{ toYaml (.Values.slave.podAnnotations | default .Values.master.podAnnotations) | indent 8 }}
{{- end }}
spec:
{{- if .Values.image.pullSecrets }}
imagePullSecrets:
{{- range .Values.image.pullSecrets }}
- name: {{ . }}
{{- end}}
{{- end}}
{{- /* Include master securityContext if slave securityContext not defined */ -}}
{{ include "redis.slave.securityContext" . | indent 6 }}
serviceAccountName: "{{ template "redis.serviceAccountName" . }}"
{{- if (.Values.slave.nodeSelector | default .Values.master.nodeSelector) }}
nodeSelector:
{{ toYaml (.Values.slave.nodeSelector | default .Values.master.nodeSelector) | indent 8 }}
{{- end }}
{{- if (.Values.slave.tolerations | default .Values.master.tolerations) }}
tolerations:
{{ toYaml (.Values.slave.tolerations | default .Values.master.tolerations) | indent 8 }}
{{- end }}
{{- if .Values.slave.schedulerName }}
schedulerName: "{{ .Values.slave.schedulerName }}"
{{- end }}
{{- with .Values.slave.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
containers:
- name: {{ template "redis.fullname" . }}
image: {{ template "redis.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | default "" | quote }}
{{- if (.Values.slave.args | default .Values.master.args) }}
args:
{{ toYaml (.Values.slave.args | default .Values.master.args) | indent 10 }}
{{- end }}
env:
- name: REDIS_REPLICATION_MODE
value: slave
- name: REDIS_MASTER_HOST
value: {{ template "redis.fullname" . }}-master
- name: REDIS_PORT
value: {{ .Values.slave.port | default .Values.master.port | quote }}
- name: REDIS_MASTER_PORT_NUMBER
value: {{ .Values.master.service.port | quote }}
{{- if .Values.usePassword }}
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.existingSecret }}
name: {{ .Values.existingSecret }}
{{- else }}
name: {{ template "redis.fullname" . }}
{{- end }}
key: redis-password
- name: REDIS_MASTER_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.existingSecret }}
name: {{ .Values.existingSecret }}
{{- else }}
name: {{ template "redis.fullname" . }}
{{- end }}
key: redis-password
{{- else }}
- name: ALLOW_EMPTY_PASSWORD
value: "yes"
{{- end }}
- name: REDIS_DISABLE_COMMANDS
value: {{ .Values.slave.disableCommands | default .Values.master.disableCommands }}
{{- if (.Values.slave.extraFlags | default .Values.master.extraFlags) }}
- name: REDIS_EXTRA_FLAGS
value: {{ .Values.slave.extraFlags | default .Values.master.extraFlags | join " " }}
{{- end }}
ports:
- name: redis
containerPort: {{ .Values.slave.port | default .Values.master.port }}
{{- /* Include master livenessProbe if slave livenessProbe not defined */ -}}
{{ include "redis.slave.livenessProbe" . | indent 8 }}
{{- /* Include master readinessProbe if slave readinessProbe not defined */ -}}
{{ include "redis.slave.readinessProbe" . | indent 8 }}
resources:
{{ toYaml (.Values.slave.resources | default .Values.master.resources) | indent 10 }}
volumeMounts:
- name: health
mountPath: /health
{{- if .Values.configmap }}
- name: config
mountPath: /opt/bitnami/redis/etc/redis.conf
subPath: redis.conf
{{- end }}
volumes:
- name: health
configMap:
name: {{ template "redis.fullname" . }}-health
defaultMode: 0755
{{- if .Values.configmap }}
- name: config
configMap:
name: {{ template "redis.fullname" . }}
{{- end }}
{{- end }}