envoy

package
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package envoy contains a configuration writer for v2 YAML config. To avoid a dependncy on a YAML library, we generate the YAML using the text/template package.

Index

Constants

View Source
const CACertificateKey = "ca.crt"

CACertificateKey stores the key for the TLS validation secret cert

Variables

View Source
var DefaultFields = []string{
	"@timestamp",
	"authority",
	"bytes_received",
	"bytes_sent",
	"downstream_local_address",
	"downstream_remote_address",
	"duration",
	"method",
	"path",
	"protocol",
	"request_id",
	"requested_server_name",
	"response_code",
	"response_flags",
	"uber_trace_id",
	"upstream_cluster",
	"upstream_host",
	"upstream_local_address",
	"upstream_service_time",
	"user_agent",
	"x_forwarded_for",
}

DefaultFields are fields that will be included by default when JSON logging is enabled.

View Source
var JSONFields = map[string]string{
	"@timestamp":                "%START_TIME%",
	"ts":                        "%START_TIME%",
	"authority":                 "%REQ(:AUTHORITY)%",
	"bytes_received":            "%BYTES_RECEIVED%",
	"bytes_sent":                "%BYTES_SENT%",
	"downstream_local_address":  "%DOWNSTREAM_LOCAL_ADDRESS%",
	"downstream_remote_address": "%DOWNSTREAM_REMOTE_ADDRESS%",
	"duration":                  "%DURATION%",
	"method":                    "%REQ(:METHOD)%",
	"path":                      "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%",
	"protocol":                  "%PROTOCOL%",
	"request_id":                "%REQ(X-REQUEST-ID)%",
	"requested_server_name":     "%REQUESTED_SERVER_NAME%",
	"response_code":             "%RESPONSE_CODE%",
	"response_flags":            "%RESPONSE_FLAGS%",
	"uber_trace_id":             "%REQ(UBER-TRACE-ID)%",
	"upstream_cluster":          "%UPSTREAM_CLUSTER%",
	"upstream_host":             "%UPSTREAM_HOST%",
	"upstream_local_address":    "%UPSTREAM_LOCAL_ADDRESS%",
	"upstream_service_time":     "%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%",
	"user_agent":                "%REQ(USER-AGENT)%",
	"x_forwarded_for":           "%REQ(X-FORWARDED-FOR)%",
}

JSONFields is the canonical translation table for JSON fields to Envoy log template formats, used for specifying fields for Envoy to log when JSON logging is enabled. Only fields specified in this map may be used for JSON logging.

Functions

func AppendHeader added in v1.0.0

func AppendHeader(key, value string) *envoy_api_v2_core.HeaderValueOption

func Bootstrap added in v0.10.0

func Bootstrap(c *BootstrapConfig) *bootstrap.Bootstrap

Bootstrap creates a new v2 Bootstrap configuration.

func Cluster

func Cluster(c *dag.Cluster) *v2.Cluster

Cluster creates new v2.Cluster from dag.Cluster.

func ClusterCommonLBConfig added in v0.8.0

func ClusterCommonLBConfig() *v2.Cluster_CommonLbConfig

ClusterCommonLBConfig creates a *v2.Cluster_CommonLbConfig with HealthyPanicThreshold disabled.

func ClusterDiscoveryType added in v1.0.0

func ClusterDiscoveryType(t v2.Cluster_DiscoveryType) *v2.Cluster_Type

ClusterDiscoveryType returns the type of a ClusterDiscovery as a Cluster_type.

func ClusterLoadAssignment added in v1.0.0

func ClusterLoadAssignment(name string, addrs ...*envoy_api_v2_core.Address) *v2.ClusterLoadAssignment

ClusterLoadAssignment returns a *v2.ClusterLoadAssignment with a single LocalityLbEndpoints of the supplied addresses.

func Clustername added in v0.7.0

func Clustername(cluster *dag.Cluster) string

Clustername returns the name of the CDS cluster for this service.

func ConfigSource added in v0.7.0

func ConfigSource(cluster string) *envoy_api_v2_core.ConfigSource

ConfigSource returns a *envoy_api_v2_core.ConfigSource for cluster.

func DownstreamTLSContext added in v0.7.0

func DownstreamTLSContext(secretName string, tlsMinProtoVersion envoy_api_v2_auth.TlsParameters_TlsProtocol, alpnProtos ...string) *envoy_api_v2_auth.DownstreamTlsContext

DownstreamTLSContext creates a new DownstreamTlsContext.

func Endpoints added in v1.0.0

Endpoints returns a slice of LocalityLbEndpoints. The slice contains one entry, with one LbEndpoint per *envoy_api_v2_core.Address supplied.

func FileAccessLogEnvoy added in v1.0.0

func FileAccessLogEnvoy(path string) []*accesslog.AccessLog

FileAccessLogEnvoy returns a new file based access log filter that will output Envoy's default access logs.

func FileAccessLogJSON added in v1.0.0

func FileAccessLogJSON(path string, keys []string) []*accesslog.AccessLog

FileAccessLogJSON returns a new file based access log filter that will log in JSON format

func FilterChain added in v1.0.0

FilterChain retruns a *envoy_api_v2_listener.FilterChain for the supplied filters.

func FilterChainTLS added in v1.0.0

func FilterChainTLS(domain string, secret *dag.Secret, filters []*envoy_api_v2_listener.Filter, tlsMinProtoVersion envoy_api_v2_auth.TlsParameters_TlsProtocol, alpnProtos ...string) *envoy_api_v2_listener.FilterChain

FilterChainTLS returns a TLS enabled envoy_api_v2_listener.FilterChain,

func FilterChains added in v1.0.0

FilterChains returns a []*envoy_api_v2_listener.FilterChain for the supplied filters.

func Filters added in v1.0.0

Filters returns a []*envoy_api_v2_listener.Filter for the supplied filters.

func HTTPConnectionManager added in v0.7.0

func HTTPConnectionManager(routename string, accesslogger []*accesslog.AccessLog) *envoy_api_v2_listener.Filter

HTTPConnectionManager creates a new HTTP Connection Manager filter for the supplied route and access log.

func LBEndpoint added in v0.7.0

LBEndpoint creates a new LbEndpoint.

func Listener

func Listener(name, address string, port int, lf []*envoy_api_v2_listener.ListenerFilter, filters ...*envoy_api_v2_listener.Filter) *v2.Listener

Listener returns a new v2.Listener for the supplied address, port, and filters.

func ListenerFilters added in v1.0.0

ListenerFilters returns a []*envoy_api_v2_listener.ListenerFilter for the supplied listener filters.

func ProxyProtocol added in v0.10.0

func ProxyProtocol() *envoy_api_v2_listener.ListenerFilter

ProxyProtocol returns a new Proxy Protocol listener filter.

func Route

Route returns a *envoy_api_v2_route.Route for the supplied match and action.

func RouteConfiguration added in v1.0.0

func RouteConfiguration(name string, virtualhosts ...*envoy_api_v2_route.VirtualHost) *v2.RouteConfiguration

RouteConfiguration returns a *v2.RouteConfiguration.

func RoutePrefix added in v1.0.0

func RoutePrefix(prefix string, headers ...dag.HeaderCondition) *envoy_api_v2_route.RouteMatch

RoutePrefix returns a prefix matcher.

func RouteRegex added in v1.0.0

func RouteRegex(regex string) *envoy_api_v2_route.RouteMatch

RouteRegex returns a regex matcher.

func RouteRoute added in v0.7.0

func RouteRoute(r *dag.Route) *envoy_api_v2_route.Route_Route

RouteRoute creates a *envoy_api_v2_route.Route_Route for the services supplied. If len(services) is greater than one, the route's action will be a weighted cluster.

func Routes added in v1.0.0

func Routes(routes ...*envoy_api_v2_route.Route) []*envoy_api_v2_route.Route

Routes returns a []*envoy_api_v2_route.Route for the supplied routes.

func Secret added in v1.0.0

func Secret(s *dag.Secret) *envoy_api_v2_auth.Secret

Secret creates new envoy_api_v2_auth.Secret from secret.

func Secretname added in v1.0.0

func Secretname(s *dag.Secret) string

Secretname returns the name of the SDS secret for this secret.

func SocketAddress added in v0.7.0

func SocketAddress(address string, port int) *envoy_api_v2_core.Address

SocketAddress creates a new TCP envoy_api_v2_core.Address.

func StaticClusterLoadAssignment added in v1.0.0

func StaticClusterLoadAssignment(service *dag.Service) *v2.ClusterLoadAssignment

StaticClusterLoadAssignment creates a *v2.ClusterLoadAssignment pointing to the external DNS address of the service

func StatsListener added in v1.0.0

func StatsListener(address string, port int) *v2.Listener

StatsListener returns a *v2.Listener configured to serve prometheus metrics on /stats.

func TCPProxy added in v0.8.0

func TCPProxy(statPrefix string, proxy *dag.TCPProxy, accesslogger []*accesslog.AccessLog) *envoy_api_v2_listener.Filter

TCPProxy creates a new TCPProxy filter.

func TLSInspector added in v0.7.0

func TLSInspector() *envoy_api_v2_listener.ListenerFilter

TLSInspector returns a new TLS inspector listener filter.

func UpgradeHTTPS added in v0.7.0

func UpgradeHTTPS() *envoy_api_v2_route.Route_Redirect

UpgradeHTTPS returns a route Action that redirects the request to HTTPS.

func UpstreamTLSContext added in v0.7.0

func UpstreamTLSContext(ca []byte, subjectName string, alpnProtocols ...string) *envoy_api_v2_auth.UpstreamTlsContext

UpstreamTLSContext creates an envoy_api_v2_auth.UpstreamTlsContext. By default UpstreamTLSContext returns a HTTP/1.1 TLS enabled context. A list of additional ALPN protocols can be provided.

func VirtualHost

func VirtualHost(hostname string, routes ...*envoy_api_v2_route.Route) *envoy_api_v2_route.VirtualHost

VirtualHost creates a new route.VirtualHost.

Types

type BootstrapConfig added in v0.10.0

type BootstrapConfig struct {
	// AdminAccessLogPath is the path to write the access log for the administration server.
	// Defaults to /dev/null.
	AdminAccessLogPath string

	// AdminAddress is the TCP address that the administration server will listen on.
	// Defaults to 127.0.0.1.
	AdminAddress string

	// AdminPort is the port that the administration server will listen on.
	// Defaults to 9001.
	AdminPort int

	// XDSAddress is the TCP address of the gRPC XDS management server.
	// Defaults to 127.0.0.1.
	XDSAddress string

	// XDSGRPCPort is the management server port that provides the v2 gRPC API.
	// Defaults to 8001.
	XDSGRPCPort int

	// Namespace is the namespace where Contour is running
	Namespace string

	//GrpcCABundle is the filename that contains a CA certificate chain that can
	//verify the client cert.
	GrpcCABundle string

	// GrpcClientCert is the filename that contains a client certificate. May contain a full bundle if you
	// don't want to pass a CA Bundle.
	GrpcClientCert string

	// GrpcClientKey is the filename that contains a client key for secure gRPC with TLS.
	GrpcClientKey string
}

BootstrapConfig holds configuration values for a v2.Bootstrap.

type ConfigWriter

type ConfigWriter struct {
	// AdminAccessLogPath is the path to write the access log for the administration server.
	// Defaults to /dev/null.
	AdminAccessLogPath string

	// AdminAddress is the TCP address that the administration server will listen on.
	// Defaults to 127.0.0.1.
	AdminAddress string

	// AdminPort is the port that the administration server will listen on.
	// Defaults to 9001.
	AdminPort int

	// StatsAddress is the address that Envoy will listen on which serves the /stats path
	// Defaults to 0.0.0.0
	StatsAddress string

	// StatsPort is the port that Envoy will listen on which serves the /stats path
	// Defaults to 8002
	StatsPort int

	// XDSAddress is the TCP address of the XDS management server. For JSON configurations
	// this is the address of the v1 REST API server. For YAML configurations this is the
	// address of the v2 gRPC management server.
	// Defaults to 127.0.0.1.
	XDSAddress string

	// XDSRESTPort is the management server port that provides the v1 REST API.
	// Defaults to 8000.
	XDSRESTPort int

	// XDSGRPCPort is the management server port that provides the v2 gRPC API.
	// Defaults to 8001.
	XDSGRPCPort int
}

A ConfigWriter knows how to write a bootstap Envoy configuration in YAML format.

func (*ConfigWriter) WriteYAML

func (c *ConfigWriter) WriteYAML(w io.Writer) error

WriteYAML writes the configuration to the supplied writer in YAML v2 format. If the supplied io.Writer is a file, it should end with a .yaml extension.

Jump to

Keyboard shortcuts

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