[stable/rabbitmq-ha] Clustering fixes (#4610)

* Use hostnames instead of IPs for node names since IPs are ephemeral
* Always use a headless clusterIP service for clustering
* Never use a cached erlang cookie since we are always providing it
This commit is contained in:
Corey O'Brien
2018-04-07 09:55:08 -07:00
committed by k8s-ci-robot
parent d6f2afaf74
commit 276f446055
4 changed files with 84 additions and 9 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
name: rabbitmq-ha
apiVersion: v1
appVersion: 3.7.3
version: 1.0.8
version: 1.1.0
description: Highly available RabbitMQ cluster, the open source message broker
software that implements the Advanced Message Queuing Protocol (AMQP).
keywords:
+2 -2
View File
@@ -47,7 +47,7 @@ data:
rabbitmq.conf: |
## RabbitMQ configuration
## Ref: https://github.com/rabbitmq/rabbitmq-server/blob/master/docs/rabbitmq.conf.example
## Authentification
{{- if .Values.rabbitmqAuth.enabled }}
{{ .Values.rabbitmqAuth.config | indent 4 }}
@@ -56,7 +56,7 @@ data:
## Clustering
cluster_formation.peer_discovery_backend = rabbit_peer_discovery_k8s
cluster_formation.k8s.host = kubernetes.default.svc.cluster.local
cluster_formation.k8s.address_type = ip
cluster_formation.k8s.address_type = hostname
cluster_formation.node_cleanup.interval = 10
cluster_formation.node_cleanup.only_log_warning = false
cluster_partition_handling = autoheal
@@ -0,0 +1,70 @@
apiVersion: v1
kind: Service
metadata:
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
name: {{ template "rabbitmq-ha.fullname" . }}-discovery
labels:
app: {{ template "rabbitmq-ha.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
clusterIP: None
ports:
- name: http
protocol: TCP
port: {{ .Values.rabbitmqManagerPort }}
targetPort: http
- name: amqp
protocol: TCP
port: {{ .Values.rabbitmqNodePort }}
targetPort: amqp
- name: epmd
protocol: TCP
port: {{ .Values.rabbitmqEpmdPort }}
targetPort: epmd
{{- if .Values.rabbitmqSTOMPPlugin.enabled }}
- name: stomp-tcp
protocol: TCP
port: 1883
targetPort: stomp-tcp
- name: stomp-ssl
protocol: TCP
port: 8883
targetPort: stomp-ssl
{{- end }}
{{- if .Values.rabbitmqWebSTOMPPlugin.enabled }}
- name: stomp-ws
protocol: TCP
port: 15674
targetPort: stomp-ws
{{- end }}
{{- if .Values.rabbitmqMQTTPlugin.enabled }}
- name: mqtt-tcp
protocol: TCP
port: 61613
targetPort: mqtt-tcp
- name: mqtt-ssl
protocol: TCP
port: 61614
targetPort: mqtt-ssl
{{- end }}
{{- if .Values.rabbitmqWebMQTTPlugin.enabled }}
- name: mqtt-ws
protocol: TCP
port: 15675
targetPort: mqtt-ws
{{- end }}
{{- if .Values.rabbitmqAmqpsSupport.enabled }}
- name: amqps
protocol: TCP
port: {{ .Values.rabbitmqAmqpsSupport.amqpsNodePort }}
targetPort: amqps
{{- end }}
selector:
app: {{ template "rabbitmq-ha.name" . }}
release: {{ .Release.Name }}
type: ClusterIP
+11 -6
View File
@@ -8,7 +8,7 @@ metadata:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
serviceName: {{ template "rabbitmq-ha.fullname" . }}
serviceName: {{ template "rabbitmq-ha.fullname" . }}-discovery
replicas: {{ .Values.replicaCount }}
updateStrategy:
type: {{ .Values.updateStrategy }}
@@ -27,12 +27,14 @@ spec:
initContainers:
- name: copy-rabbitmq-config
image: busybox
command: ['sh', '-c', 'cp /configmap/* /etc/rabbitmq']
command: ['sh', '-c', 'cp /configmap/* /etc/rabbitmq; rm -f /var/lib/rabbitmq/.erlang.cookie']
volumeMounts:
- name: configmap
mountPath: /configmap
- name: config
mountPath: /etc/rabbitmq
- name: data
mountPath: /var/lib/rabbitmq
containers:
- name: {{ .Chart.Name }}
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
@@ -93,16 +95,19 @@ spec:
initialDelaySeconds: 10
timeoutSeconds: 5
env:
- name: MY_POD_IP
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: status.podIP
apiVersion: v1
fieldPath: metadata.name
- name: RABBITMQ_USE_LONGNAME
value: "true"
- name: RABBITMQ_NODENAME
value: "rabbit@$(MY_POD_IP)"
value: rabbit@$(MY_POD_NAME).{{ template "rabbitmq-ha.fullname" . }}-discovery.{{ .Release.Namespace }}.svc.cluster.local
- name: K8S_HOSTNAME_SUFFIX
value: .{{ template "rabbitmq-ha.fullname" . }}-discovery.{{ .Release.Namespace }}.svc.cluster.local
- name: K8S_SERVICE_NAME
value: {{ template "rabbitmq-ha.fullname" . }}
value: {{ template "rabbitmq-ha.fullname" . }}-discovery
- name: RABBITMQ_ERLANG_COOKIE
valueFrom:
secretKeyRef: