Some checks failed
Build Helm Chart / helm-package (push) Failing after 30s
Rename artemis-broker to artemis-broker-primary This commit renames and refactors the Helm chart for the artemis-broker. The original files in the artemis-broker directory are renamed and moved to artemis-broker-primary. The purpose of this change is to enable a clear distinction between the primary broker configuration and any backup or alternative configurations. Additionally, the configuration has been updated to support enhancements in TLS setup, metrics services, and users, allowing for a more robust and flexible deployment. This change introduces new templates and scripts needed for managing various aspects of the broker's functions, including improved user authentication and logging. No breaking changes were introduced, but users must update their references to the chart paths as they now point to the new directory structure. ```
76 lines
2.4 KiB
Bash
Executable File
76 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
export BROKER_IP=`hostname -f`
|
|
|
|
instanceDir="${HOME}/${AMQ_NAME}"
|
|
|
|
ENDPOINT_NAME="${HEADLESS_ENDPOINT}"
|
|
if [ "$HEADLESS_SVC_NAME" ]; then
|
|
ENDPOINT_NAME=$HEADLESS_SVC_NAME
|
|
fi
|
|
|
|
endpointsUrl="https://${KUBERNETES_SERVICE_HOST:-kubernetes.default.svc}:${KUBERNETES_SERVICE_PORT:-443}/api/v1/namespaces/${POD_NAMESPACE}/"
|
|
endpointsAuth="Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"
|
|
|
|
function waitForJolokia() {
|
|
while : ;
|
|
do
|
|
sleep 5
|
|
curl -s -o /dev/null -G -k http://${AMQ_USER}:${AMQ_PASSWORD}@${BROKER_IP}:8161/console/jolokia
|
|
if [ $? -eq 0 ]; then
|
|
break
|
|
fi
|
|
done
|
|
}
|
|
|
|
|
|
endpointsCode=$(curl -s -o /dev/null -w "%{http_code}" -G -k -H "${endpointsAuth}" ${endpointsUrl})
|
|
if [ $endpointsCode -ne 200 ]; then
|
|
echo "Can't find endpoints with ips status <${endpointsCode}>"
|
|
exit 1
|
|
fi
|
|
|
|
ENDPOINTS=$(curl -s -X GET -G -k -H "${endpointsAuth}" ${endpointsUrl}"endpoints/${ENDPOINT_NAME}")
|
|
echo $ENDPOINTS
|
|
count=0
|
|
while [ 1 ]; do
|
|
ip=$(echo $ENDPOINTS | python -c "import sys, json; print json.load(sys.stdin)['subsets'][0]['addresses'][${count}]['ip']")
|
|
if [ $? -ne 0 ]; then
|
|
echo "Can't find ip to scale down to tried ${count} ips"
|
|
exit
|
|
fi
|
|
|
|
echo "got ip ${ip} broker ip is ${BROKER_IP}"
|
|
if [ "$ip" != "$BROKER_IP" ]; then
|
|
break
|
|
fi
|
|
|
|
count=$(( count + 1 ))
|
|
done
|
|
|
|
source /opt/amq/bin/launch.sh nostart
|
|
|
|
SCALE_TO_BROKER_IP=$ip
|
|
|
|
# Add connector to the pod to scale down to
|
|
connector="<connector name=\"scaledownconnector\">tcp:\/\/${SCALE_TO_BROKER_IP}:61616<\/connector>"
|
|
sed -i "/<\/connectors>/ s/.*/${connector}\n&/" ${instanceDir}/etc/broker.xml
|
|
|
|
# Remove the acceptors
|
|
#sed -i -ne "/<acceptors>/ {p; " -e ":a; n; /<\/acceptors>/ {p; b}; ba}; p" ${instanceDir}/etc/broker.xml
|
|
acceptor="<acceptor name=\"artemis\">tcp:\/\/${BROKER_IP}:61616?protocols=CORE<\/acceptor>"
|
|
sed -i -ne "/<acceptors>/ {p; i $acceptor" -e ":a; n; /<\/acceptors>/ {p; b}; ba}; p" ${instanceDir}/etc/broker.xml
|
|
|
|
#start the broker and issue the scaledown command to drain the messages.
|
|
${instanceDir}/bin/artemis-service start
|
|
|
|
if [ "$AMQ_DATA_DIR_LOGGING" = "true" ]; then
|
|
tail -n 100 -f ${AMQ_DATA_DIR}/log/artemis.log &
|
|
else
|
|
tail -n 100 -f ${AMQ_NAME}/log/artemis.log &
|
|
fi
|
|
|
|
waitForJolokia
|
|
curl -s -o /dev/null -G -k http://${AMQ_USER}:${AMQ_PASSWORD}@${BROKER_IP}:8161/console/jolokia/exec/org.apache.activemq.artemis:broker=%22${AMQ_NAME}%22/scaleDown/scaledownconnector
|
|
|