2017-09-25 18:40:42 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hashicorp/hcl"
|
|
|
|
"github.com/mitchellh/mapstructure"
|
2020-10-05 20:28:13 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/consul/lib/decode"
|
2017-09-25 18:40:42 +00:00
|
|
|
)
|
|
|
|
|
2020-08-10 16:46:28 +00:00
|
|
|
// Source parses configuration from some source.
|
|
|
|
type Source interface {
|
|
|
|
// Source returns an identifier for the Source that can be used in error message
|
|
|
|
Source() string
|
|
|
|
// Parse a configuration and return the result.
|
|
|
|
Parse() (Config, mapstructure.Metadata, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ErrNoData indicates to Builder.Build that the source contained no data, and
|
|
|
|
// it can be skipped.
|
|
|
|
var ErrNoData = fmt.Errorf("config source contained no data")
|
|
|
|
|
|
|
|
// FileSource implements Source and parses a config from a file.
|
|
|
|
type FileSource struct {
|
2017-09-25 18:40:42 +00:00
|
|
|
Name string
|
|
|
|
Format string
|
|
|
|
Data string
|
|
|
|
}
|
|
|
|
|
2020-08-10 16:46:28 +00:00
|
|
|
func (f FileSource) Source() string {
|
|
|
|
return f.Name
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse a config file in either JSON or HCL format.
|
|
|
|
func (f FileSource) Parse() (Config, mapstructure.Metadata, error) {
|
|
|
|
if f.Name == "" || f.Data == "" {
|
|
|
|
return Config{}, mapstructure.Metadata{}, ErrNoData
|
|
|
|
}
|
|
|
|
|
2017-09-25 18:40:42 +00:00
|
|
|
var raw map[string]interface{}
|
2020-08-10 16:46:28 +00:00
|
|
|
var err error
|
|
|
|
var md mapstructure.Metadata
|
|
|
|
switch f.Format {
|
2017-09-25 18:40:42 +00:00
|
|
|
case "json":
|
2020-08-10 16:46:28 +00:00
|
|
|
err = json.Unmarshal([]byte(f.Data), &raw)
|
2017-09-25 18:40:42 +00:00
|
|
|
case "hcl":
|
2020-08-10 16:46:28 +00:00
|
|
|
err = hcl.Decode(&raw, f.Data)
|
2017-09-25 18:40:42 +00:00
|
|
|
default:
|
2020-08-10 16:46:28 +00:00
|
|
|
err = fmt.Errorf("invalid format: %s", f.Format)
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
if err != nil {
|
2020-08-10 16:46:28 +00:00
|
|
|
return Config{}, md, err
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-10 16:46:28 +00:00
|
|
|
var c Config
|
2017-09-25 18:40:42 +00:00
|
|
|
d, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
2020-05-27 17:02:22 +00:00
|
|
|
DecodeHook: mapstructure.ComposeDecodeHookFunc(
|
|
|
|
// decode.HookWeakDecodeFromSlice is only necessary when reading from
|
|
|
|
// an HCL config file. In the future we could omit it when reading from
|
|
|
|
// JSON configs. It is left here for now to maintain backwards compat
|
|
|
|
// for the unlikely scenario that someone is using malformed JSON configs
|
|
|
|
// and expecting this behaviour to correct their config.
|
|
|
|
decode.HookWeakDecodeFromSlice,
|
|
|
|
decode.HookTranslateKeys,
|
|
|
|
),
|
|
|
|
Metadata: &md,
|
|
|
|
Result: &c,
|
2017-09-25 18:40:42 +00:00
|
|
|
})
|
|
|
|
if err != nil {
|
2020-08-10 16:46:28 +00:00
|
|
|
return Config{}, md, err
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
2020-05-27 17:02:22 +00:00
|
|
|
if err := d.Decode(raw); err != nil {
|
2020-08-10 16:46:28 +00:00
|
|
|
return Config{}, md, err
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
2019-07-12 17:20:30 +00:00
|
|
|
|
2020-05-29 21:16:03 +00:00
|
|
|
return c, md, nil
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
2020-08-10 17:03:33 +00:00
|
|
|
// LiteralSource implements Source and returns an existing Config struct.
|
|
|
|
type LiteralSource struct {
|
|
|
|
Name string
|
|
|
|
Config Config
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l LiteralSource) Source() string {
|
|
|
|
return l.Name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (l LiteralSource) Parse() (Config, mapstructure.Metadata, error) {
|
|
|
|
return l.Config, mapstructure.Metadata{}, nil
|
|
|
|
}
|
|
|
|
|
2020-10-05 21:31:35 +00:00
|
|
|
// Cache configuration for the agent/cache.
|
2020-07-27 21:11:11 +00:00
|
|
|
type Cache struct {
|
|
|
|
// EntryFetchMaxBurst max burst size of RateLimit for a single cache entry
|
2020-11-20 22:48:39 +00:00
|
|
|
EntryFetchMaxBurst *int `mapstructure:"entry_fetch_max_burst"`
|
2020-07-27 21:11:11 +00:00
|
|
|
// EntryFetchRate represents the max calls/sec for a single cache entry
|
2020-11-20 22:48:39 +00:00
|
|
|
EntryFetchRate *float64 `mapstructure:"entry_fetch_rate"`
|
2020-07-27 21:11:11 +00:00
|
|
|
}
|
|
|
|
|
2017-09-25 18:40:42 +00:00
|
|
|
// Config defines the format of a configuration file in either JSON or
|
|
|
|
// HCL format.
|
|
|
|
//
|
|
|
|
// It must contain only pointer values, slices and maps to support
|
|
|
|
// standardized merging of multiple Config structs into one.
|
|
|
|
//
|
|
|
|
// Since this is the format which users use to specify their
|
|
|
|
// configuration it should be treated as an external API which cannot be
|
|
|
|
// changed and refactored at will since this will break existing setups.
|
|
|
|
type Config struct {
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLAgentMasterToken *string `mapstructure:"acl_agent_master_token"`
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLAgentToken *string `mapstructure:"acl_agent_token"`
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved to "primary_datacenter"
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLDatacenter *string `mapstructure:"acl_datacenter"`
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLDefaultPolicy *string `mapstructure:"acl_default_policy"`
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLDownPolicy *string `mapstructure:"acl_down_policy"`
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLEnableKeyListPolicy *bool `mapstructure:"acl_enable_key_list_policy"`
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLMasterToken *string `mapstructure:"acl_master_token"`
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLReplicationToken *string `mapstructure:"acl_replication_token"`
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLTTL *string `mapstructure:"acl_ttl"`
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLToken *string `mapstructure:"acl_token"`
|
|
|
|
ACL ACL `mapstructure:"acl"`
|
|
|
|
Addresses Addresses `mapstructure:"addresses"`
|
|
|
|
AdvertiseAddrLAN *string `mapstructure:"advertise_addr"`
|
|
|
|
AdvertiseAddrLANIPv4 *string `mapstructure:"advertise_addr_ipv4"`
|
|
|
|
AdvertiseAddrLANIPv6 *string `mapstructure:"advertise_addr_ipv6"`
|
|
|
|
AdvertiseAddrWAN *string `mapstructure:"advertise_addr_wan"`
|
|
|
|
AdvertiseAddrWANIPv4 *string `mapstructure:"advertise_addr_wan_ipv4"`
|
2021-03-09 13:56:44 +00:00
|
|
|
AdvertiseAddrWANIPv6 *string `mapstructure:"advertise_addr_wan_ipv6"`
|
2020-11-20 22:48:39 +00:00
|
|
|
AdvertiseReconnectTimeout *string `mapstructure:"advertise_reconnect_timeout"`
|
|
|
|
AutoConfig AutoConfigRaw `mapstructure:"auto_config"`
|
|
|
|
Autopilot Autopilot `mapstructure:"autopilot"`
|
|
|
|
BindAddr *string `mapstructure:"bind_addr"`
|
|
|
|
Bootstrap *bool `mapstructure:"bootstrap"`
|
|
|
|
BootstrapExpect *int `mapstructure:"bootstrap_expect"`
|
|
|
|
Cache Cache `mapstructure:"cache"`
|
|
|
|
CAFile *string `mapstructure:"ca_file"`
|
|
|
|
CAPath *string `mapstructure:"ca_path"`
|
|
|
|
CertFile *string `mapstructure:"cert_file"`
|
|
|
|
Check *CheckDefinition `mapstructure:"check"` // needs to be a pointer to avoid partial merges
|
|
|
|
CheckOutputMaxSize *int `mapstructure:"check_output_max_size"`
|
|
|
|
CheckUpdateInterval *string `mapstructure:"check_update_interval"`
|
|
|
|
Checks []CheckDefinition `mapstructure:"checks"`
|
|
|
|
ClientAddr *string `mapstructure:"client_addr"`
|
|
|
|
ConfigEntries ConfigEntries `mapstructure:"config_entries"`
|
|
|
|
AutoEncrypt AutoEncrypt `mapstructure:"auto_encrypt"`
|
|
|
|
Connect Connect `mapstructure:"connect"`
|
|
|
|
DNS DNS `mapstructure:"dns_config"`
|
|
|
|
DNSDomain *string `mapstructure:"domain"`
|
|
|
|
DNSAltDomain *string `mapstructure:"alt_domain"`
|
|
|
|
DNSRecursors []string `mapstructure:"recursors"`
|
|
|
|
DataDir *string `mapstructure:"data_dir"`
|
|
|
|
Datacenter *string `mapstructure:"datacenter"`
|
|
|
|
DefaultQueryTime *string `mapstructure:"default_query_time"`
|
|
|
|
DisableAnonymousSignature *bool `mapstructure:"disable_anonymous_signature"`
|
|
|
|
DisableCoordinates *bool `mapstructure:"disable_coordinates"`
|
|
|
|
DisableHostNodeID *bool `mapstructure:"disable_host_node_id"`
|
|
|
|
DisableHTTPUnprintableCharFilter *bool `mapstructure:"disable_http_unprintable_char_filter"`
|
|
|
|
DisableKeyringFile *bool `mapstructure:"disable_keyring_file"`
|
|
|
|
DisableRemoteExec *bool `mapstructure:"disable_remote_exec"`
|
|
|
|
DisableUpdateCheck *bool `mapstructure:"disable_update_check"`
|
|
|
|
DiscardCheckOutput *bool `mapstructure:"discard_check_output"`
|
|
|
|
DiscoveryMaxStale *string `mapstructure:"discovery_max_stale"`
|
|
|
|
EnableACLReplication *bool `mapstructure:"enable_acl_replication"`
|
|
|
|
EnableAgentTLSForChecks *bool `mapstructure:"enable_agent_tls_for_checks"`
|
|
|
|
EnableCentralServiceConfig *bool `mapstructure:"enable_central_service_config"`
|
|
|
|
EnableDebug *bool `mapstructure:"enable_debug"`
|
|
|
|
EnableScriptChecks *bool `mapstructure:"enable_script_checks"`
|
|
|
|
EnableLocalScriptChecks *bool `mapstructure:"enable_local_script_checks"`
|
|
|
|
EnableSyslog *bool `mapstructure:"enable_syslog"`
|
|
|
|
EncryptKey *string `mapstructure:"encrypt"`
|
|
|
|
EncryptVerifyIncoming *bool `mapstructure:"encrypt_verify_incoming"`
|
|
|
|
EncryptVerifyOutgoing *bool `mapstructure:"encrypt_verify_outgoing"`
|
|
|
|
GossipLAN GossipLANConfig `mapstructure:"gossip_lan"`
|
|
|
|
GossipWAN GossipWANConfig `mapstructure:"gossip_wan"`
|
|
|
|
HTTPConfig HTTPConfig `mapstructure:"http_config"`
|
|
|
|
KeyFile *string `mapstructure:"key_file"`
|
|
|
|
LeaveOnTerm *bool `mapstructure:"leave_on_terminate"`
|
|
|
|
Limits Limits `mapstructure:"limits"`
|
|
|
|
LogLevel *string `mapstructure:"log_level"`
|
|
|
|
LogJSON *bool `mapstructure:"log_json"`
|
|
|
|
LogFile *string `mapstructure:"log_file"`
|
|
|
|
LogRotateDuration *string `mapstructure:"log_rotate_duration"`
|
|
|
|
LogRotateBytes *int `mapstructure:"log_rotate_bytes"`
|
|
|
|
LogRotateMaxFiles *int `mapstructure:"log_rotate_max_files"`
|
|
|
|
MaxQueryTime *string `mapstructure:"max_query_time"`
|
|
|
|
NodeID *string `mapstructure:"node_id"`
|
|
|
|
NodeMeta map[string]string `mapstructure:"node_meta"`
|
|
|
|
NodeName *string `mapstructure:"node_name"`
|
|
|
|
Performance Performance `mapstructure:"performance"`
|
|
|
|
PidFile *string `mapstructure:"pid_file"`
|
|
|
|
Ports Ports `mapstructure:"ports"`
|
|
|
|
PrimaryDatacenter *string `mapstructure:"primary_datacenter"`
|
|
|
|
PrimaryGateways []string `mapstructure:"primary_gateways"`
|
|
|
|
PrimaryGatewaysInterval *string `mapstructure:"primary_gateways_interval"`
|
|
|
|
RPCProtocol *int `mapstructure:"protocol"`
|
|
|
|
RaftProtocol *int `mapstructure:"raft_protocol"`
|
|
|
|
RaftSnapshotThreshold *int `mapstructure:"raft_snapshot_threshold"`
|
|
|
|
RaftSnapshotInterval *string `mapstructure:"raft_snapshot_interval"`
|
|
|
|
RaftTrailingLogs *int `mapstructure:"raft_trailing_logs"`
|
|
|
|
ReconnectTimeoutLAN *string `mapstructure:"reconnect_timeout"`
|
|
|
|
ReconnectTimeoutWAN *string `mapstructure:"reconnect_timeout_wan"`
|
|
|
|
RejoinAfterLeave *bool `mapstructure:"rejoin_after_leave"`
|
|
|
|
RetryJoinIntervalLAN *string `mapstructure:"retry_interval"`
|
|
|
|
RetryJoinIntervalWAN *string `mapstructure:"retry_interval_wan"`
|
|
|
|
RetryJoinLAN []string `mapstructure:"retry_join"`
|
|
|
|
RetryJoinMaxAttemptsLAN *int `mapstructure:"retry_max"`
|
|
|
|
RetryJoinMaxAttemptsWAN *int `mapstructure:"retry_max_wan"`
|
|
|
|
RetryJoinWAN []string `mapstructure:"retry_join_wan"`
|
|
|
|
SerfAllowedCIDRsLAN []string `mapstructure:"serf_lan_allowed_cidrs"`
|
|
|
|
SerfAllowedCIDRsWAN []string `mapstructure:"serf_wan_allowed_cidrs"`
|
|
|
|
SerfBindAddrLAN *string `mapstructure:"serf_lan"`
|
|
|
|
SerfBindAddrWAN *string `mapstructure:"serf_wan"`
|
|
|
|
ServerMode *bool `mapstructure:"server"`
|
|
|
|
ServerName *string `mapstructure:"server_name"`
|
|
|
|
Service *ServiceDefinition `mapstructure:"service"`
|
|
|
|
Services []ServiceDefinition `mapstructure:"services"`
|
|
|
|
SessionTTLMin *string `mapstructure:"session_ttl_min"`
|
|
|
|
SkipLeaveOnInt *bool `mapstructure:"skip_leave_on_interrupt"`
|
|
|
|
StartJoinAddrsLAN []string `mapstructure:"start_join"`
|
|
|
|
StartJoinAddrsWAN []string `mapstructure:"start_join_wan"`
|
|
|
|
SyslogFacility *string `mapstructure:"syslog_facility"`
|
|
|
|
TLSCipherSuites *string `mapstructure:"tls_cipher_suites"`
|
|
|
|
TLSMinVersion *string `mapstructure:"tls_min_version"`
|
|
|
|
TLSPreferServerCipherSuites *bool `mapstructure:"tls_prefer_server_cipher_suites"`
|
|
|
|
TaggedAddresses map[string]string `mapstructure:"tagged_addresses"`
|
|
|
|
Telemetry Telemetry `mapstructure:"telemetry"`
|
|
|
|
TranslateWANAddrs *bool `mapstructure:"translate_wan_addrs"`
|
2020-09-10 16:25:56 +00:00
|
|
|
|
|
|
|
// DEPRECATED (ui-config) - moved to the ui_config stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
UI *bool `mapstructure:"ui"`
|
2020-09-10 16:25:56 +00:00
|
|
|
// DEPRECATED (ui-config) - moved to the ui_config stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
UIContentPath *string `mapstructure:"ui_content_path"`
|
2020-09-10 16:25:56 +00:00
|
|
|
// DEPRECATED (ui-config) - moved to the ui_config stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
UIDir *string `mapstructure:"ui_dir"`
|
|
|
|
UIConfig RawUIConfig `mapstructure:"ui_config"`
|
2020-09-10 16:25:56 +00:00
|
|
|
|
2020-11-20 22:48:39 +00:00
|
|
|
UnixSocket UnixSocket `mapstructure:"unix_sockets"`
|
|
|
|
VerifyIncoming *bool `mapstructure:"verify_incoming"`
|
|
|
|
VerifyIncomingHTTPS *bool `mapstructure:"verify_incoming_https"`
|
|
|
|
VerifyIncomingRPC *bool `mapstructure:"verify_incoming_rpc"`
|
|
|
|
VerifyOutgoing *bool `mapstructure:"verify_outgoing"`
|
|
|
|
VerifyServerHostname *bool `mapstructure:"verify_server_hostname"`
|
|
|
|
Watches []map[string]interface{} `mapstructure:"watches"`
|
2017-09-25 18:40:42 +00:00
|
|
|
|
2020-10-05 20:28:13 +00:00
|
|
|
RPC RPC `mapstructure:"rpc"`
|
|
|
|
|
2020-10-23 21:47:01 +00:00
|
|
|
// UseStreamingBackend instead of blocking queries for service health and
|
|
|
|
// any other endpoints which support streaming.
|
2020-11-20 22:48:39 +00:00
|
|
|
UseStreamingBackend *bool `mapstructure:"use_streaming_backend"`
|
2020-10-23 21:47:01 +00:00
|
|
|
|
2017-11-10 21:50:45 +00:00
|
|
|
// This isn't used by Consul but we've documented a feature where users
|
|
|
|
// can deploy their snapshot agent configs alongside their Consul configs
|
|
|
|
// so we have a placeholder here so it can be parsed but this doesn't
|
|
|
|
// manifest itself in any way inside the runtime config.
|
2020-11-20 22:48:39 +00:00
|
|
|
SnapshotAgent map[string]interface{} `mapstructure:"snapshot_agent"`
|
2017-11-10 21:50:45 +00:00
|
|
|
|
2017-09-25 18:40:42 +00:00
|
|
|
// non-user configurable values
|
2018-10-19 16:04:07 +00:00
|
|
|
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
|
2020-11-20 22:48:39 +00:00
|
|
|
ACLDisabledTTL *string `mapstructure:"acl_disabled_ttl"`
|
|
|
|
AEInterval *string `mapstructure:"ae_interval"`
|
|
|
|
CheckDeregisterIntervalMin *string `mapstructure:"check_deregister_interval_min"`
|
|
|
|
CheckReapInterval *string `mapstructure:"check_reap_interval"`
|
|
|
|
Consul Consul `mapstructure:"consul"`
|
|
|
|
Revision *string `mapstructure:"revision"`
|
|
|
|
SegmentLimit *int `mapstructure:"segment_limit"`
|
|
|
|
SegmentNameLimit *int `mapstructure:"segment_name_limit"`
|
|
|
|
SyncCoordinateIntervalMin *string `mapstructure:"sync_coordinate_interval_min"`
|
|
|
|
SyncCoordinateRateTarget *float64 `mapstructure:"sync_coordinate_rate_target"`
|
|
|
|
Version *string `mapstructure:"version"`
|
|
|
|
VersionPrerelease *string `mapstructure:"version_prerelease"`
|
2020-04-17 20:27:39 +00:00
|
|
|
|
2020-05-11 20:27:35 +00:00
|
|
|
// Enterprise Only
|
2020-11-20 22:48:39 +00:00
|
|
|
Audit *Audit `mapstructure:"audit"`
|
2020-04-28 13:45:33 +00:00
|
|
|
// Enterprise Only
|
2020-11-20 22:48:39 +00:00
|
|
|
ReadReplica *bool `mapstructure:"read_replica" alias:"non_voting_server"`
|
2020-04-28 13:45:33 +00:00
|
|
|
// Enterprise Only
|
2020-11-20 22:48:39 +00:00
|
|
|
SegmentName *string `mapstructure:"segment"`
|
2020-04-28 13:45:33 +00:00
|
|
|
// Enterprise Only
|
2020-11-20 22:48:39 +00:00
|
|
|
Segments []Segment `mapstructure:"segments"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
2018-07-26 15:39:49 +00:00
|
|
|
type GossipLANConfig struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
GossipNodes *int `mapstructure:"gossip_nodes"`
|
|
|
|
GossipInterval *string `mapstructure:"gossip_interval"`
|
|
|
|
ProbeInterval *string `mapstructure:"probe_interval"`
|
|
|
|
ProbeTimeout *string `mapstructure:"probe_timeout"`
|
|
|
|
SuspicionMult *int `mapstructure:"suspicion_mult"`
|
|
|
|
RetransmitMult *int `mapstructure:"retransmit_mult"`
|
2018-07-26 15:39:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type GossipWANConfig struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
GossipNodes *int `mapstructure:"gossip_nodes"`
|
|
|
|
GossipInterval *string `mapstructure:"gossip_interval"`
|
|
|
|
ProbeInterval *string `mapstructure:"probe_interval"`
|
|
|
|
ProbeTimeout *string `mapstructure:"probe_timeout"`
|
|
|
|
SuspicionMult *int `mapstructure:"suspicion_mult"`
|
|
|
|
RetransmitMult *int `mapstructure:"retransmit_mult"`
|
2018-07-26 15:39:49 +00:00
|
|
|
}
|
|
|
|
|
2017-09-25 18:40:42 +00:00
|
|
|
type Consul struct {
|
|
|
|
Coordinate struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
UpdateBatchSize *int `mapstructure:"update_batch_size"`
|
|
|
|
UpdateMaxBatches *int `mapstructure:"update_max_batches"`
|
|
|
|
UpdatePeriod *string `mapstructure:"update_period"`
|
|
|
|
} `mapstructure:"coordinate"`
|
2017-09-25 18:40:42 +00:00
|
|
|
|
|
|
|
Raft struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
ElectionTimeout *string `mapstructure:"election_timeout"`
|
|
|
|
HeartbeatTimeout *string `mapstructure:"heartbeat_timeout"`
|
|
|
|
LeaderLeaseTimeout *string `mapstructure:"leader_lease_timeout"`
|
|
|
|
} `mapstructure:"raft"`
|
2017-09-25 18:40:42 +00:00
|
|
|
|
|
|
|
Server struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
HealthInterval *string `mapstructure:"health_interval"`
|
|
|
|
} `mapstructure:"server"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Addresses struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
DNS *string `mapstructure:"dns"`
|
|
|
|
HTTP *string `mapstructure:"http"`
|
|
|
|
HTTPS *string `mapstructure:"https"`
|
|
|
|
GRPC *string `mapstructure:"grpc"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type AdvertiseAddrsConfig struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
RPC *string `mapstructure:"rpc"`
|
|
|
|
SerfLAN *string `mapstructure:"serf_lan"`
|
|
|
|
SerfWAN *string `mapstructure:"serf_wan"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Autopilot struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
CleanupDeadServers *bool `mapstructure:"cleanup_dead_servers"`
|
|
|
|
LastContactThreshold *string `mapstructure:"last_contact_threshold"`
|
|
|
|
MaxTrailingLogs *int `mapstructure:"max_trailing_logs"`
|
|
|
|
MinQuorum *uint `mapstructure:"min_quorum"`
|
|
|
|
ServerStabilizationTime *string `mapstructure:"server_stabilization_time"`
|
2020-04-28 13:45:33 +00:00
|
|
|
|
|
|
|
// Enterprise Only
|
2020-11-20 22:48:39 +00:00
|
|
|
DisableUpgradeMigration *bool `mapstructure:"disable_upgrade_migration"`
|
2020-04-28 13:45:33 +00:00
|
|
|
// Enterprise Only
|
2020-11-20 22:48:39 +00:00
|
|
|
RedundancyZoneTag *string `mapstructure:"redundancy_zone_tag"`
|
2020-04-28 13:45:33 +00:00
|
|
|
// Enterprise Only
|
2020-11-20 22:48:39 +00:00
|
|
|
UpgradeVersionTag *string `mapstructure:"upgrade_version_tag"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
2018-09-07 14:30:47 +00:00
|
|
|
// ServiceWeights defines the registration of weights used in DNS for a Service
|
|
|
|
type ServiceWeights struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Passing *int `mapstructure:"passing"`
|
|
|
|
Warning *int `mapstructure:"warning"`
|
2018-09-07 14:30:47 +00:00
|
|
|
}
|
|
|
|
|
2019-06-17 14:51:50 +00:00
|
|
|
type ServiceAddress struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Address *string `mapstructure:"address"`
|
|
|
|
Port *int `mapstructure:"port"`
|
2019-06-17 14:51:50 +00:00
|
|
|
}
|
|
|
|
|
2017-09-25 18:40:42 +00:00
|
|
|
type ServiceDefinition struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Kind *string `mapstructure:"kind"`
|
|
|
|
ID *string `mapstructure:"id"`
|
|
|
|
Name *string `mapstructure:"name"`
|
|
|
|
Tags []string `mapstructure:"tags"`
|
|
|
|
Address *string `mapstructure:"address"`
|
|
|
|
TaggedAddresses map[string]ServiceAddress `mapstructure:"tagged_addresses"`
|
|
|
|
Meta map[string]string `mapstructure:"meta"`
|
|
|
|
Port *int `mapstructure:"port"`
|
|
|
|
Check *CheckDefinition `mapstructure:"check"`
|
|
|
|
Checks []CheckDefinition `mapstructure:"checks"`
|
|
|
|
Token *string `mapstructure:"token"`
|
|
|
|
Weights *ServiceWeights `mapstructure:"weights"`
|
|
|
|
EnableTagOverride *bool `mapstructure:"enable_tag_override"`
|
|
|
|
Proxy *ServiceProxy `mapstructure:"proxy"`
|
|
|
|
Connect *ServiceConnect `mapstructure:"connect"`
|
|
|
|
|
|
|
|
EnterpriseMeta `mapstructure:",squash"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type CheckDefinition struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
ID *string `mapstructure:"id"`
|
|
|
|
Name *string `mapstructure:"name"`
|
|
|
|
Notes *string `mapstructure:"notes"`
|
|
|
|
ServiceID *string `mapstructure:"service_id" alias:"serviceid"`
|
|
|
|
Token *string `mapstructure:"token"`
|
|
|
|
Status *string `mapstructure:"status"`
|
|
|
|
ScriptArgs []string `mapstructure:"args" alias:"scriptargs"`
|
|
|
|
HTTP *string `mapstructure:"http"`
|
|
|
|
Header map[string][]string `mapstructure:"header"`
|
|
|
|
Method *string `mapstructure:"method"`
|
|
|
|
Body *string `mapstructure:"body"`
|
|
|
|
OutputMaxSize *int `mapstructure:"output_max_size"`
|
|
|
|
TCP *string `mapstructure:"tcp"`
|
|
|
|
Interval *string `mapstructure:"interval"`
|
|
|
|
DockerContainerID *string `mapstructure:"docker_container_id" alias:"dockercontainerid"`
|
|
|
|
Shell *string `mapstructure:"shell"`
|
|
|
|
GRPC *string `mapstructure:"grpc"`
|
|
|
|
GRPCUseTLS *bool `mapstructure:"grpc_use_tls"`
|
2021-02-25 06:35:34 +00:00
|
|
|
TLSServerName *string `mapstructure:"tls_server_name"`
|
2020-11-20 22:48:39 +00:00
|
|
|
TLSSkipVerify *bool `mapstructure:"tls_skip_verify" alias:"tlsskipverify"`
|
|
|
|
AliasNode *string `mapstructure:"alias_node"`
|
|
|
|
AliasService *string `mapstructure:"alias_service"`
|
|
|
|
Timeout *string `mapstructure:"timeout"`
|
|
|
|
TTL *string `mapstructure:"ttl"`
|
2021-04-09 19:12:10 +00:00
|
|
|
H2PING *string `mapstructure:"h2ping"`
|
2020-11-20 22:48:39 +00:00
|
|
|
SuccessBeforePassing *int `mapstructure:"success_before_passing"`
|
|
|
|
FailuresBeforeCritical *int `mapstructure:"failures_before_critical"`
|
|
|
|
DeregisterCriticalServiceAfter *string `mapstructure:"deregister_critical_service_after" alias:"deregistercriticalserviceafter"`
|
|
|
|
|
|
|
|
EnterpriseMeta `mapstructure:",squash"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
2018-04-16 15:00:20 +00:00
|
|
|
// ServiceConnect is the connect block within a service registration
|
|
|
|
type ServiceConnect struct {
|
2018-07-25 18:55:41 +00:00
|
|
|
// Native is true when this service can natively understand Connect.
|
2020-11-20 22:48:39 +00:00
|
|
|
Native *bool `mapstructure:"native"`
|
2018-07-25 18:55:41 +00:00
|
|
|
|
2018-09-27 13:33:12 +00:00
|
|
|
// SidecarService is a nested Service Definition to register at the same time.
|
|
|
|
// It's purely a convenience mechanism to allow specifying a sidecar service
|
|
|
|
// along with the application service definition. It's nested nature allows
|
|
|
|
// all of the fields to be defaulted which can reduce the amount of
|
|
|
|
// boilerplate needed to register a sidecar service separately, but the end
|
|
|
|
// result is identical to just making a second service registration via any
|
|
|
|
// other means.
|
2020-11-20 22:48:39 +00:00
|
|
|
SidecarService *ServiceDefinition `mapstructure:"sidecar_service"`
|
2018-04-16 15:00:20 +00:00
|
|
|
}
|
|
|
|
|
2018-09-12 16:07:47 +00:00
|
|
|
// ServiceProxy is the additional config needed for a Kind = connect-proxy
|
|
|
|
// registration.
|
|
|
|
type ServiceProxy struct {
|
|
|
|
// DestinationServiceName is required and is the name of the service to accept
|
|
|
|
// traffic for.
|
2020-11-20 22:48:39 +00:00
|
|
|
DestinationServiceName *string `mapstructure:"destination_service_name"`
|
2018-09-12 16:07:47 +00:00
|
|
|
|
|
|
|
// DestinationServiceID is optional and should only be specified for
|
|
|
|
// "side-car" style proxies where the proxy is in front of just a single
|
|
|
|
// instance of the service. It should be set to the service ID of the instance
|
|
|
|
// being represented which must be registered to the same agent. It's valid to
|
|
|
|
// provide a service ID that does not yet exist to avoid timing issues when
|
|
|
|
// bootstrapping a service with a proxy.
|
2020-11-20 22:48:39 +00:00
|
|
|
DestinationServiceID *string `mapstructure:"destination_service_id"`
|
2018-09-12 16:07:47 +00:00
|
|
|
|
|
|
|
// LocalServiceAddress is the address of the local service instance. It is
|
|
|
|
// optional and should only be specified for "side-car" style proxies. It will
|
|
|
|
// default to 127.0.0.1 if the proxy is a "side-car" (DestinationServiceID is
|
|
|
|
// set) but otherwise will be ignored.
|
2020-11-20 22:48:39 +00:00
|
|
|
LocalServiceAddress *string `mapstructure:"local_service_address"`
|
2018-09-12 16:07:47 +00:00
|
|
|
|
|
|
|
// LocalServicePort is the port of the local service instance. It is optional
|
|
|
|
// and should only be specified for "side-car" style proxies. It will default
|
|
|
|
// to the registered port for the instance if the proxy is a "side-car"
|
|
|
|
// (DestinationServiceID is set) but otherwise will be ignored.
|
2020-11-20 22:48:39 +00:00
|
|
|
LocalServicePort *int `mapstructure:"local_service_port"`
|
2018-09-12 16:07:47 +00:00
|
|
|
|
2021-04-12 15:35:14 +00:00
|
|
|
// TransparentProxy configuration.
|
|
|
|
TransparentProxy *TransparentProxyConfig `mapstructure:"transparent_proxy"`
|
|
|
|
|
|
|
|
// Mode represents how the proxy's inbound and upstream listeners are dialed.
|
|
|
|
Mode *string `mapstructure:"mode"`
|
|
|
|
|
2018-09-12 16:07:47 +00:00
|
|
|
// Config is the arbitrary configuration data provided with the proxy
|
|
|
|
// registration.
|
2020-11-20 22:48:39 +00:00
|
|
|
Config map[string]interface{} `mapstructure:"config"`
|
2018-09-12 16:07:47 +00:00
|
|
|
|
|
|
|
// Upstreams describes any upstream dependencies the proxy instance should
|
|
|
|
// setup.
|
2020-11-20 22:48:39 +00:00
|
|
|
Upstreams []Upstream `mapstructure:"upstreams"`
|
2019-07-24 21:01:42 +00:00
|
|
|
|
|
|
|
// Mesh Gateway Configuration
|
2020-11-20 22:48:39 +00:00
|
|
|
MeshGateway *MeshGatewayConfig `mapstructure:"mesh_gateway"`
|
2019-09-26 02:55:52 +00:00
|
|
|
|
|
|
|
// Expose defines whether checks or paths are exposed through the proxy
|
2020-11-20 22:48:39 +00:00
|
|
|
Expose *ExposeConfig `mapstructure:"expose"`
|
2018-09-12 16:07:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Upstream represents a single upstream dependency for a service or proxy. It
|
|
|
|
// describes the mechanism used to discover instances to communicate with (the
|
|
|
|
// Target) as well as any potential client configuration that may be useful such
|
|
|
|
// as load balancer options, timeouts etc.
|
|
|
|
type Upstream struct {
|
|
|
|
// Destination fields are the required ones for determining what this upstream
|
|
|
|
// points to. Depending on DestinationType some other fields below might
|
|
|
|
// further restrict the set of instances allowable.
|
|
|
|
//
|
|
|
|
// DestinationType would be better as an int constant but even with custom
|
|
|
|
// JSON marshallers it causes havoc with all the mapstructure mangling we do
|
|
|
|
// on service definitions in various places.
|
2020-11-20 22:48:39 +00:00
|
|
|
DestinationType *string `mapstructure:"destination_type"`
|
|
|
|
DestinationNamespace *string `mapstructure:"destination_namespace"`
|
|
|
|
DestinationName *string `mapstructure:"destination_name"`
|
2018-09-12 16:07:47 +00:00
|
|
|
|
|
|
|
// Datacenter that the service discovery request should be run against. Note
|
|
|
|
// for prepared queries, the actual results might be from a different
|
|
|
|
// datacenter.
|
2020-11-20 22:48:39 +00:00
|
|
|
Datacenter *string `mapstructure:"datacenter"`
|
2018-09-12 16:07:47 +00:00
|
|
|
|
|
|
|
// LocalBindAddress is the ip address a side-car proxy should listen on for
|
|
|
|
// traffic destined for this upstream service. Default if empty is 127.0.0.1.
|
2020-11-20 22:48:39 +00:00
|
|
|
LocalBindAddress *string `mapstructure:"local_bind_address"`
|
2018-09-12 16:07:47 +00:00
|
|
|
|
|
|
|
// LocalBindPort is the ip address a side-car proxy should listen on for traffic
|
|
|
|
// destined for this upstream service. Required.
|
2020-11-20 22:48:39 +00:00
|
|
|
LocalBindPort *int `mapstructure:"local_bind_port"`
|
2018-09-12 16:07:47 +00:00
|
|
|
|
|
|
|
// Config is an opaque config that is specific to the proxy process being run.
|
2019-03-06 17:13:28 +00:00
|
|
|
// It can be used to pass arbitrary configuration for this specific upstream
|
2018-09-12 16:07:47 +00:00
|
|
|
// to the proxy.
|
2020-11-20 22:48:39 +00:00
|
|
|
Config map[string]interface{} `mapstructure:"config"`
|
2019-07-24 21:01:42 +00:00
|
|
|
|
|
|
|
// Mesh Gateway Configuration
|
2020-11-20 22:48:39 +00:00
|
|
|
MeshGateway *MeshGatewayConfig `mapstructure:"mesh_gateway"`
|
2019-07-24 21:01:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type MeshGatewayConfig struct {
|
|
|
|
// Mesh Gateway Mode
|
2020-11-20 22:48:39 +00:00
|
|
|
Mode *string `mapstructure:"mode"`
|
2018-04-16 15:00:20 +00:00
|
|
|
}
|
|
|
|
|
2021-04-12 15:35:14 +00:00
|
|
|
type TransparentProxyConfig struct {
|
|
|
|
// Mesh Gateway Mode
|
|
|
|
OutboundListenerPort *int `mapstructure:"outbound_listener_port"`
|
|
|
|
}
|
|
|
|
|
2019-09-26 02:55:52 +00:00
|
|
|
// ExposeConfig describes HTTP paths to expose through Envoy outside of Connect.
|
|
|
|
// Users can expose individual paths and/or all HTTP/GRPC paths for checks.
|
|
|
|
type ExposeConfig struct {
|
|
|
|
// Checks defines whether paths associated with Consul checks will be exposed.
|
|
|
|
// This flag triggers exposing all HTTP and GRPC check paths registered for the service.
|
2020-11-20 22:48:39 +00:00
|
|
|
Checks *bool `mapstructure:"checks"`
|
2019-09-26 02:55:52 +00:00
|
|
|
|
|
|
|
// Port defines the port of the proxy's listener for exposed paths.
|
2020-11-20 22:48:39 +00:00
|
|
|
Port *int `mapstructure:"port"`
|
2019-09-26 02:55:52 +00:00
|
|
|
|
|
|
|
// Paths is the list of paths exposed through the proxy.
|
2020-11-20 22:48:39 +00:00
|
|
|
Paths []ExposePath `mapstructure:"paths"`
|
2019-09-26 02:55:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ExposePath struct {
|
|
|
|
// ListenerPort defines the port of the proxy's listener for exposed paths.
|
2020-11-20 22:48:39 +00:00
|
|
|
ListenerPort *int `mapstructure:"listener_port"`
|
2019-09-26 02:55:52 +00:00
|
|
|
|
|
|
|
// Path is the path to expose through the proxy, ie. "/metrics."
|
2020-11-20 22:48:39 +00:00
|
|
|
Path *string `mapstructure:"path"`
|
2019-09-26 02:55:52 +00:00
|
|
|
|
|
|
|
// Protocol describes the upstream's service protocol.
|
2020-11-20 22:48:39 +00:00
|
|
|
Protocol *string `mapstructure:"protocol"`
|
2019-09-26 02:55:52 +00:00
|
|
|
|
|
|
|
// LocalPathPort is the port that the service is listening on for the given path.
|
2020-11-20 22:48:39 +00:00
|
|
|
LocalPathPort *int `mapstructure:"local_path_port"`
|
2019-09-26 02:55:52 +00:00
|
|
|
}
|
|
|
|
|
2019-06-27 20:22:07 +00:00
|
|
|
// AutoEncrypt is the agent-global auto_encrypt configuration.
|
|
|
|
type AutoEncrypt struct {
|
|
|
|
// TLS enables receiving certificates for clients from servers
|
2020-11-20 22:48:39 +00:00
|
|
|
TLS *bool `mapstructure:"tls"`
|
2019-06-27 20:22:07 +00:00
|
|
|
|
2020-01-17 22:25:26 +00:00
|
|
|
// Additional DNS SAN entries that clients request for their certificates.
|
2020-11-20 22:48:39 +00:00
|
|
|
DNSSAN []string `mapstructure:"dns_san"`
|
2020-01-17 22:25:26 +00:00
|
|
|
|
|
|
|
// Additional IP SAN entries that clients request for their certificates.
|
2020-11-20 22:48:39 +00:00
|
|
|
IPSAN []string `mapstructure:"ip_san"`
|
2020-01-17 22:25:26 +00:00
|
|
|
|
2019-06-27 20:22:07 +00:00
|
|
|
// AllowTLS enables the RPC endpoint on the server to answer
|
|
|
|
// AutoEncrypt.Sign requests.
|
2020-11-20 22:48:39 +00:00
|
|
|
AllowTLS *bool `mapstructure:"allow_tls"`
|
2019-06-27 20:22:07 +00:00
|
|
|
}
|
|
|
|
|
2018-04-16 15:00:20 +00:00
|
|
|
// Connect is the agent-global connect configuration.
|
|
|
|
type Connect struct {
|
|
|
|
// Enabled opts the agent into connect. It should be set on all clients and
|
2018-06-07 09:17:44 +00:00
|
|
|
// servers in a cluster for correct connect operation.
|
2020-11-20 22:48:39 +00:00
|
|
|
Enabled *bool `mapstructure:"enabled"`
|
|
|
|
CAProvider *string `mapstructure:"ca_provider"`
|
|
|
|
CAConfig map[string]interface{} `mapstructure:"ca_config"`
|
|
|
|
MeshGatewayWANFederationEnabled *bool `mapstructure:"enable_mesh_gateway_wan_federation"`
|
2020-06-10 20:47:35 +00:00
|
|
|
|
|
|
|
// TestCALeafRootChangeSpread controls how long after a CA roots change before new leaft certs will be generated.
|
|
|
|
// This is only tuned in tests, generally set to 1ns to make tests deterministic with when to expect updated leaf
|
|
|
|
// certs by. This configuration is not exposed to users (not documented, and agent/config/default.go will override it)
|
2020-11-20 22:48:39 +00:00
|
|
|
TestCALeafRootChangeSpread *string `mapstructure:"test_ca_leaf_root_change_spread"`
|
2018-04-16 15:00:20 +00:00
|
|
|
}
|
|
|
|
|
Added SOA configuration for DNS settings. (#4714)
This will allow to fine TUNE SOA settings sent by Consul in DNS responses,
for instance to be able to control negative ttl.
Will fix: https://github.com/hashicorp/consul/issues/4713
# Example
Override all settings:
* min_ttl: 0 => 60s
* retry: 600 (10m) => 300s (5 minutes),
* expire: 86400 (24h) => 43200 (12h)
* refresh: 3600 (1h) => 1800 (30 minutes)
```
consul agent -dev -hcl 'dns_config={soa={min_ttl=60,retry=300,expire=43200,refresh=1800}}'
```
Result:
```
dig +multiline @localhost -p 8600 service.consul
; <<>> DiG 9.12.1 <<>> +multiline @localhost -p 8600 service.consul
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 36557
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;service.consul. IN A
;; AUTHORITY SECTION:
consul. 0 IN SOA ns.consul. hostmaster.consul. (
1537959133 ; serial
1800 ; refresh (30 minutes)
300 ; retry (5 minutes)
43200 ; expire (12 hours)
60 ; minimum (1 minute)
)
;; Query time: 4 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Wed Sep 26 12:52:13 CEST 2018
;; MSG SIZE rcvd: 93
```
2018-10-10 19:50:56 +00:00
|
|
|
// SOA is the configuration of SOA for DNS
|
|
|
|
type SOA struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Refresh *uint32 `mapstructure:"refresh"`
|
|
|
|
Retry *uint32 `mapstructure:"retry"`
|
|
|
|
Expire *uint32 `mapstructure:"expire"`
|
|
|
|
Minttl *uint32 `mapstructure:"min_ttl"`
|
Added SOA configuration for DNS settings. (#4714)
This will allow to fine TUNE SOA settings sent by Consul in DNS responses,
for instance to be able to control negative ttl.
Will fix: https://github.com/hashicorp/consul/issues/4713
# Example
Override all settings:
* min_ttl: 0 => 60s
* retry: 600 (10m) => 300s (5 minutes),
* expire: 86400 (24h) => 43200 (12h)
* refresh: 3600 (1h) => 1800 (30 minutes)
```
consul agent -dev -hcl 'dns_config={soa={min_ttl=60,retry=300,expire=43200,refresh=1800}}'
```
Result:
```
dig +multiline @localhost -p 8600 service.consul
; <<>> DiG 9.12.1 <<>> +multiline @localhost -p 8600 service.consul
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 36557
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;service.consul. IN A
;; AUTHORITY SECTION:
consul. 0 IN SOA ns.consul. hostmaster.consul. (
1537959133 ; serial
1800 ; refresh (30 minutes)
300 ; retry (5 minutes)
43200 ; expire (12 hours)
60 ; minimum (1 minute)
)
;; Query time: 4 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Wed Sep 26 12:52:13 CEST 2018
;; MSG SIZE rcvd: 93
```
2018-10-10 19:50:56 +00:00
|
|
|
}
|
|
|
|
|
2017-09-25 18:40:42 +00:00
|
|
|
type DNS struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
AllowStale *bool `mapstructure:"allow_stale"`
|
|
|
|
ARecordLimit *int `mapstructure:"a_record_limit"`
|
|
|
|
DisableCompression *bool `mapstructure:"disable_compression"`
|
|
|
|
EnableTruncate *bool `mapstructure:"enable_truncate"`
|
|
|
|
MaxStale *string `mapstructure:"max_stale"`
|
|
|
|
NodeTTL *string `mapstructure:"node_ttl"`
|
|
|
|
OnlyPassing *bool `mapstructure:"only_passing"`
|
|
|
|
RecursorTimeout *string `mapstructure:"recursor_timeout"`
|
|
|
|
ServiceTTL map[string]string `mapstructure:"service_ttl"`
|
|
|
|
UDPAnswerLimit *int `mapstructure:"udp_answer_limit"`
|
|
|
|
NodeMetaTXT *bool `mapstructure:"enable_additional_node_meta_txt"`
|
|
|
|
SOA *SOA `mapstructure:"soa"`
|
|
|
|
UseCache *bool `mapstructure:"use_cache"`
|
|
|
|
CacheMaxAge *string `mapstructure:"cache_max_age"`
|
2020-04-28 13:45:33 +00:00
|
|
|
|
|
|
|
// Enterprise Only
|
2020-11-20 22:48:39 +00:00
|
|
|
PreferNamespace *bool `mapstructure:"prefer_namespace"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type HTTPConfig struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
BlockEndpoints []string `mapstructure:"block_endpoints"`
|
|
|
|
AllowWriteHTTPFrom []string `mapstructure:"allow_write_http_from"`
|
|
|
|
ResponseHeaders map[string]string `mapstructure:"response_headers"`
|
|
|
|
UseCache *bool `mapstructure:"use_cache"`
|
|
|
|
MaxHeaderBytes *int `mapstructure:"max_header_bytes"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Performance struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
LeaveDrainTime *string `mapstructure:"leave_drain_time"`
|
|
|
|
RaftMultiplier *int `mapstructure:"raft_multiplier"` // todo(fs): validate as uint
|
|
|
|
RPCHoldTimeout *string `mapstructure:"rpc_hold_timeout"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Telemetry struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
CirconusAPIApp *string `mapstructure:"circonus_api_app"`
|
|
|
|
CirconusAPIToken *string `mapstructure:"circonus_api_token"`
|
|
|
|
CirconusAPIURL *string `mapstructure:"circonus_api_url"`
|
|
|
|
CirconusBrokerID *string `mapstructure:"circonus_broker_id"`
|
|
|
|
CirconusBrokerSelectTag *string `mapstructure:"circonus_broker_select_tag"`
|
|
|
|
CirconusCheckDisplayName *string `mapstructure:"circonus_check_display_name"`
|
|
|
|
CirconusCheckForceMetricActivation *string `mapstructure:"circonus_check_force_metric_activation"`
|
|
|
|
CirconusCheckID *string `mapstructure:"circonus_check_id"`
|
|
|
|
CirconusCheckInstanceID *string `mapstructure:"circonus_check_instance_id"`
|
|
|
|
CirconusCheckSearchTag *string `mapstructure:"circonus_check_search_tag"`
|
|
|
|
CirconusCheckTags *string `mapstructure:"circonus_check_tags"`
|
|
|
|
CirconusSubmissionInterval *string `mapstructure:"circonus_submission_interval"`
|
|
|
|
CirconusSubmissionURL *string `mapstructure:"circonus_submission_url"`
|
|
|
|
DisableCompatOneNine *bool `mapstructure:"disable_compat_1.9"`
|
|
|
|
DisableHostname *bool `mapstructure:"disable_hostname"`
|
|
|
|
DogstatsdAddr *string `mapstructure:"dogstatsd_addr"`
|
|
|
|
DogstatsdTags []string `mapstructure:"dogstatsd_tags"`
|
|
|
|
FilterDefault *bool `mapstructure:"filter_default"`
|
|
|
|
PrefixFilter []string `mapstructure:"prefix_filter"`
|
|
|
|
MetricsPrefix *string `mapstructure:"metrics_prefix"`
|
|
|
|
PrometheusRetentionTime *string `mapstructure:"prometheus_retention_time"`
|
|
|
|
StatsdAddr *string `mapstructure:"statsd_address"`
|
|
|
|
StatsiteAddr *string `mapstructure:"statsite_address"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Ports struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
DNS *int `mapstructure:"dns"`
|
|
|
|
HTTP *int `mapstructure:"http"`
|
|
|
|
HTTPS *int `mapstructure:"https"`
|
|
|
|
SerfLAN *int `mapstructure:"serf_lan"`
|
|
|
|
SerfWAN *int `mapstructure:"serf_wan"`
|
|
|
|
Server *int `mapstructure:"server"`
|
|
|
|
GRPC *int `mapstructure:"grpc"`
|
|
|
|
ProxyMinPort *int `mapstructure:"proxy_min_port"`
|
|
|
|
ProxyMaxPort *int `mapstructure:"proxy_max_port"`
|
|
|
|
SidecarMinPort *int `mapstructure:"sidecar_min_port"`
|
|
|
|
SidecarMaxPort *int `mapstructure:"sidecar_max_port"`
|
|
|
|
ExposeMinPort *int `mapstructure:"expose_min_port"`
|
|
|
|
ExposeMaxPort *int `mapstructure:"expose_max_port"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type UnixSocket struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Group *string `mapstructure:"group"`
|
|
|
|
Mode *string `mapstructure:"mode"`
|
|
|
|
User *string `mapstructure:"user"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Limits struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
HTTPMaxConnsPerClient *int `mapstructure:"http_max_conns_per_client"`
|
|
|
|
HTTPSHandshakeTimeout *string `mapstructure:"https_handshake_timeout"`
|
|
|
|
RPCHandshakeTimeout *string `mapstructure:"rpc_handshake_timeout"`
|
|
|
|
RPCMaxBurst *int `mapstructure:"rpc_max_burst"`
|
|
|
|
RPCMaxConnsPerClient *int `mapstructure:"rpc_max_conns_per_client"`
|
|
|
|
RPCRate *float64 `mapstructure:"rpc_rate"`
|
|
|
|
KVMaxValueSize *uint64 `mapstructure:"kv_max_value_size"`
|
|
|
|
TxnMaxReqLen *uint64 `mapstructure:"txn_max_req_len"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Segment struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Advertise *string `mapstructure:"advertise"`
|
|
|
|
Bind *string `mapstructure:"bind"`
|
|
|
|
Name *string `mapstructure:"name"`
|
|
|
|
Port *int `mapstructure:"port"`
|
|
|
|
RPCListener *bool `mapstructure:"rpc_listener"`
|
2017-09-25 18:40:42 +00:00
|
|
|
}
|
2018-10-19 16:04:07 +00:00
|
|
|
|
|
|
|
type ACL struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Enabled *bool `mapstructure:"enabled"`
|
|
|
|
TokenReplication *bool `mapstructure:"enable_token_replication"`
|
|
|
|
PolicyTTL *string `mapstructure:"policy_ttl"`
|
|
|
|
RoleTTL *string `mapstructure:"role_ttl"`
|
|
|
|
TokenTTL *string `mapstructure:"token_ttl"`
|
|
|
|
DownPolicy *string `mapstructure:"down_policy"`
|
|
|
|
DefaultPolicy *string `mapstructure:"default_policy"`
|
|
|
|
EnableKeyListPolicy *bool `mapstructure:"enable_key_list_policy"`
|
|
|
|
Tokens Tokens `mapstructure:"tokens"`
|
|
|
|
DisabledTTL *string `mapstructure:"disabled_ttl"`
|
|
|
|
EnableTokenPersistence *bool `mapstructure:"enable_token_persistence"`
|
2020-04-28 13:45:33 +00:00
|
|
|
|
|
|
|
// Enterprise Only
|
2020-11-20 22:48:39 +00:00
|
|
|
MSPDisableBootstrap *bool `mapstructure:"msp_disable_bootstrap"`
|
2018-10-19 16:04:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Tokens struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Master *string `mapstructure:"master"`
|
|
|
|
Replication *string `mapstructure:"replication"`
|
|
|
|
AgentMaster *string `mapstructure:"agent_master"`
|
|
|
|
Default *string `mapstructure:"default"`
|
|
|
|
Agent *string `mapstructure:"agent"`
|
2020-04-28 13:45:33 +00:00
|
|
|
|
|
|
|
// Enterprise Only
|
2020-11-20 22:48:39 +00:00
|
|
|
ManagedServiceProvider []ServiceProviderToken `mapstructure:"managed_service_provider"`
|
2020-02-04 20:58:56 +00:00
|
|
|
}
|
|
|
|
|
2020-04-28 13:45:33 +00:00
|
|
|
// ServiceProviderToken groups an accessor and secret for a service provider token. Enterprise Only
|
2020-02-04 20:58:56 +00:00
|
|
|
type ServiceProviderToken struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
AccessorID *string `mapstructure:"accessor_id"`
|
|
|
|
SecretID *string `mapstructure:"secret_id"`
|
2018-10-19 16:04:07 +00:00
|
|
|
}
|
2019-04-26 18:25:03 +00:00
|
|
|
|
|
|
|
type ConfigEntries struct {
|
2019-04-30 14:13:59 +00:00
|
|
|
// Bootstrap is the list of config_entries that should only be persisted to
|
|
|
|
// cluster on initial startup of a new leader if no such config exists
|
|
|
|
// already. The type is map not structs.ConfigEntry for decoding reasons - we
|
|
|
|
// need to figure out the right concrete type before we can decode it
|
|
|
|
// unabiguously.
|
2020-11-20 22:48:39 +00:00
|
|
|
Bootstrap []map[string]interface{} `mapstructure:"bootstrap"`
|
2019-04-26 18:25:03 +00:00
|
|
|
}
|
2020-05-11 20:27:35 +00:00
|
|
|
|
|
|
|
// Audit allows us to enable and define destinations for auditing
|
|
|
|
type Audit struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Enabled *bool `mapstructure:"enabled"`
|
|
|
|
Sinks map[string]AuditSink `mapstructure:"sink"`
|
2020-05-11 20:27:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// AuditSink can be provided multiple times to define pipelines for auditing
|
|
|
|
type AuditSink struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Name *string `mapstructure:"name"`
|
|
|
|
Type *string `mapstructure:"type"`
|
|
|
|
Format *string `mapstructure:"format"`
|
|
|
|
Path *string `mapstructure:"path"`
|
|
|
|
DeliveryGuarantee *string `mapstructure:"delivery_guarantee"`
|
|
|
|
RotateBytes *int `mapstructure:"rotate_bytes"`
|
|
|
|
RotateDuration *string `mapstructure:"rotate_duration"`
|
|
|
|
RotateMaxFiles *int `mapstructure:"rotate_max_files"`
|
2020-05-11 20:27:35 +00:00
|
|
|
}
|
2020-06-16 19:03:22 +00:00
|
|
|
|
|
|
|
type AutoConfigRaw struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Enabled *bool `mapstructure:"enabled"`
|
|
|
|
IntroToken *string `mapstructure:"intro_token"`
|
|
|
|
IntroTokenFile *string `mapstructure:"intro_token_file"`
|
|
|
|
ServerAddresses []string `mapstructure:"server_addresses"`
|
|
|
|
DNSSANs []string `mapstructure:"dns_sans"`
|
|
|
|
IPSANs []string `mapstructure:"ip_sans"`
|
|
|
|
Authorization AutoConfigAuthorizationRaw `mapstructure:"authorization"`
|
2020-06-18 15:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type AutoConfigAuthorizationRaw struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Enabled *bool `mapstructure:"enabled"`
|
|
|
|
Static AutoConfigAuthorizerRaw `mapstructure:"static"`
|
2020-06-16 19:03:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type AutoConfigAuthorizerRaw struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
ClaimAssertions []string `mapstructure:"claim_assertions"`
|
|
|
|
AllowReuse *bool `mapstructure:"allow_reuse"`
|
2020-06-16 19:03:22 +00:00
|
|
|
|
|
|
|
// Fields to be shared with the JWT Auth Method
|
2020-11-20 22:48:39 +00:00
|
|
|
JWTSupportedAlgs []string `mapstructure:"jwt_supported_algs"`
|
|
|
|
BoundAudiences []string `mapstructure:"bound_audiences"`
|
|
|
|
ClaimMappings map[string]string `mapstructure:"claim_mappings"`
|
|
|
|
ListClaimMappings map[string]string `mapstructure:"list_claim_mappings"`
|
|
|
|
OIDCDiscoveryURL *string `mapstructure:"oidc_discovery_url"`
|
|
|
|
OIDCDiscoveryCACert *string `mapstructure:"oidc_discovery_ca_cert"`
|
|
|
|
JWKSURL *string `mapstructure:"jwks_url"`
|
|
|
|
JWKSCACert *string `mapstructure:"jwks_ca_cert"`
|
|
|
|
JWTValidationPubKeys []string `mapstructure:"jwt_validation_pub_keys"`
|
|
|
|
BoundIssuer *string `mapstructure:"bound_issuer"`
|
|
|
|
ExpirationLeeway *string `mapstructure:"expiration_leeway"`
|
|
|
|
NotBeforeLeeway *string `mapstructure:"not_before_leeway"`
|
|
|
|
ClockSkewLeeway *string `mapstructure:"clock_skew_leeway"`
|
2020-06-16 19:03:22 +00:00
|
|
|
}
|
2020-09-10 16:25:56 +00:00
|
|
|
|
|
|
|
type RawUIConfig struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Enabled *bool `mapstructure:"enabled"`
|
|
|
|
Dir *string `mapstructure:"dir"`
|
|
|
|
ContentPath *string `mapstructure:"content_path"`
|
|
|
|
MetricsProvider *string `mapstructure:"metrics_provider"`
|
|
|
|
MetricsProviderFiles []string `mapstructure:"metrics_provider_files"`
|
|
|
|
MetricsProviderOptionsJSON *string `mapstructure:"metrics_provider_options_json"`
|
|
|
|
MetricsProxy RawUIMetricsProxy `mapstructure:"metrics_proxy"`
|
|
|
|
DashboardURLTemplates map[string]string `mapstructure:"dashboard_url_templates"`
|
2020-09-10 16:25:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type RawUIMetricsProxy struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
BaseURL *string `mapstructure:"base_url"`
|
|
|
|
AddHeaders []RawUIMetricsProxyAddHeader `mapstructure:"add_headers"`
|
|
|
|
PathAllowlist []string `mapstructure:"path_allowlist"`
|
2020-09-10 16:25:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type RawUIMetricsProxyAddHeader struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
Name *string `mapstructure:"name"`
|
|
|
|
Value *string `mapstructure:"value"`
|
2020-09-10 16:25:56 +00:00
|
|
|
}
|
2020-10-05 20:28:13 +00:00
|
|
|
|
|
|
|
type RPC struct {
|
2020-11-20 22:48:39 +00:00
|
|
|
EnableStreaming *bool `mapstructure:"enable_streaming"`
|
2020-10-05 20:28:13 +00:00
|
|
|
}
|