From 894975ec5056c349a13b052c649e7ff7dee7cacf Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Thu, 5 Sep 2019 15:36:06 +0200 Subject: [PATCH 01/15] Added definitions.json file to define and set RabbitMQ policies for HA (Mirrored Queues) queues. Added logic to parse environment variables to set defult username, password and patter for Mirrored Queues at container startup --- images/rabbitmq-cluster/cluster-rabbit.sh | 7 +++++++ images/rabbitmq/Dockerfile | 17 ++++++++++++++--- images/rabbitmq/cluster-rabbit.sh | 11 +++++++++++ images/rabbitmq/definitions.json | 14 ++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 images/rabbitmq/cluster-rabbit.sh create mode 100644 images/rabbitmq/definitions.json diff --git a/images/rabbitmq-cluster/cluster-rabbit.sh b/images/rabbitmq-cluster/cluster-rabbit.sh index 31c488ef1e..cd2ea1d38c 100644 --- a/images/rabbitmq-cluster/cluster-rabbit.sh +++ b/images/rabbitmq-cluster/cluster-rabbit.sh @@ -13,5 +13,12 @@ echo NODENAME=rabbit@${HOSTNAME}.${SERVICE_NAME}-headless.${POD_NAMESPACE}.svc.c echo cluster_formation.k8s.hostname_suffix=.${SERVICE_NAME}-headless.${POD_NAMESPACE}.svc.cluster.local >> /etc/rabbitmq/rabbitmq.conf echo cluster_formation.k8s.service_name=${SERVICE_NAME}-headless >> /etc/rabbitmq/rabbitmq.conf +# Replace placeholders with ENV values and copy file to rabbitmq conf directory from ConfigMap +if [ -e /etc/rabbitmq/definitions.json ]; then + sed -i -e "s/REPLACE_USERNAME/${RABBITMQ_DEFAULT_USER}/g" \ + -e "s/REPLACE_PASSWORD/${RABBITMQ_DEFAULT_PASS}/g" \ + -e "s/REPLACE_QUEUE_PATTERN/${RABBITMQ_DEFAULT_HA_PATTERN}/g" /etc/rabbitmq/definitions.json +fi + # start the server docker-entrypoint.sh rabbitmq-server diff --git a/images/rabbitmq/Dockerfile b/images/rabbitmq/Dockerfile index 6611b115b3..6acc38e5b6 100644 --- a/images/rabbitmq/Dockerfile +++ b/images/rabbitmq/Dockerfile @@ -3,9 +3,20 @@ FROM rabbitmq:3-management ARG LAGOON_VERSION ENV LAGOON_VERSION=$LAGOON_VERSION -COPY rabbitmq_delayed_message_exchange-3.7.0.ez /plugins +ENV RABBITMQ_DEFAULT_USER=guest \ + RABBITMQ_DEFAULT_PASS="guest"\ + RABBITMQ_DEFAULT_HA_PATTERN='^lagoon-' + +COPY rabbitmq_delayed_message_exchange-3.7.0.ez /plugins RUN rabbitmq-plugins enable --offline rabbitmq_delayed_message_exchange; -ENV RABBITMQ_DEFAULT_USER=guest \ - RABBITMQ_DEFAULT_PASS="guest" +# Copy startup schema with vhost, users, permissions and policies +COPY definitions.json /etc/rabbitmq/definitions.json +RUN chgrp 0 /etc/rabbitmq/definitions.json; chmod g+rw /etc/rabbitmq/definitions.json + +# Copy a custom entrypoint +ADD cluster-rabbit.sh / +RUN chgrp 0 /cluster-rabbit.sh; chmod +x /cluster-rabbit.sh + +ENTRYPOINT /cluster-rabbit.sh diff --git a/images/rabbitmq/cluster-rabbit.sh b/images/rabbitmq/cluster-rabbit.sh new file mode 100644 index 0000000000..2826068a86 --- /dev/null +++ b/images/rabbitmq/cluster-rabbit.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# Replace placeholders with ENV values and copy file to rabbitmq conf directory from ConfigMap +if [ -e /etc/rabbitmq/definitions.json ]; then + sed -i -e "s/REPLACE_USERNAME/${RABBITMQ_DEFAULT_USER}/g" \ + -e "s/REPLACE_PASSWORD/${RABBITMQ_DEFAULT_PASS}/g" \ + -e "s/REPLACE_QUEUE_PATTERN/${RABBITMQ_DEFAULT_HA_PATTERN}/g" /etc/rabbitmq/definitions.json +fi + +# start the server +docker-entrypoint.sh rabbitmq-server diff --git a/images/rabbitmq/definitions.json b/images/rabbitmq/definitions.json new file mode 100644 index 0000000000..b73523212d --- /dev/null +++ b/images/rabbitmq/definitions.json @@ -0,0 +1,14 @@ +{ + "vhosts":[ + {"name": "/"} + ], + "users": [ + { "name": "REPLACE_USERNAME", "password": "REPLACE_PASSWORD", "tags": "administrator" } + ], + "permissions":[ + { "user": "REPLACE_USERNAME", "vhost": "/", "configure": ".*", "write": ".*", "read": ".*" } + ], + "policies":[ + {"vhost":"/","name":"lagoon-ha","pattern":"REPLACE_QUEUE_PATTERN", "definition":{"ha-mode":"all","ha-sync-mode":"automatic","ha-sync-batch-size":5}} + ] +} From dcd18246fe19117913ba65fc9e38cbb96072a07f Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Fri, 6 Sep 2019 00:11:10 +0200 Subject: [PATCH 02/15] - Changed RabbitMQ default ha-policy to "exactly" instead of "all" - Set number of mirrors per queue to 2 - Modified broker lagoon template by adding the RABBITMQ_DEFAULT_HA_PATTER variable --- images/rabbitmq-cluster/cluster-rabbit.sh | 2 +- images/rabbitmq/definitions.json | 2 +- services/broker/.lagoon.app.yml | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/images/rabbitmq-cluster/cluster-rabbit.sh b/images/rabbitmq-cluster/cluster-rabbit.sh index cd2ea1d38c..e875ebafd2 100644 --- a/images/rabbitmq-cluster/cluster-rabbit.sh +++ b/images/rabbitmq-cluster/cluster-rabbit.sh @@ -13,7 +13,7 @@ echo NODENAME=rabbit@${HOSTNAME}.${SERVICE_NAME}-headless.${POD_NAMESPACE}.svc.c echo cluster_formation.k8s.hostname_suffix=.${SERVICE_NAME}-headless.${POD_NAMESPACE}.svc.cluster.local >> /etc/rabbitmq/rabbitmq.conf echo cluster_formation.k8s.service_name=${SERVICE_NAME}-headless >> /etc/rabbitmq/rabbitmq.conf -# Replace placeholders with ENV values and copy file to rabbitmq conf directory from ConfigMap +# Replace placeholders with ENV values and copy file to rabbitmq conf directory if [ -e /etc/rabbitmq/definitions.json ]; then sed -i -e "s/REPLACE_USERNAME/${RABBITMQ_DEFAULT_USER}/g" \ -e "s/REPLACE_PASSWORD/${RABBITMQ_DEFAULT_PASS}/g" \ diff --git a/images/rabbitmq/definitions.json b/images/rabbitmq/definitions.json index b73523212d..70d291a22a 100644 --- a/images/rabbitmq/definitions.json +++ b/images/rabbitmq/definitions.json @@ -9,6 +9,6 @@ { "user": "REPLACE_USERNAME", "vhost": "/", "configure": ".*", "write": ".*", "read": ".*" } ], "policies":[ - {"vhost":"/","name":"lagoon-ha","pattern":"REPLACE_QUEUE_PATTERN", "definition":{"ha-mode":"all","ha-sync-mode":"automatic","ha-sync-batch-size":5}} + {"vhost":"/","name":"lagoon-ha","pattern":"REPLACE_QUEUE_PATTERN", "definition":{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic","ha-sync-batch-size":5}} ] } diff --git a/services/broker/.lagoon.app.yml b/services/broker/.lagoon.app.yml index 403f715140..f08fb57337 100644 --- a/services/broker/.lagoon.app.yml +++ b/services/broker/.lagoon.app.yml @@ -120,6 +120,8 @@ objects: key: RABBITMQ_PASSWORD - name: RABBITMQ_USE_LONGNAME value: "true" + - name: RABBITMQ_DEFAULT_HA_PATTERN + value: "^lagoon-" - name: POD_NAMESPACE valueFrom: fieldRef: From a80cc5783ac6b802bfb69c78d180067f3fa682eb Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Fri, 6 Sep 2019 10:54:08 +0200 Subject: [PATCH 03/15] Update Dockerfile Use of COPY for consistence in Dockerfile Changed RABBITMQ_DEFAULT_HA_PATTERN default value --- images/rabbitmq/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images/rabbitmq/Dockerfile b/images/rabbitmq/Dockerfile index 6acc38e5b6..d5ab906683 100644 --- a/images/rabbitmq/Dockerfile +++ b/images/rabbitmq/Dockerfile @@ -5,7 +5,7 @@ ENV LAGOON_VERSION=$LAGOON_VERSION ENV RABBITMQ_DEFAULT_USER=guest \ RABBITMQ_DEFAULT_PASS="guest"\ - RABBITMQ_DEFAULT_HA_PATTERN='^lagoon-' + RABBITMQ_DEFAULT_HA_PATTERN='^$' COPY rabbitmq_delayed_message_exchange-3.7.0.ez /plugins @@ -16,7 +16,7 @@ COPY definitions.json /etc/rabbitmq/definitions.json RUN chgrp 0 /etc/rabbitmq/definitions.json; chmod g+rw /etc/rabbitmq/definitions.json # Copy a custom entrypoint -ADD cluster-rabbit.sh / +COPY cluster-rabbit.sh / RUN chgrp 0 /cluster-rabbit.sh; chmod +x /cluster-rabbit.sh ENTRYPOINT /cluster-rabbit.sh From 644f46b5af9481aeac5af84069413744c8ebf5e0 Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Fri, 6 Sep 2019 11:25:03 +0200 Subject: [PATCH 04/15] Added REPLACE_VHOST replace patter for vhosts variable --- images/rabbitmq/definitions.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/images/rabbitmq/definitions.json b/images/rabbitmq/definitions.json index 70d291a22a..4dddbbfa40 100644 --- a/images/rabbitmq/definitions.json +++ b/images/rabbitmq/definitions.json @@ -1,14 +1,14 @@ { "vhosts":[ - {"name": "/"} + {"name": "REPLACE_VHOST"} ], "users": [ { "name": "REPLACE_USERNAME", "password": "REPLACE_PASSWORD", "tags": "administrator" } ], "permissions":[ - { "user": "REPLACE_USERNAME", "vhost": "/", "configure": ".*", "write": ".*", "read": ".*" } + { "user": "REPLACE_USERNAME", "vhost": "REPLACE_VHOST", "configure": ".*", "write": ".*", "read": ".*" } ], "policies":[ - {"vhost":"/","name":"lagoon-ha","pattern":"REPLACE_QUEUE_PATTERN", "definition":{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic","ha-sync-batch-size":5}} + {"vhost":"REPLACE_VHOST","name":"lagoon-ha","pattern":"REPLACE_QUEUE_PATTERN", "definition":{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic","ha-sync-batch-size":5}} ] } From 6bd16526aac9d8df6d0d9e29b475ab47db459135 Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Fri, 6 Sep 2019 13:17:04 +0200 Subject: [PATCH 05/15] New ENV variables logic Added RABBITMQ_DEFAULT_VHOST variable Added envplate binary to substitute variables --- images/rabbitmq/Dockerfile | 8 +++++++- images/rabbitmq/cluster-rabbit.sh | 4 +--- images/rabbitmq/definitions.json | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/images/rabbitmq/Dockerfile b/images/rabbitmq/Dockerfile index d5ab906683..c8f69bf1e9 100644 --- a/images/rabbitmq/Dockerfile +++ b/images/rabbitmq/Dockerfile @@ -5,8 +5,14 @@ ENV LAGOON_VERSION=$LAGOON_VERSION ENV RABBITMQ_DEFAULT_USER=guest \ RABBITMQ_DEFAULT_PASS="guest"\ - RABBITMQ_DEFAULT_HA_PATTERN='^$' + RABBITMQ_DEFAULT_HA_PATTERN='^$'\ + RABBITMQ_DEFAULT_VHOST='/' +RUN apt-get -y update \ + && apt-get -y install curl \ + && curl -sLo /bin/ep https://github.com/kreuzwerker/envplate/releases/download/1.0.0-RC1/ep-linux \ + && echo "48e234e067874a57a4d4bb198b5558d483ee37bcc285287fffb3864818b42f2785be0568faacbc054e97ca1c5047ec70382e1ca0e71182c9dba06649ad83a5f6 /bin/ep" | sha512sum -c \ + && chmod +x /bin/ep COPY rabbitmq_delayed_message_exchange-3.7.0.ez /plugins RUN rabbitmq-plugins enable --offline rabbitmq_delayed_message_exchange; diff --git a/images/rabbitmq/cluster-rabbit.sh b/images/rabbitmq/cluster-rabbit.sh index 2826068a86..202e8969c9 100644 --- a/images/rabbitmq/cluster-rabbit.sh +++ b/images/rabbitmq/cluster-rabbit.sh @@ -2,9 +2,7 @@ # Replace placeholders with ENV values and copy file to rabbitmq conf directory from ConfigMap if [ -e /etc/rabbitmq/definitions.json ]; then - sed -i -e "s/REPLACE_USERNAME/${RABBITMQ_DEFAULT_USER}/g" \ - -e "s/REPLACE_PASSWORD/${RABBITMQ_DEFAULT_PASS}/g" \ - -e "s/REPLACE_QUEUE_PATTERN/${RABBITMQ_DEFAULT_HA_PATTERN}/g" /etc/rabbitmq/definitions.json + /bin/ep /etc/rabbitmq/definitions.json fi # start the server diff --git a/images/rabbitmq/definitions.json b/images/rabbitmq/definitions.json index 4dddbbfa40..30214fb57e 100644 --- a/images/rabbitmq/definitions.json +++ b/images/rabbitmq/definitions.json @@ -1,14 +1,14 @@ { "vhosts":[ - {"name": "REPLACE_VHOST"} + {"name": "${RABBITMQ_DEFAULT_VHOST}"} ], "users": [ - { "name": "REPLACE_USERNAME", "password": "REPLACE_PASSWORD", "tags": "administrator" } + { "name": "${RABBITMQ_DEFAULT_USER}", "password": "${RABBITMQ_DEFAULT_PASS}", "tags": "administrator" } ], "permissions":[ - { "user": "REPLACE_USERNAME", "vhost": "REPLACE_VHOST", "configure": ".*", "write": ".*", "read": ".*" } + { "user": "${RABBITMQ_DEFAULT_USER}", "vhost": "${RABBITMQ_DEFAULT_VHOST}", "configure": ".*", "write": ".*", "read": ".*" } ], "policies":[ - {"vhost":"REPLACE_VHOST","name":"lagoon-ha","pattern":"REPLACE_QUEUE_PATTERN", "definition":{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic","ha-sync-batch-size":5}} + {"vhost":"${RABBITMQ_DEFAULT_VHOST}","name":"lagoon-ha","pattern":"${RABBITMQ_DEFAULT_HA_PATTERN}", "definition":{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic","ha-sync-batch-size":5}} ] } From dc5d8aad5eaabd7db0f0d63f3e9ba79750e6e53f Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Fri, 6 Sep 2019 13:53:28 +0200 Subject: [PATCH 06/15] RabbitMQ image consistent ENTRYPOINT Same ENTRYPOINT for rabbitmq and rabbitmq-cluster images Defined ENV variables for Lagoon broker service --- images/rabbitmq-cluster/Dockerfile | 3 --- images/rabbitmq-cluster/cluster-rabbit.sh | 24 ----------------------- images/rabbitmq/cluster-rabbit.sh | 16 ++++++++++++++- services/broker/.lagoon.app.yml | 2 -- services/broker/Dockerfile | 2 ++ 5 files changed, 17 insertions(+), 30 deletions(-) delete mode 100644 images/rabbitmq-cluster/cluster-rabbit.sh diff --git a/images/rabbitmq-cluster/Dockerfile b/images/rabbitmq-cluster/Dockerfile index b75c5887ec..c76178dbb3 100644 --- a/images/rabbitmq-cluster/Dockerfile +++ b/images/rabbitmq-cluster/Dockerfile @@ -9,6 +9,3 @@ ADD rabbitmq.conf /etc/rabbitmq/rabbitmq.conf RUN chgrp 0 /etc/rabbitmq/rabbitmq.conf; chmod g+rw /etc/rabbitmq/rabbitmq.conf ENV RABBITMQ_ERLANG_COOKIE=5188fd99edf19acfefcbb29a16f3d373aa01f66bfe89929852dfad2674d36af2 - -# this is only used in the cluster version -ADD cluster-rabbit.sh / diff --git a/images/rabbitmq-cluster/cluster-rabbit.sh b/images/rabbitmq-cluster/cluster-rabbit.sh deleted file mode 100644 index e875ebafd2..0000000000 --- a/images/rabbitmq-cluster/cluster-rabbit.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - - -# Check if the container runs in Kubernetes/OpenShift -if [ -z "$POD_NAMESPACE" ]; then - # Single container runs in docker - echo "POD_NAMESPACE not set, spin up single node" - exec docker-entrypoint.sh rabbitmq-server -fi - -# clustering uses full hostnames, generate those -echo NODENAME=rabbit@${HOSTNAME}.${SERVICE_NAME}-headless.${POD_NAMESPACE}.svc.cluster.local > /etc/rabbitmq/rabbitmq-env.conf -echo cluster_formation.k8s.hostname_suffix=.${SERVICE_NAME}-headless.${POD_NAMESPACE}.svc.cluster.local >> /etc/rabbitmq/rabbitmq.conf -echo cluster_formation.k8s.service_name=${SERVICE_NAME}-headless >> /etc/rabbitmq/rabbitmq.conf - -# Replace placeholders with ENV values and copy file to rabbitmq conf directory -if [ -e /etc/rabbitmq/definitions.json ]; then - sed -i -e "s/REPLACE_USERNAME/${RABBITMQ_DEFAULT_USER}/g" \ - -e "s/REPLACE_PASSWORD/${RABBITMQ_DEFAULT_PASS}/g" \ - -e "s/REPLACE_QUEUE_PATTERN/${RABBITMQ_DEFAULT_HA_PATTERN}/g" /etc/rabbitmq/definitions.json -fi - -# start the server -docker-entrypoint.sh rabbitmq-server diff --git a/images/rabbitmq/cluster-rabbit.sh b/images/rabbitmq/cluster-rabbit.sh index 202e8969c9..c2f73562d3 100644 --- a/images/rabbitmq/cluster-rabbit.sh +++ b/images/rabbitmq/cluster-rabbit.sh @@ -1,9 +1,23 @@ #!/bin/sh -# Replace placeholders with ENV values and copy file to rabbitmq conf directory from ConfigMap + +# Replace ENV values in definitions.json if [ -e /etc/rabbitmq/definitions.json ]; then /bin/ep /etc/rabbitmq/definitions.json fi +# Check if the container runs in Kubernetes/OpenShift +if [ -z "$POD_NAMESPACE" ]; then + # Single container runs in docker + echo "POD_NAMESPACE not set, spin up single node" + exec docker-entrypoint.sh rabbitmq-server +fi + +# clustering uses full hostnames, generate those +echo NODENAME=rabbit@${HOSTNAME}.${SERVICE_NAME}-headless.${POD_NAMESPACE}.svc.cluster.local > /etc/rabbitmq/rabbitmq-env.conf +echo cluster_formation.k8s.hostname_suffix=.${SERVICE_NAME}-headless.${POD_NAMESPACE}.svc.cluster.local >> /etc/rabbitmq/rabbitmq.conf +echo cluster_formation.k8s.service_name=${SERVICE_NAME}-headless >> /etc/rabbitmq/rabbitmq.conf + + # start the server docker-entrypoint.sh rabbitmq-server diff --git a/services/broker/.lagoon.app.yml b/services/broker/.lagoon.app.yml index f08fb57337..403f715140 100644 --- a/services/broker/.lagoon.app.yml +++ b/services/broker/.lagoon.app.yml @@ -120,8 +120,6 @@ objects: key: RABBITMQ_PASSWORD - name: RABBITMQ_USE_LONGNAME value: "true" - - name: RABBITMQ_DEFAULT_HA_PATTERN - value: "^lagoon-" - name: POD_NAMESPACE valueFrom: fieldRef: diff --git a/services/broker/Dockerfile b/services/broker/Dockerfile index aa687d0667..318a4cb917 100644 --- a/services/broker/Dockerfile +++ b/services/broker/Dockerfile @@ -1,2 +1,4 @@ ARG IMAGE_REPO FROM ${IMAGE_REPO:-lagoon}/rabbitmq-cluster +ENV RABBITMQ_DEFAULT_HA_PATTERN='^lagoon-'\ + RABBITMQ_DEFAULT_VHOST='/' From a75127cbf58c302a9ffccc505552b1f91584151d Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Fri, 6 Sep 2019 15:27:14 +0200 Subject: [PATCH 07/15] Protect variables with single ticks and copy /bin/ep from commons --- images/rabbitmq/Dockerfile | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/images/rabbitmq/Dockerfile b/images/rabbitmq/Dockerfile index c8f69bf1e9..1d19d57e0e 100644 --- a/images/rabbitmq/Dockerfile +++ b/images/rabbitmq/Dockerfile @@ -1,18 +1,15 @@ +FROM ${IMAGE_REPO:-lagoon}/commons as commons FROM rabbitmq:3-management ARG LAGOON_VERSION ENV LAGOON_VERSION=$LAGOON_VERSION -ENV RABBITMQ_DEFAULT_USER=guest \ - RABBITMQ_DEFAULT_PASS="guest"\ +ENV RABBITMQ_DEFAULT_USER='guest' \ + RABBITMQ_DEFAULT_PASS='guest'\ RABBITMQ_DEFAULT_HA_PATTERN='^$'\ RABBITMQ_DEFAULT_VHOST='/' -RUN apt-get -y update \ - && apt-get -y install curl \ - && curl -sLo /bin/ep https://github.com/kreuzwerker/envplate/releases/download/1.0.0-RC1/ep-linux \ - && echo "48e234e067874a57a4d4bb198b5558d483ee37bcc285287fffb3864818b42f2785be0568faacbc054e97ca1c5047ec70382e1ca0e71182c9dba06649ad83a5f6 /bin/ep" | sha512sum -c \ - && chmod +x /bin/ep +COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/ COPY rabbitmq_delayed_message_exchange-3.7.0.ez /plugins RUN rabbitmq-plugins enable --offline rabbitmq_delayed_message_exchange; From 5df283d8176e5a4deb10f1f34ec26a2da69a6e50 Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Fri, 6 Sep 2019 15:50:08 +0200 Subject: [PATCH 08/15] Removed RABBITMQ_DEFAULT_VHOST variable (keep default value) --- services/broker/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/broker/Dockerfile b/services/broker/Dockerfile index 318a4cb917..ea40fe5bd7 100644 --- a/services/broker/Dockerfile +++ b/services/broker/Dockerfile @@ -1,4 +1,3 @@ ARG IMAGE_REPO FROM ${IMAGE_REPO:-lagoon}/rabbitmq-cluster -ENV RABBITMQ_DEFAULT_HA_PATTERN='^lagoon-'\ - RABBITMQ_DEFAULT_VHOST='/' +ENV RABBITMQ_DEFAULT_HA_PATTERN='^lagoon-' From 91e204f6c7b6c1d3dac5e1bc359d2e41370d750a Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Fri, 6 Sep 2019 15:59:42 +0200 Subject: [PATCH 09/15] Removed unused binaries --- images/rabbitmq/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/rabbitmq/Dockerfile b/images/rabbitmq/Dockerfile index 1d19d57e0e..8c2b87106e 100644 --- a/images/rabbitmq/Dockerfile +++ b/images/rabbitmq/Dockerfile @@ -9,7 +9,7 @@ ENV RABBITMQ_DEFAULT_USER='guest' \ RABBITMQ_DEFAULT_HA_PATTERN='^$'\ RABBITMQ_DEFAULT_VHOST='/' -COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/ +COPY --from=commons /bin/ep /bin/ COPY rabbitmq_delayed_message_exchange-3.7.0.ez /plugins RUN rabbitmq-plugins enable --offline rabbitmq_delayed_message_exchange; From d4fc1ddedf0712439827fcaaa493e930faee07d7 Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Fri, 6 Sep 2019 16:55:08 +0200 Subject: [PATCH 10/15] Added fix-permissions binary --- images/rabbitmq/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images/rabbitmq/Dockerfile b/images/rabbitmq/Dockerfile index 8c2b87106e..1fe518c185 100644 --- a/images/rabbitmq/Dockerfile +++ b/images/rabbitmq/Dockerfile @@ -9,14 +9,14 @@ ENV RABBITMQ_DEFAULT_USER='guest' \ RABBITMQ_DEFAULT_HA_PATTERN='^$'\ RABBITMQ_DEFAULT_VHOST='/' -COPY --from=commons /bin/ep /bin/ +COPY --from=commons /bin/ep /bin/fix-permissions /bin/ COPY rabbitmq_delayed_message_exchange-3.7.0.ez /plugins RUN rabbitmq-plugins enable --offline rabbitmq_delayed_message_exchange; # Copy startup schema with vhost, users, permissions and policies COPY definitions.json /etc/rabbitmq/definitions.json -RUN chgrp 0 /etc/rabbitmq/definitions.json; chmod g+rw /etc/rabbitmq/definitions.json +RUN fix-permissions /etc/rabbitmq/definitions.json # Copy a custom entrypoint COPY cluster-rabbit.sh / From 69b5c5d73b72e24b617cc35a28e9c8b923aa5830 Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Fri, 6 Sep 2019 18:05:35 +0200 Subject: [PATCH 11/15] Run fix-permissions instead of chgrp and chown --- images/rabbitmq-cluster/Dockerfile | 2 +- images/rabbitmq/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/images/rabbitmq-cluster/Dockerfile b/images/rabbitmq-cluster/Dockerfile index c76178dbb3..e1750ceb81 100644 --- a/images/rabbitmq-cluster/Dockerfile +++ b/images/rabbitmq-cluster/Dockerfile @@ -6,6 +6,6 @@ RUN rabbitmq-plugins --offline enable rabbitmq_peer_discovery_k8s ADD enabled_plugins /etc/rabbitmq/enabled_plugins ADD rabbitmq.conf /etc/rabbitmq/rabbitmq.conf -RUN chgrp 0 /etc/rabbitmq/rabbitmq.conf; chmod g+rw /etc/rabbitmq/rabbitmq.conf +RUN fix-permissions /etc/rabbitmq/rabbitmq.conf ENV RABBITMQ_ERLANG_COOKIE=5188fd99edf19acfefcbb29a16f3d373aa01f66bfe89929852dfad2674d36af2 diff --git a/images/rabbitmq/Dockerfile b/images/rabbitmq/Dockerfile index 1fe518c185..88d520b756 100644 --- a/images/rabbitmq/Dockerfile +++ b/images/rabbitmq/Dockerfile @@ -20,6 +20,6 @@ RUN fix-permissions /etc/rabbitmq/definitions.json # Copy a custom entrypoint COPY cluster-rabbit.sh / -RUN chgrp 0 /cluster-rabbit.sh; chmod +x /cluster-rabbit.sh +RUN fix-permissions /cluster-rabbit.sh; chmod +x /cluster-rabbit.sh ENTRYPOINT /cluster-rabbit.sh From 080f80d6954e18a99e053a3aa45cf53f088b2db1 Mon Sep 17 00:00:00 2001 From: Michael Schmid Date: Sat, 7 Sep 2019 01:52:31 -0700 Subject: [PATCH 12/15] Update images/rabbitmq/Dockerfile --- images/rabbitmq/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/rabbitmq/Dockerfile b/images/rabbitmq/Dockerfile index 88d520b756..9f1912dc78 100644 --- a/images/rabbitmq/Dockerfile +++ b/images/rabbitmq/Dockerfile @@ -20,6 +20,6 @@ RUN fix-permissions /etc/rabbitmq/definitions.json # Copy a custom entrypoint COPY cluster-rabbit.sh / -RUN fix-permissions /cluster-rabbit.sh; chmod +x /cluster-rabbit.sh +RUN fix-permissions /cluster-rabbit.sh && chmod +x /cluster-rabbit.sh ENTRYPOINT /cluster-rabbit.sh From ace564a3c4098e5d3373ee95b9c7f8485d804e35 Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Mon, 9 Sep 2019 16:26:57 +0200 Subject: [PATCH 13/15] Added RabbitMQ image documentation --- docs/using_lagoon/docker_images/rabbitmq.md | 34 +++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 35 insertions(+) create mode 100644 docs/using_lagoon/docker_images/rabbitmq.md diff --git a/docs/using_lagoon/docker_images/rabbitmq.md b/docs/using_lagoon/docker_images/rabbitmq.md new file mode 100644 index 0000000000..d9bdbca3c6 --- /dev/null +++ b/docs/using_lagoon/docker_images/rabbitmq.md @@ -0,0 +1,34 @@ +# rabbitmq Image +amazee.io RabbitMQ Dockerfile with management plugin installed, based on the official rabbitmq:3-management image at [docker-hub](https://hub.docker.com/_/rabbitmq). + +This Dockerfile is intended to be used to setup a standalone RabbitMQ queue broker as well as base image to setup a cluster with HA queues support by default ([Mirrored queues](https://www.rabbitmq.com/ha.html)). +By default the RabbitMQ broker is started as single node. If you want to start a cluster, you need to use the [`rabbitmq-cluster`](https://github.com/amazeeio/lagoon/blob/master/images/rabbitmq-cluster/Dockerfile) Docker image, based on `rabbitmq` image plus the `rabbitmq_peer_discovery_k8s` plugin. + +## amazee.io & OpenShift adaptions +This image is prepared to be used on amazee.io which leverages OpenShift. There are therefore some things already done: + +- Folder permissions are automatically adapted with [`fix-permissions`](https://github.com/sclorg/s2i-base-container/blob/master/core/root/usr/bin/fix-permissions) so this image will work with a random user and therefore also on OpenShift. +- The file `/etc/rabbitmq/definitions.json` is parsed through [envplate](https://github.com/kreuzwerker/envplate) with an container-entrypoint. + +## Included RabbitMQ default schema (definitions.json) +To enable the support for Mirrored Queues, at least one [`policy`](https://www.rabbitmq.com/parameters.html#policies) must exists. +Into the `definitions.json` schema file, are definied the minimal entities to let the container running: virtualhost (vhost), username and password to access management UI, permissions and policies. + +By default a policy called `lagoon-ha` is created at startup but it is not active because it doesn't match any queue's name pattern (see default [Environment Variables](#environment-variables)). +``` +"policies":[ + {"vhost":"${RABBITMQ_DEFAULT_VHOST}","name":"lagoon-ha","pattern":"${RABBITMQ_DEFAULT_HA_PATTERN}", "definition":{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic","ha-sync-batch-size":5}} + ] +``` +By default, the `ha-mode` is set to `exactly` which controls the exact number of mirroring nodes for a queue (mirrors). The number of nodes, is controller by `ha-params`. +For furhter and custom configuration, please refer to [official RabbitMQ documentation](https://www.rabbitmq.com/ha.html). + +## Environment Variables +Environment variables defined in RabbitMQ base image + +| Environment Variable | Default | Description | +| --------------------------------- | --------- | ---------------------------------------------- | +| `RABBITMQ_DEFAULT_USER` | guest | Username for management UI access | +| `RABBITMQ_DEFAULT_PASS` | guest | Password for management UI access | +| `RABBITMQ_DEFAULT_VHOST` | / | RabbitMQ main virtualhost| +| `RABBITMQ_DEFAULT_HA_PATTERN` | ^$ | Regular expression to match for mirrored queues| diff --git a/mkdocs.yml b/mkdocs.yml index 8c1c9e21ec..a0bb270422 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -17,6 +17,7 @@ pages: - Docker Images: - PHP-FPM: using_lagoon/docker_images/php-fpm.md - Nginx: using_lagoon/docker_images/nginx.md + - RabbitMQ: using_lagoon/docker_images/rabbitmq.md - Workflows: using_lagoon/workflows.md - Backups: using_lagoon/backups.md - Logging: using_lagoon/logging.md From 8644f4bd36162a671dd8572d4fbb7c2b2a2d29f7 Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Mon, 9 Sep 2019 17:24:49 +0200 Subject: [PATCH 14/15] Fix typos and amazee.io references --- docs/using_lagoon/docker_images/rabbitmq.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/using_lagoon/docker_images/rabbitmq.md b/docs/using_lagoon/docker_images/rabbitmq.md index d9bdbca3c6..e82a02ff7a 100644 --- a/docs/using_lagoon/docker_images/rabbitmq.md +++ b/docs/using_lagoon/docker_images/rabbitmq.md @@ -1,11 +1,11 @@ # rabbitmq Image -amazee.io RabbitMQ Dockerfile with management plugin installed, based on the official rabbitmq:3-management image at [docker-hub](https://hub.docker.com/_/rabbitmq). +Lagoon RabbitMQ Dockerfile with management plugin installed, based on the official rabbitmq:3-management image at [docker-hub](https://hub.docker.com/_/rabbitmq). This Dockerfile is intended to be used to setup a standalone RabbitMQ queue broker as well as base image to setup a cluster with HA queues support by default ([Mirrored queues](https://www.rabbitmq.com/ha.html)). By default the RabbitMQ broker is started as single node. If you want to start a cluster, you need to use the [`rabbitmq-cluster`](https://github.com/amazeeio/lagoon/blob/master/images/rabbitmq-cluster/Dockerfile) Docker image, based on `rabbitmq` image plus the `rabbitmq_peer_discovery_k8s` plugin. -## amazee.io & OpenShift adaptions -This image is prepared to be used on amazee.io which leverages OpenShift. There are therefore some things already done: +## Lagoon & OpenShift adaptions +This image is prepared to be used on Lagoon which leverages OpenShift. There are therefore some things already done: - Folder permissions are automatically adapted with [`fix-permissions`](https://github.com/sclorg/s2i-base-container/blob/master/core/root/usr/bin/fix-permissions) so this image will work with a random user and therefore also on OpenShift. - The file `/etc/rabbitmq/definitions.json` is parsed through [envplate](https://github.com/kreuzwerker/envplate) with an container-entrypoint. @@ -21,7 +21,7 @@ By default a policy called `lagoon-ha` is created at startup but it is not activ ] ``` By default, the `ha-mode` is set to `exactly` which controls the exact number of mirroring nodes for a queue (mirrors). The number of nodes, is controller by `ha-params`. -For furhter and custom configuration, please refer to [official RabbitMQ documentation](https://www.rabbitmq.com/ha.html). +For further and custom configuration, please refer to [official RabbitMQ documentation](https://www.rabbitmq.com/ha.html). ## Environment Variables Environment variables defined in RabbitMQ base image From 1b578162f04fee78bc07d1460f800abab4eb69d9 Mon Sep 17 00:00:00 2001 From: Vincenzo De Naro Papa Date: Mon, 23 Sep 2019 21:46:33 +0200 Subject: [PATCH 15/15] Added `ARG IMAGE_REPO` to fix image test --- images/rabbitmq/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/images/rabbitmq/Dockerfile b/images/rabbitmq/Dockerfile index 9f1912dc78..e7c13f8166 100644 --- a/images/rabbitmq/Dockerfile +++ b/images/rabbitmq/Dockerfile @@ -1,3 +1,4 @@ +ARG IMAGE_REPO FROM ${IMAGE_REPO:-lagoon}/commons as commons FROM rabbitmq:3-management