Making Nomad register services with consul in dev mode
This commit is contained in:
parent
439d7bf326
commit
df9d256132
|
@ -411,7 +411,8 @@ func (c *ConsulService) performSync() error {
|
|||
func (c *ConsulService) filterConsulServices(srvcs map[string]*consul.AgentService) map[string]*consul.AgentService {
|
||||
nomadServices := make(map[string]*consul.AgentService)
|
||||
for _, srv := range srvcs {
|
||||
if strings.HasPrefix(srv.ID, structs.NomadConsulPrefix) {
|
||||
if strings.HasPrefix(srv.ID, structs.NomadConsulPrefix) &&
|
||||
!strings.HasPrefix(srv.ID, fmt.Sprintf("%s-%s", structs.NomadConsulPrefix, "agent")) {
|
||||
nomadServices[srv.ID] = srv
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,8 @@ func NewAgent(config *Config, logOutput io.Writer) (*Agent, error) {
|
|||
}
|
||||
if err := a.syncAgentServicesWithConsul(a.serverHTTPAddr, a.clientHTTPAddr); err != nil {
|
||||
a.logger.Printf("[ERR] agent: unable to sync agent services with consul: %v", err)
|
||||
} else {
|
||||
}
|
||||
if a.consulService != nil {
|
||||
go a.consulService.PeriodicSync()
|
||||
}
|
||||
return a, nil
|
||||
|
|
|
@ -140,6 +140,10 @@ type ConsulConfig struct {
|
|||
// clients with Consul
|
||||
ClientServiceName string `mapstructure:"client_service_name"`
|
||||
|
||||
// AutoRegister determines if Nomad will register the Nomad client and
|
||||
// server agents with Consul
|
||||
AutoRegister bool `mapstructure:"auto_register"`
|
||||
|
||||
// Addr is the address of the local Consul agent
|
||||
Addr string `mapstructure:"addr"`
|
||||
|
||||
|
@ -419,6 +423,11 @@ func DefaultConfig() *Config {
|
|||
Addresses: &Addresses{},
|
||||
AdvertiseAddrs: &AdvertiseAddrs{},
|
||||
Atlas: &AtlasConfig{},
|
||||
ConsulConfig: &ConsulConfig{
|
||||
ServerServiceName: "nomad-server",
|
||||
ClientServiceName: "nomad-client",
|
||||
AutoRegister: true,
|
||||
},
|
||||
Client: &ClientConfig{
|
||||
Enabled: false,
|
||||
NetworkSpeed: 100,
|
||||
|
|
Loading…
Reference in a new issue