From a2c43262cfbd3b5976732ca270593920e6640b92 Mon Sep 17 00:00:00 2001 From: Zhipeng Liu Date: Fri, 20 Mar 2020 22:07:54 +0800 Subject: [PATCH] Fix rabbitmq could not bind port to ipv6 address issue When we use amarda to deploy openstack service for ipv6, rabbitmq pod could not start listen on [::]:5672 and [::]:15672. For ipv6, we need do some override as below. conf: rabbitmq: management.listener.port: 15672 management.listener.ip: "::" rabbitmq_env: | SERVER_ADDITIONAL_ERL_ARGS="+A 128 -kernel inetrc '/etc/rabbitmq/erl_inetrc' -proto_dist inet6_tcp" CTL_ERL_ARGS="-proto_dist inet6_tcp" erl_inetrc: | {inet6,true}. We have test pass on both ipv4 and ipv6 setup for StarlingX project. Signed-off-by: Zhipeng Liu Change-Id: I7af840ecd8960f9f1aa3f38d155c6e1bd822cb6e --- rabbitmq/templates/configmap-etc.yaml | 34 ++++++++++++++++++++++++++- rabbitmq/templates/statefulset.yaml | 13 +++++++--- rabbitmq/values.yaml | 3 +++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/rabbitmq/templates/configmap-etc.yaml b/rabbitmq/templates/configmap-etc.yaml index 85208485e..cfb46efe2 100644 --- a/rabbitmq/templates/configmap-etc.yaml +++ b/rabbitmq/templates/configmap-etc.yaml @@ -12,6 +12,23 @@ See the License for the specific language governing permissions and limitations under the License. */}} +{{/* +(aostapenko) rounds cpu limit in any permissible format to integer value (min 1) +"100m" -> 1 +"1100m" -> 1 +"10900m" -> 10 +0.3 -> 1 +5.4 -> 5 +*/}} +{{- define "get_erlvm_scheduler_num" -}} +{{- $val := . | toString -}} +{{- if regexMatch "^[0-9]*m$" $val -}} +{{- $val = div (float64 (trimSuffix "m" $val)) 1000 -}} +{{- end -}} +{{/* NOTE(aostapenko) String with floating number does not convert well to int*/}} +{{- $val | float64 | int | default 1 -}} +{{- end -}} + {{- if .Values.manifests.configmap_etc }} {{- $envAll := . }} @@ -19,7 +36,9 @@ limitations under the License. {{- $_ := print "kubernetes.default.svc." $envAll.Values.endpoints.cluster_domain_suffix | set $envAll.Values.conf.rabbitmq.cluster_formation.k8s "host" -}} {{- end -}} -{{- $_ := print "0.0.0.0:" ( tuple "oslo_messaging" "internal" "amqp" . | include "helm-toolkit.endpoints.endpoint_port_lookup") | set $envAll.Values.conf.rabbitmq.listeners.tcp "1" -}} +{{- $_ := print ":::" ( tuple "oslo_messaging" "internal" "amqp" . | include "helm-toolkit.endpoints.endpoint_port_lookup") | set $envAll.Values.conf.rabbitmq.listeners.tcp "1" -}} + +{{- $_ := tuple "oslo_messaging" "internal" "http" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | set $envAll.Values.conf.rabbitmq "management.listener.port" -}} --- apiVersion: v1 @@ -31,4 +50,17 @@ data: {{ tuple "etc/_enabled_plugins.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} rabbitmq.conf: | {{ include "rabbitmq.utils.to_rabbit_config" $envAll.Values.conf.rabbitmq | indent 4 }} + +{{- $erlvm_scheduler_num := include "get_erlvm_scheduler_num" .Values.pod.resources.server.limits.cpu }} +{{- $erlvm_scheduler_conf := printf "+S %s:%s" $erlvm_scheduler_num $erlvm_scheduler_num }} +{{- if .Values.manifests.config_ipv6 }} + rabbitmq-env.conf: | + SERVER_ADDITIONAL_ERL_ARGS={{ printf "+A 128 -kernel inetrc '/etc/rabbitmq/erl_inetrc' -proto_dist inet6_tcp %s" $erlvm_scheduler_conf | quote }} + CTL_ERL_ARGS="-proto_dist inet6_tcp" + erl_inetrc: | + {inet6, true}. +{{- else }} + rabbitmq-env.conf: | + SERVER_ADDITIONAL_ERL_ARGS={{ $erlvm_scheduler_conf | quote }} +{{- end }} {{ end }} diff --git a/rabbitmq/templates/statefulset.yaml b/rabbitmq/templates/statefulset.yaml index 65cecb4f6..e5739f506 100644 --- a/rabbitmq/templates/statefulset.yaml +++ b/rabbitmq/templates/statefulset.yaml @@ -207,9 +207,6 @@ spec: value: "{{ tuple "oslo_messaging" "internal" "amqp" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }}" - name: PORT_CLUSTERING value: "{{ add (tuple "oslo_messaging" "internal" "amqp" . | include "helm-toolkit.endpoints.endpoint_port_lookup") 20000 }}" - - name: RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS - {{- $erlvm_scheduler_num := include "get_erlvm_scheduler_num" .Values.pod.resources.server.limits.cpu }} - value: {{ printf "+S %s:%s" $erlvm_scheduler_num $erlvm_scheduler_num | quote }} readinessProbe: initialDelaySeconds: 10 timeoutSeconds: 10 @@ -247,6 +244,16 @@ spec: mountPath: /etc/rabbitmq/rabbitmq.conf subPath: rabbitmq.conf readOnly: true + - name: rabbitmq-etc + mountPath: /etc/rabbitmq/rabbitmq-env.conf + subPath: rabbitmq-env.conf + readOnly: true +{{- if .Values.manifests.config_ipv6 }} + - name: rabbitmq-etc + mountPath: /etc/rabbitmq/erl_inetrc + subPath: erl_inetrc + readOnly: true +{{- end }} volumes: - name: pod-tmp emptyDir: {} diff --git a/rabbitmq/values.yaml b/rabbitmq/values.yaml index f539fbf58..5240da426 100644 --- a/rabbitmq/values.yaml +++ b/rabbitmq/values.yaml @@ -188,6 +188,8 @@ conf: queue_master_locator: min-masters loopback_users.guest: "false" management.load_definitions: "/var/lib/rabbitmq/definitions.json" + management.listener.ip: "::" + management.listener.port: null dependencies: dynamic: @@ -374,4 +376,5 @@ manifests: service_ingress_management: true service: true statefulset: true + config_ipv6: false ...