add advertise grpc address option

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2019-10-07 13:52:47 -04:00
parent 4bc08c92c2
commit f18d19aeb5
No known key found for this signature in database
GPG key ID: A519480096146526
5 changed files with 22 additions and 15 deletions

View file

@ -5,5 +5,3 @@ auto-elects in the event of a current master failure. Non-node peers are also s
can only access the network but do not provide routing capabilities.
![Heimdall](docs/overview.png)
#

View file

@ -60,6 +60,12 @@ func main() {
Value: fmt.Sprintf("tcp://%s:%d", heimdall.GetIP(), defaultGRPCPort),
EnvVar: "HEIMDALL_GRPC_ADDR",
},
cli.StringFlag{
Name: "advertise-grpc-address",
Usage: "public advertise grpc address",
Value: fmt.Sprintf("tcp://%s:%d", heimdall.GetIP(), defaultGRPCPort),
EnvVar: "HEIMDALL_ADVERTISE_GRPC_ADDR",
},
cli.StringFlag{
Name: "redis-url, r",
Usage: "uri for datastore backend",

View file

@ -41,17 +41,18 @@ import (
func runServer(cx *cli.Context) error {
cfg := &heimdall.Config{
ID: cx.String("id"),
GRPCAddress: cx.String("addr"),
GRPCPeerAddress: cx.String("peer"),
ClusterKey: cx.String("cluster-key"),
NodeNetwork: cx.String("node-network"),
PeerNetwork: cx.String("peer-network"),
EndpointIP: cx.String("endpoint-ip"),
EndpointPort: cx.Int("endpoint-port"),
InterfaceName: cx.String("interface-name"),
RedisURL: cx.String("redis-url"),
AdvertiseRedisURL: cx.String("advertise-redis-url"),
ID: cx.String("id"),
GRPCAddress: cx.String("addr"),
AdvertiseGRPCAddress: cx.String("advertise-grpc-address"),
GRPCPeerAddress: cx.String("peer"),
ClusterKey: cx.String("cluster-key"),
NodeNetwork: cx.String("node-network"),
PeerNetwork: cx.String("peer-network"),
EndpointIP: cx.String("endpoint-ip"),
EndpointPort: cx.Int("endpoint-port"),
InterfaceName: cx.String("interface-name"),
RedisURL: cx.String("redis-url"),
AdvertiseRedisURL: cx.String("advertise-redis-url"),
}
errCh := make(chan error, 1)

View file

@ -29,6 +29,8 @@ type Config struct {
ID string
// GRPCAddress is the address for the grpc server
GRPCAddress string
// AdvertiseGRPCAddress is the public address for the grpc server
AdvertiseGRPCAddress string
// GRPCPeerAddress is the peer address to join
GRPCPeerAddress string
// ClusterKey is a preshared key for cluster peers

View file

@ -99,7 +99,7 @@ func (s *Server) configureNode() error {
return err
}
// ignore self
if node.Addr == s.cfg.GRPCAddress {
if node.ID == s.cfg.ID {
continue
}
@ -277,7 +277,7 @@ func (s *Server) updateMasterInfo(ctx context.Context) error {
}
m := &v1.Master{
ID: s.cfg.ID,
GRPCAddress: s.cfg.GRPCAddress,
GRPCAddress: s.cfg.AdvertiseGRPCAddress,
RedisURL: s.cfg.AdvertiseRedisURL,
}
data, err := proto.Marshal(m)