Jika Anda memiliki banyak cluster consul dengan banyak datacenter yang berbeda. Anda mungkin tidak punya banyak waktu untuk memonitor health service pada setiap cluster dengan WebUI consul.
Agar efisien waktu, Anda dapat membuat koneksi peer pada nodes di cluster consul yang berbeda lalu export service agar dapat dimonitor pada satu WebUI consul.
Create a peering token #
Generate token pada consule server. Nantinya consul server ini akan digunakan untuk monitoring service pada node client di datacenter yang berbeda.
consul peering generate-token -name nova-2
Pada -name gunakan hostname yang dapat resolve ke ip node client {: .prompt-info }
Simpan output token untuk digunakan pada node client.
Establish a connection between clusters #
Selanjutnya pada node client buat koneksi peering dengan perintah
consul peering establish -name control-1 -peering-token [token]
Jika berhasil terhubung pada node server atau control-1
status peer akan aktif

Export services between clusters #
Untuk export service pada node client. Buat file peer.hcl
lalu tambahkan konfig berikut.
Kind = "exported-services"
Name = "default"
Services = [
{
## The name and namespace of the service to export.
Name = "webserver"
Namespace = "default"
## The list of peer clusters to export the service to.
Consumers = [
{
## The peer name to reference in config is the one set
## during the peering process.
Peer = "control-1"
}
]
}
]
Tambahkan konfigurasi ke dalam cluster.
consul config write peer.hcl
Buka WebUI consul pada node control-1
dan cek bagian service akan muncul service yang ada di node client atau nova-2
.
