RabbitMQ: persist stateful data to volume

This PS persists stateful data to volumes, allowing the cluster to
restart.

Change-Id: Ic881230cf2434d5c381542e57dc30df92cd4e158
Closes-Bug: #1753500
This commit is contained in:
portdirect 2018-03-05 09:18:18 -05:00
parent e25342ddd0
commit 7b4fabb06c
2 changed files with 39 additions and 4 deletions

View File

@ -74,7 +74,23 @@ spec:
nodeSelector: nodeSelector:
{{ .Values.labels.server.node_selector_key }}: {{ .Values.labels.server.node_selector_value }} {{ .Values.labels.server.node_selector_key }}: {{ .Values.labels.server.node_selector_value }}
initContainers: initContainers:
{{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 9 }} {{ tuple $envAll $dependencies list | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }}
{{- if .Values.volume.chown_on_start }}
- name: rabbitmq-perms
image: {{ .Values.images.tags.rabbitmq }}
imagePullPolicy: {{ .Values.images.pull_policy }}
securityContext:
runAsUser: 0
{{ tuple $envAll $envAll.Values.pod.resources.server | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }}
command:
- chown
- -R
- "rabbitmq:"
- /var/lib/rabbitmq
volumeMounts:
- name: rabbitmq-data
mountPath: /var/lib/rabbitmq
{{- end }}
containers: containers:
- name: rabbitmq - name: rabbitmq
image: {{ .Values.images.tags.rabbitmq }} image: {{ .Values.images.tags.rabbitmq }}
@ -114,7 +130,7 @@ spec:
command: command:
- /tmp/rabbitmq-liveness.sh - /tmp/rabbitmq-liveness.sh
volumeMounts: volumeMounts:
- name: rabbitmq-emptydir - name: rabbitmq-data
mountPath: /var/lib/rabbitmq mountPath: /var/lib/rabbitmq
- name: rabbitmq-bin - name: rabbitmq-bin
mountPath: /tmp mountPath: /tmp
@ -127,8 +143,6 @@ spec:
subPath: rabbitmq.conf subPath: rabbitmq.conf
readOnly: true readOnly: true
volumes: volumes:
- name: rabbitmq-emptydir
emptyDir: {}
- name: rabbitmq-bin - name: rabbitmq-bin
configMap: configMap:
name: {{ printf "%s-%s" $envAll.Release.Name "rabbitmq-bin" | quote }} name: {{ printf "%s-%s" $envAll.Release.Name "rabbitmq-bin" | quote }}
@ -137,4 +151,19 @@ spec:
configMap: configMap:
name: {{ printf "%s-%s" $envAll.Release.Name "rabbitmq-etc" | quote }} name: {{ printf "%s-%s" $envAll.Release.Name "rabbitmq-etc" | quote }}
defaultMode: 0444 defaultMode: 0444
{{- if not .Values.volume.enabled }}
- name: rabbitmq-data
emptyDir: {}
{{- end }}
{{- if .Values.volume.enabled }}
volumeClaimTemplates:
- metadata:
name: rabbitmq-data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.volume.size }}
storageClassName: {{ .Values.volume.class_name }}
{{- end }}
{{ end }} {{ end }}

View File

@ -184,6 +184,12 @@ endpoints:
metrics: metrics:
default: 9095 default: 9095
volume:
chown_on_start: true
enabled: true
class_name: general
size: 1Gi
manifests: manifests:
configmap_bin: true configmap_bin: true
configmap_etc: true configmap_etc: true