Advertise Raft on the Fully Qualified Domain Name
Distributed Services with Go — by Travis Jeffery (77 / 84)
👈 Configure and Deploy Your Service with Helm | TOC | What You Learned 👉
Currently, we configure Raft’s address as the transport’s local address, and the server will advertise its address as ::8400. We want to use the fully qualified domain name instead so the node will properly advertise itself to its cluster and to its clients.
In internal/log/config.go, change your Config to this:
DeployLocally/internal/log/config.go
type Config struct {
Raft struct {
raft.Config
» BindAddr string
StreamLayer *StreamLayer
Bootstrap bool
}
Segment struct {
MaxStoreBytes uint64
MaxIndexBytes uint64
InitialOffset uint64
}
}
Change your DistributedLog’s bootstrap code to use the configured bind address:
DeployLocally/internal/log/distributed.go
if l.config.Raft.Bootstrap && !hasState {
config := raft.Configuration{
Servers: []raft.Server{{
ID: config.LocalID,
» Address: raft.ServerAddress(l.config.Raft.BindAddr),
}},
}
err = l.raft.BootstrapCluster(config).Error()…