You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When configured this way, the node has to be registered manually or using another mechanism,
136
-
e.g. by a container orchestrator such as [Nomad](https://developer.hashicorp.com/nomad/integrations/hashicorp/rabbitmq) or [Kubernetes](https://www.rabbitmq.com/kubernetes/operator/operator-overview).
136
+
e.g. by a container orchestrator such as [Nomad](https://developer.hashicorp.com/nomad/integrations/hashicorp/rabbitmq).
137
137
138
138
If peer discovery isn't configured, or it [repeatedly fails](#discovery-retries),
139
139
or no peers are reachable, a node that wasn't a cluster member in the past
### Important: Prerequisites and Deployment Considerations
465
+
:::tip
479
466
480
-
:::important
481
-
The recommended option for deploying RabbitMQ to Kubernetes is the [RabbitMQ Kubernetes Cluster Operator](/kubernetes/operator/operator-overview).
467
+
In most cases you don't need to worry about peer discovery, when deploying to Kubernetes.
482
468
483
-
It follows the recommendations listed below.
469
+
[Cluster Operator](/kubernetes/operator/operator-overview) (the recommended way of deploying to Kubernetes)
470
+
as well as popular Helm charts, pre-configure peer discovery for you.
484
471
:::
485
472
486
-
With this mechanism, nodes fetch a list of their peers from
487
-
a Kubernetes API endpoint using a set of configured values:
488
-
a URI scheme, host, port, as well as the token and certificate paths.
489
-
490
-
If the recommended option of the [RabbitMQ Kubernetes Cluster Operator](/kubernetes/operator/operator-overview) cannot be used,
491
-
there are several prerequisites and deployment choices that must be taken into
492
-
account when deploying RabbitMQ to Kubernetes, with this peer discovery mechanism
493
-
and in general.
494
-
495
-
#### Use a Stateful Set
496
-
497
-
A RabbitMQ cluster deployed to Kubernetes will use a set of pods. The set must be a [stateful set](https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/#statefulset).
498
-
A [headless service](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#limitations) must be used to
499
-
control [network identity of the pods](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/)
500
-
(their hostnames), which in turn affect RabbitMQ node names.
501
-
On the headless service `spec`, field `publishNotReadyAddresses` must be set to `true` to propagate SRV DNS records for its Pods for the purpose of peer discovery.
502
-
503
-
In addition, since RabbitMQ nodes [resolve their own and peer hostnames during boot](./clustering#hostname-resolution-requirement),
504
-
CoreDNS [caching timeout may need to be decreased](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id) from default 30 seconds
505
-
to a value in the 5-10 second range.
506
-
507
-
:::important
508
-
509
-
CoreDNS [caching timeout may need to be decreased](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id)
510
-
from default 30 seconds to a value in the 5-10 second range
511
-
512
-
:::
513
-
514
-
If a stateless set is used recreated nodes will not have their persisted data and will start as blank nodes.
515
-
This can lead to data loss and higher network traffic volume due to more frequent
516
-
data synchronisation of both [quorum queues](./quorum-queues)
517
-
and [streams](./streams) on newly joining nodes.
518
-
519
-
#### Use Persistent Volumes
520
-
521
-
How [storage is configured](https://kubernetes.io/docs/concepts/storage/persistent-volumes/)
522
-
is generally orthogonal to peer discovery. However, it does not make sense to run a stateful
523
-
data service such as RabbitMQ with [node data directory](./relocate) stored on a transient volume.
524
-
Use of transient volumes can lead nodes to not have their persisted data after a restart.
525
-
This has the same consequences as with stateless sets covered above.
526
-
527
-
#### Make Sure `/etc/rabbitmq` is Mounted as Writeable
528
-
529
-
RabbitMQ nodes and images may need to update a file under `/etc/rabbitmq`, the default [configuration file location](./configure#config-location) on Linux. This may involve configuration file generation
530
-
performed by the image used, [enabled plugins file](./plugins#enabled-plugins-file) updates,
531
-
and so on.
532
-
533
-
It is therefore highly recommended that `/etc/rabbitmq` is mounted as writeable and owned by
534
-
RabbitMQ's effective user (typically `rabbitmq`).
535
-
536
-
#### Use Parallel podManagementPolicy
537
-
538
-
`podManagementPolicy: "Parallel"` is the recommended option for RabbitMQ clusters.
539
-
540
-
Because of [how nodes rejoin their cluster](./clustering#restarting), `podManagementPolicy` set to `OrderedReady`
541
-
can lead to a deployment deadlock with certain readiness probes:
542
-
543
-
* Kubernetes will expect the first node to pass a readiness probe
544
-
* The readiness probe may require a fully booted node
545
-
* The node will fully boot after it detects that its peers have come online
546
-
* Kubernetes will not start any more pods until the first one boots
547
-
* The deployment therefore is deadlocked
548
-
549
-
`podManagementPolicy: "Parallel"` avoids this problem, and the Kubernetes peer discovery plugin
550
-
then deals with the [natural race condition present during parallel cluster formation](#initial-formation-race-condition).
551
-
552
-
553
-
#### Use Most Basic Health Checks for RabbitMQ Pod Readiness Probes
554
-
555
-
A readiness probe that expects the node to be fully booted and have rejoined its cluster peers
556
-
can deadlock a deployment that restarts all RabbitMQ pods and relies on the `OrderedReady` pod management policy.
557
-
Deployments that use the `Parallel` pod management policy
558
-
will not be affected.
559
-
560
-
One health check that does not expect a node to be fully booted and have schema tables synced is
561
-
562
-
```bash
563
-
# a very basic check that will succeed for the nodes that are currently waiting for
564
-
# a peer to sync schema from
565
-
rabbitmq-diagnostics ping
566
-
```
567
-
568
-
This basic check would allow the deployment to proceed and the nodes to eventually rejoin each other,
569
-
assuming they are [compatible](./upgrade).
570
-
571
-
See [Schema Syncing from Online Peers](./clustering#restarting-schema-sync) in the [Clustering guide](./clustering).
473
+
### Kubernetes Peer Discovery Overview
572
474
475
+
A [Kubernetes](https://kubernetes.io/)-based discovery mechanism
476
+
is available via [a plugin](https://github.com/rabbitmq/rabbitmq-server/tree/main/deps/rabbitmq_peer_discovery_k8s).
573
477
574
-
### Examples
478
+
Since peer discovery happens early during node boot, you should add `rabbitmq_peer_discovery_k8s` to the
If you use [a different ordinal start value in your StatefulSet](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#ordinal-index),
496
+
you have to configure this plugin to use it:
610
497
```
611
-
612
-
#### Kubernetes API Access Token
613
-
614
-
Kubernetes token file path is configurable via `cluster_formation.k8s.token_path`:
Supported values are `ip` or `hostname`. `hostname` is
690
-
the recommended option but has limitations: it can only be used with [stateful sets](https://kubernetes.io/docs/tasks/run-application/run-replicated-stateful-application/#statefulset) (also highly recommended)
691
-
and [headless services](https://kubernetes.io/docs/concepts/services-networking/service/#headless-services).
692
-
`ip` is used by default for better compatibility.
693
-
694
-
##### Peer Node Pod Name Suffix
695
-
696
-
It is possible to append a suffix to peer hostnames returned by Kubernetes using
0 commit comments