U1.55 Ubuntu Quick Start (QS): RabbitMQ Kubernetes infrastructure with Topology Operator. - chempkovsky/CS2WPF-and-CS2XAMARIN Wiki

We start with

RabbitMQ cluster name and Namespace

API Reference

Virtual Host

Queues

Policies

Exchanges and Bindings

Users and User Permissions

We start with

RabbitMQ cluster name and Namespace

API Reference

Virtual Host

Create Virtual Host

kubectl apply -f- <<EOF
apiVersion: rabbitmq.com/v1beta1
kind: Vhost
metadata:
  name: rbmq-tst-clstr-vhost-mtdt
  namespace: rbmq-tst-clstr-nmspc
spec:
  name: rbmq-tst-clstr-vhost
  rabbitmqClusterReference:
    name: rbmq-tst-clstr
EOF

Get a list of Virtual Hosts

[email protected]:~$ kubectl get vhost -n  rbmq-tst-clstr-nmspc
NAME                        AGE
rbmq-tst-clstr-vhost-mtdt   55s

Delete Virtual Host

kubectl delete -f- <<EOF
apiVersion: rabbitmq.com/v1beta1
kind: Vhost
metadata:
  name: rbmq-tst-clstr-vhost-mtdt
  namespace: rbmq-tst-clstr-nmspc
spec:
  name: rbmq-tst-clstr-vhost
  rabbitmqClusterReference:
    name: rbmq-tst-clstr
EOF

Virtual Host Limits

rabbitmqctl set_vhost_limits -p vhost_name '{"max-connections": 256}'
rabbitmqctl set_vhost_limits -p vhost_name '{"max-queues": 1024}'
Install krew which is unuseful
(
  set -x; cd "$(mktemp -d)" &&
  OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
  ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
  KREW="krew-${OS}_${ARCH}" &&
  curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
  tar zxvf "${KREW}.tar.gz" &&
  ./"${KREW}" install krew
)
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
Install RabbitMQ Cluster Operator Plugin
kubectl krew install rabbitmq
Get cluster info with a Plugin
[email protected]:~$ kubectl rabbitmq -n rbmq-tst-clstr-nmspc get rbmq-tst-clstr
NAME                          READY   STATUS    RESTARTS   AGE
pod/rbmq-tst-clstr-server-0   1/1     Running   0          18h
pod/rbmq-tst-clstr-server-1   1/1     Running   0          18h

NAME                                    DATA   AGE
configmap/rbmq-tst-clstr-plugins-conf   1      18h
configmap/rbmq-tst-clstr-server-conf    2      18h

NAME                                     READY   AGE
statefulset.apps/rbmq-tst-clstr-server   2/2     18h

NAME                           TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                        AGE
service/rbmq-tst-clstr         ClusterIP   10.107.160.237   <none>        5672/TCP,15672/TCP,15692/TCP   18h
service/rbmq-tst-clstr-nodes   ClusterIP   None             <none>        4369/TCP,25672/TCP             18h

NAME                                  TYPE     DATA   AGE
secret/rbmq-tst-clstr-default-user    Opaque   7      18h
secret/rbmq-tst-clstr-erlang-cookie   Opaque   1      18h
Set Virtual Host Limits
kubectl rabbitmq -n rbmq-tst-clstr-nmspc set_vhost_limits rbmq-tst-clstr '{"max-connections": -1, "max-queues": -1}'
Management UI which is useful
kubectl exec which is useful
[email protected]:~$ kubectl exec --stdin --tty rbmq-tst-clstr-server-0 -n rbmq-tst-clstr-nmspc -- /bin/bash
Defaulted container "rabbitmq" out of: rabbitmq, setup-container (init)

[email protected]:/$ rabbitmqctl set_vhost_limits -p rbmq-tst-clstr-vhost '{"max-connections": 256}'
Setting vhost limits to "{"max-connections": 256}" for vhost "rbmq-tst-clstr-vhost" ...

[email protected]:/$ rabbitmqctl set_vhost_limits -p rbmq-tst-clstr-vhost '{"max-queues": 100}'
Setting vhost limits to "{"max-queues": 100}" for vhost "rbmq-tst-clstr-vhost" ...

[email protected]:/$ rabbitmqctl set_vhost_limits -p rbmq-tst-clstr-vhost '{"max-connections": 25, "max-queues": 30}'
Setting vhost limits to "{"max-connections": 25, "max-queues": 30}" for vhost "rbmq-tst-clstr-vhost" ...

[email protected]:/$ exit
exit
[email protected]:~$ kubectl exec --stdin --tty rbmq-tst-clstr-server-0 -n rbmq-tst-clstr-nmspc -- /bin/bash
Defaulted container "rabbitmq" out of: rabbitmq, setup-container (init)
[email protected]:/$ rabbitmqctl add_vhost testvhost
Adding vhost "testvhost" ...
[email protected]:/$ exit
exit
[email protected]:~$ kubectl get vhost -n  rbmq-tst-clstr-nmspc
NAME                        AGE
rbmq-tst-clstr-vhost-mtdt   16h

Queues

Create Queue

kubectl apply -f- <<EOF
apiVersion: rabbitmq.com/v1beta1
kind: Queue
metadata:
  name: rbmq-tst-clstr-queue-mtdt
  namespace: rbmq-tst-clstr-nmspc
spec:
  name: rbmq-tst-clstr-queue
  type: classic
  vhost: rbmq-tst-clstr-vhost
  autoDelete: false
  durable: true
  rabbitmqClusterReference:
    name: rbmq-tst-clstr
EOF

Get a list of Queues

[email protected]:~$ kubectl get queues -n rbmq-tst-clstr-nmspc
NAME                        AGE
rbmq-tst-clstr-queue-mtdt   5m52s

Delete Queue

kubectl delete -f- <<EOF
apiVersion: rabbitmq.com/v1beta1
kind: Queue
metadata:
  name: rbmq-tst-clstr-queue-mtdt
  namespace: rbmq-tst-clstr-nmspc
spec:
  name: rbmq-tst-clstr-queue
  type: classic
  vhost: rbmq-tst-clstr-vhost
  autoDelete: false
  durable: true
  rabbitmqClusterReference:
    name: rbmq-tst-clstr
EOF

Policies

Create Policy

kubectl apply -f- <<EOF
apiVersion: rabbitmq.com/v1beta1
kind: Policy
metadata:
  name: rbmq-tst-clstr-queue-policy-mtdt
  namespace: rbmq-tst-clstr-nmspc
spec:
  name: rbmq-tst-clstr-queue-policy
  vhost: rbmq-tst-clstr-vhost
  pattern: "=rbmq-tst-clstr-queue"
  applyTo: "queues"
  definition:
    max-length: 100
  rabbitmqClusterReference:
    name: rbmq-tst-clstr
EOF

Get a list of Policies

[email protected]:~$ kubectl get policy -n  rbmq-tst-clstr-nmspc
NAME                               AGE
rbmq-tst-clstr-queue-policy-mtdt   22m

Delete Policy

kubectl delete -f- <<EOF
apiVersion: rabbitmq.com/v1beta1
kind: Policy
metadata:
  name: rbmq-tst-clstr-queue-policy-mtdt
  namespace: rbmq-tst-clstr-nmspc
spec:
  name: rbmq-tst-clstr-queue-policy
  vhost: rbmq-tst-clstr-vhost
  pattern: "=rbmq-tst-clstr-queue"
  applyTo: "queues"
  definition:
    max-length: 100
  rabbitmqClusterReference:
    name: rbmq-tst-clstr
EOF

Available Policies

Exchanges and Bindings

Users and User Permissions