config

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigEnvironmentVariable = "CONSUL_ECS_CONFIG_JSON"
)
View Source
const DefaultPublicListenerPort = 20000

DefaultPublicListenerPort is the default public listener port for sidecar proxies.

Variables

View Source
var Schema string

Functions

This section is empty.

Types

type AgentServiceCheck

type AgentServiceCheck struct {
	CheckID                string              `json:"checkId,omitempty"`
	Name                   string              `json:"name,omitempty"`
	Args                   []string            `json:"args,omitempty"`
	Interval               string              `json:"interval,omitempty"`
	Timeout                string              `json:"timeout,omitempty"`
	TTL                    string              `json:"ttl,omitempty"`
	HTTP                   string              `json:"http,omitempty"`
	Header                 map[string][]string `json:"header,omitempty"`
	Method                 string              `json:"method,omitempty"`
	Body                   string              `json:"body,omitempty"`
	TCP                    string              `json:"tcp,omitempty"`
	Status                 string              `json:"status,omitempty"`
	Notes                  string              `json:"notes,omitempty"`
	TLSServerName          string              `json:"tlsServerName,omitempty"`
	TLSSkipVerify          bool                `json:"tlsSkipVerify,omitempty"`
	GRPC                   string              `json:"grpc,omitempty"`
	GRPCUseTLS             bool                `json:"grpcUseTls,omitempty"`
	H2PPING                string              `json:"h2ping,omitempty"`
	H2PingUseTLS           bool                `json:"h2pingUseTLS,omitempty"`
	AliasNode              string              `json:"aliasNode,omitempty"`
	AliasService           string              `json:"aliasService,omitempty"`
	SuccessBeforePassing   int                 `json:"successBeforePassing,omitempty"`
	FailuresBeforeCritical int                 `json:"failuresBeforeCritical,omitempty"`
}

AgentServiceCheck configures a Consul Check.

NOTE:

  • The DockerContainerID and Shell fields are excluded. Shell is only used for Docker checks, and Docker checks won't work on ECS. They cannot work on Fargate, and require specific config to access the host's Docker daemon on the EC2 launch type.
  • DeregisterCriticalServiceAfter is also excluded. We have health check support to handle service deregistration.

func (*AgentServiceCheck) ToConsulType

func (c *AgentServiceCheck) ToConsulType() *api.AgentServiceCheck

type AgentServiceConnectProxyConfig

type AgentServiceConnectProxyConfig struct {
	Config             map[string]interface{} `json:"config,omitempty"`
	PublicListenerPort int                    `json:"publicListenerPort,omitempty"`
	Upstreams          []Upstream             `json:"upstreams,omitempty"`
	MeshGateway        *MeshGatewayConfig     `json:"meshGateway,omitempty"`
	Expose             *ExposeConfig          `json:"expose,omitempty"`
}

AgentServiceConnectProxyConfig defines the sidecar proxy configuration.

NOTE: For the proxy registration request (api.AgentServiceRegistration in Consul),

  • The Kind and Port are set by mesh-init, so these fields are not configurable.
  • The ID, Name, Tags, Meta, EnableTagOverride, and Weights fields are inferred or copied from the service registration by mesh-init.
  • The bind address is always localhost in ECS, so the Address and SocketPath are excluded.
  • The Connect field is excluded. Since the sidecar proxy is being used, it's not a Connect-native service, and we don't need the nested proxy config included in the Connect field.
  • The Partition field is excluded. mesh-init will use the partition from the service registration.
  • The Namespace field is excluded. mesh-init will use the namespace from the service registration.
  • There's not a use-case for specifying TaggedAddresses with Consul ECS, and Enable

For the proxy configuration (api.AgentServiceConnectProxyConfig in Consul),

  • The DestinationServiceName, DestinationServiceId, LocalServiceAddress, and LocalServicePort are all set by mesh-init, based on the service configuration.
  • The LocalServiceSocketPath is excluded, since it would conflict with the address/port set by mesh-init.
  • Checks are excluded. mesh-init automatically configures useful checks for the proxy.
  • TProxy is not supported on ECS, so the Mode and TransparentProxy fields are excluded.

func (*AgentServiceConnectProxyConfig) GetPublicListenerPort added in v0.4.3

func (a *AgentServiceConnectProxyConfig) GetPublicListenerPort() int

func (*AgentServiceConnectProxyConfig) ToConsulType

type AgentWeights

type AgentWeights struct {
	Passing int `json:"passing"`
	Warning int `json:"warning"`
}

func (*AgentWeights) ToConsulType

func (w *AgentWeights) ToConsulType() *api.AgentWeights

type Config

type Config struct {
	BootstrapDir         string                          `json:"bootstrapDir"`
	HealthSyncContainers []string                        `json:"healthSyncContainers,omitempty"`
	Proxy                *AgentServiceConnectProxyConfig `json:"proxy"`
	Service              ServiceRegistration             `json:"service"`
}

Config is the top-level config object.

func FromEnv

func FromEnv() (*Config, error)

type ExposeConfig

type ExposeConfig struct {
	Checks bool         `json:"checks,omitempty"`
	Paths  []ExposePath `json:"paths,omitempty"`
}

ExposeConfig describes HTTP paths to expose through Envoy outside of Connect.

func (*ExposeConfig) ToConsulType

func (e *ExposeConfig) ToConsulType() api.ExposeConfig

type ExposePath

type ExposePath struct {
	ListenerPort  int    `json:"listenerPort,omitempty"`
	Path          string `json:"path,omitempty"`
	LocalPathPort int    `json:"localPathPort,omitempty"`
	Protocol      string `json:"protocol,omitempty"`
}

ExposePath are the paths to expose outside of connect. See ExposeConfig.

func (*ExposePath) ToConsulType

func (e *ExposePath) ToConsulType() api.ExposePath

type MeshGatewayConfig

type MeshGatewayConfig struct {
	Mode api.MeshGatewayMode `json:"mode,omitempty"`
}

MeshGatewayConfig describes how to use mesh gateways to reach other services.

func (*MeshGatewayConfig) ToConsulType

func (m *MeshGatewayConfig) ToConsulType() api.MeshGatewayConfig

type ServiceAddress

type ServiceAddress struct {
	Address string `json:"address"`
	Port    int    `json:"port"`
}

func (*ServiceAddress) ToConsulType

func (a *ServiceAddress) ToConsulType() api.ServiceAddress

type ServiceRegistration

type ServiceRegistration struct {
	Name              string              `json:"name"`
	Tags              []string            `json:"tags,omitempty"`
	Port              int                 `json:"port"`
	EnableTagOverride bool                `json:"enableTagOverride,omitempty"`
	Meta              map[string]string   `json:"meta,omitempty"`
	Weights           *AgentWeights       `json:"weights,omitempty"`
	Checks            []AgentServiceCheck `json:"checks,omitempty"`
	Namespace         string              `json:"namespace,omitempty"`
	Partition         string              `json:"partition,omitempty"`
}

ServiceRegistration configures the Consul service registration.

NOTE: - The Kind and Id fields are set by mesh-init during service/proxy registration. - The Address field excluded. The agent's address (task ip) should always be used in ECS. - The Connect field is not supported:

  • No Connect-native support for now. We assume Envoy is used.
  • Proxy registration occurs in a separate request, so no need to inline the proxy config. See the SidecarProxyRegistration type.

func (*ServiceRegistration) ToConsulType

type Upstream

type Upstream struct {
	DestinationType      api.UpstreamDestType   `json:"destinationType,omitempty"`
	DestinationNamespace string                 `json:"destinationNamespace,omitempty"`
	DestinationPartition string                 `json:"destinationPartition,omitempty"`
	DestinationName      string                 `json:"destinationName,omitempty"`
	Datacenter           string                 `json:"datacenter,omitempty"`
	LocalBindAddress     string                 `json:"localBindAddress,omitempty"`
	LocalBindPort        int                    `json:"localBindPort,omitempty"`
	Config               map[string]interface{} `json:"config,omitempty"`
	MeshGateway          *MeshGatewayConfig     `json:"meshGateway,omitempty"`
}

Upstream describes an upstream Consul Service.

NOTE: The LocalBindSocketPath and LocalBindSocketMode are excluded. This level of control/restriction is not as relevant in ECS since each proxy runs in an isolated Docker container.

func (*Upstream) ToConsulType

func (u *Upstream) ToConsulType() api.Upstream

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL