Содержание

RabbitMQ

https://www.rabbitmq.com/

k8s

Helm Bitnami - https://github.com/bitnami/charts/tree/master/bitnami/rabbitmq

Показать конфигурацию:

kubectl exec dvs-rabbitmq-0 -- cat /bitnami/rabbitmq/conf/rabbitmq.conf
kubectl exec dvs-rabbitmq-0 -- cat /app/load_definition.json

или из secrets:

kubectl get secret dvs-rabbitmq-config -o json | jq -r '.data."rabbitmq.conf" | @base64d'
kubectl get secret load-definition -o json | jq -r '.data."load_definition.json" | @base64d'

Обновить RabbitMQ (на примере до 4.1.0) через Operator:

kubectl -n ${NAMESPACE} patch RabbitmqCluster/dvs-rabbitmq -p '{"spec":{"image":"docker.io/bitnami/rabbitmq:4.1.0-debian-12-r0"}}' --type=merge

Удалить все crd:

kubectl delete crd $(kubectl api-resources --api-group=rabbitmq.com -o name)

ha

https://www.rabbitmq.com/ha.html

rabbitmqctl

https://www.rabbitmq.com/rabbitmqctl.8.html

Показать политики:

rabbitmqctl list_policies

Показать плагины:

rabbitmq-plugins list

Credentials & Passwords

https://www.rabbitmq.com/passwords.html

Создать пароль в rabbit_password_hashing:

Нажмите, чтобы отобразить

Нажмите, чтобы скрыть

#!/bin/bash
 
function encode_password_256()
{
    SALT=$(od -A n -t x -N 4 /dev/urandom)
    PASS=$SALT$(echo -n $1 | xxd -ps | tr -d '\n' | tr -d ' ')
    PASS=$(echo -n $PASS | xxd -r -p | sha256sum | head -c 128)
    PASS=$(echo -n $SALT$PASS | xxd -r -p | base64 | tr -d '\n')
    echo $PASS
}
function encode_password_512()
{
    SALT=$(od -A n -t x -N 4 /dev/urandom)
    PASS=$SALT$(echo -n $1 | xxd -ps | tr -d '\n' | tr -d ' ')
    PASS=$(echo -n $PASS | xxd -r -p | sha512sum | head -c 128)
    PASS=$(echo -n $SALT$PASS | xxd -r -p | base64 | tr -d '\n')
    echo $PASS
}
 
encode_password_256 "some-password"
encode_password_512 "some-password"


Проблемы

Error while waiting for Mnesia tables

Решение: Запустить с --set clustering.forceBoot=true (переменная RABBITMQ_FORCE_BOOT=yes). После обновить в k8s c PDB=true.

https://www.rabbitmq.com/rabbitmqctl.8.html#force_boot
https://stackoverflow.com/questions/60407082/rabbit-mq-error-while-waiting-for-mnesia-tables

failed to delete user/permission/policy

После удаления:

kubectl describe user.rabbitmq.com/${USER} -n ${NAMESPACE}
kubectl describe permission.rabbitmq.com/${USER} -n ${NAMESPACE}
kubectl describe policy.rabbitmq.com/${POLICY} -n ${NAMESPACE}
Events:
Type     Reason        Age                From             Message
----     ------        ----               ----             -------
Warning  FailedDelete  16m (x5 over 66m)  user-controller  failed to delete user
Warning  FailedDelete  2m5s (x11 over 140m)  permission-controller  failed to delete permission
Normal  SuccessfulDelete  5m6s (x10 over 138m)  policy-controller  successfully deleted policy

При обновлении helm:
Error: UPGRADE FAILED: an error occurred while rolling back the release. original upgrade error:
cannot patch «${USER}» with kind Permission: Internal error occurred: failed calling webhook «vpermission.kb.io»: failed to call webhook: Post «https://rmqco-rabbitmq-messaging-topology-operator-webhook.dev.svc:443/validate-rabbitmq-com-v1beta1-permission?timeout=10s»: service «rmqco-rabbitmq-messaging-topology-operator-webhook» not found
&& cannot patch «${POLICY}» with kind Policy: Internal error occurred: failed calling webhook «vpolicy.kb.io»: failed to call webhook: Post «https://rmqco-rabbitmq-messaging-topology-operator-webhook.dev.svc:443/validate-rabbitmq-com-v1beta1-policy?timeout=10s»: service «rmqco-rabbitmq-messaging-topology-operator-webhook» not found
&& cannot patch «${USER}» with kind User: Internal error occurred: failed calling webhook «vuser.kb.io»: failed to call webhook: Post «https://rmqco-rabbitmq-messaging-topology-operator-webhook.dev.svc:443/validate-rabbitmq-com-v1beta1-user?timeout=10s»: service «rmqco-rabbitmq-messaging-topology-operator-webhook» not found

Решение: Переустановить и удалить в окружении на которое указывает ошибка.

Удаление через finalizer (не работает)

Удаление через finalizer (не работает)

kubectl delete --force crd permissions.rabbitmq.com | kubectl patch crd/permissions.rabbitmq.com -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl delete --force crd users.rabbitmq.com | kubectl patch crd/users.rabbitmq.com -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl delete --force crd policies.rabbitmq.com | kubectl patch crd/policies.rabbitmq.com -p '{"metadata":{"finalizers":[]}}' --type=merge