2018-06-11 20:33:18 +00:00
|
|
|
package consul
|
2017-02-01 00:43:57 +00:00
|
|
|
|
|
|
|
import (
|
2017-08-07 22:54:05 +00:00
|
|
|
"github.com/hashicorp/nomad/command/agent/consul"
|
2019-11-27 21:41:45 +00:00
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
2017-02-01 00:43:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ConsulServiceAPI is the interface the Nomad Client uses to register and
|
2020-03-30 19:26:48 +00:00
|
|
|
// remove services and checks from Consul.
|
2020-03-27 20:07:55 +00:00
|
|
|
//
|
|
|
|
// ACL requirements
|
|
|
|
// - service:write
|
2017-02-01 00:43:57 +00:00
|
|
|
type ConsulServiceAPI interface {
|
2019-11-27 21:41:45 +00:00
|
|
|
// RegisterWorkload with Consul. Adds all service entries and checks to Consul.
|
2019-11-18 18:04:01 +00:00
|
|
|
RegisterWorkload(*consul.WorkloadServices) error
|
2019-11-27 21:41:45 +00:00
|
|
|
|
|
|
|
// RemoveWorkload from Consul. Removes all service entries and checks.
|
2019-11-18 18:04:01 +00:00
|
|
|
RemoveWorkload(*consul.WorkloadServices)
|
2019-11-27 21:41:45 +00:00
|
|
|
|
|
|
|
// UpdateWorkload in Consul. Does not alter the service if only checks have
|
|
|
|
// changed.
|
2019-11-18 18:04:01 +00:00
|
|
|
UpdateWorkload(old, newTask *consul.WorkloadServices) error
|
2019-11-27 21:41:45 +00:00
|
|
|
|
|
|
|
// AllocRegistrations returns the registrations for the given allocation.
|
2017-08-07 22:54:05 +00:00
|
|
|
AllocRegistrations(allocID string) (*consul.AllocRegistration, error)
|
2019-11-27 21:41:45 +00:00
|
|
|
|
|
|
|
// UpdateTTL is used to update the TTL of a check.
|
2021-03-16 18:22:21 +00:00
|
|
|
UpdateTTL(id, namespace, output, status string) error
|
2017-02-01 00:43:57 +00:00
|
|
|
}
|
2019-11-27 21:41:45 +00:00
|
|
|
|
|
|
|
// TokenDeriverFunc takes an allocation and a set of tasks and derives a
|
|
|
|
// service identity token for each. Requests go through nomad server.
|
|
|
|
type TokenDeriverFunc func(*structs.Allocation, []string) (map[string]string, error)
|
|
|
|
|
|
|
|
// ServiceIdentityAPI is the interface the Nomad Client uses to request Consul
|
|
|
|
// Service Identity tokens through Nomad Server.
|
2020-03-27 20:07:55 +00:00
|
|
|
//
|
|
|
|
// ACL requirements
|
|
|
|
// - acl:write (used by Server only)
|
2019-11-27 21:41:45 +00:00
|
|
|
type ServiceIdentityAPI interface {
|
|
|
|
// DeriveSITokens contacts the nomad server and requests consul service
|
|
|
|
// identity tokens be generated for tasks in the allocation.
|
|
|
|
DeriveSITokens(alloc *structs.Allocation, tasks []string) (map[string]string, error)
|
|
|
|
}
|
2020-09-04 17:50:11 +00:00
|
|
|
|
|
|
|
// SupportedProxiesAPI is the interface the Nomad Client uses to request from
|
|
|
|
// Consul the set of supported proxied to use for Consul Connect.
|
|
|
|
//
|
|
|
|
// No ACL requirements
|
|
|
|
type SupportedProxiesAPI interface {
|
|
|
|
Proxies() (map[string][]string, error)
|
|
|
|
}
|