This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
/
types.go
143 lines (115 loc) · 5.12 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Package envoy implements utility routines related to Envoy proxy, and models an instance of a proxy
// to be able to generate XDS configurations for it.
package envoy
import (
"github.com/openservicemesh/osm/pkg/logger"
)
var (
// XDSResponseOrder is the order in which we send xDS responses: CDS, EDS, LDS, RDS
// See: https://github.com/envoyproxy/go-control-plane/issues/59
XDSResponseOrder = []TypeURI{TypeCDS, TypeEDS, TypeLDS, TypeRDS, TypeSDS}
log = logger.New("envoy")
)
// TypeURI is a string describing the Envoy xDS payload.
type TypeURI string
// IsWildcardTypeURI returns if a given TypeURI is an expected wildcard TypeURI or not.
// XDS proto defines general client behavior as:
// "Envoy will always use wildcard subscriptions for Listener and Cluster resources"
// https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol#client-behavior
func IsWildcardTypeURI(t TypeURI) bool {
return t == TypeCDS || t == TypeLDS
}
func (t TypeURI) String() string {
return string(t)
}
// Short returns an abbreviated version of the TypeURI, which is easier to spot in logs and metrics.
func (t TypeURI) Short() string {
return XDSShortURINames[t]
}
// ValidURI defines valid URIs
var ValidURI = map[string]TypeURI{
string(TypeEmptyURI): TypeEmptyURI,
string(TypeSDS): TypeSDS,
string(TypeCDS): TypeCDS,
string(TypeLDS): TypeLDS,
string(TypeRDS): TypeRDS,
string(TypeEDS): TypeEDS,
string(TypeUpstreamTLSContext): TypeUpstreamTLSContext,
string(TypeZipkinConfig): TypeZipkinConfig,
}
// XDSShortURINames are shortened versions of the URI types
var XDSShortURINames = map[TypeURI]string{
TypeEmptyURI: "EmptyURI",
TypeSDS: "SDS",
TypeCDS: "CDS",
TypeLDS: "LDS",
TypeRDS: "RDS",
TypeEDS: "EDS",
}
// Envoy TypeURIs
const (
// TypeEmptyURI is an Empty URI type representation
TypeEmptyURI TypeURI = ""
// TypeSDS is the SDS type URI.
TypeSDS TypeURI = "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret"
// TypeCDS is the CDS type URI.
TypeCDS TypeURI = "type.googleapis.com/envoy.config.cluster.v3.Cluster"
// TypeLDS is the LDS type URI.
TypeLDS TypeURI = "type.googleapis.com/envoy.config.listener.v3.Listener"
// TypeRDS is the RDS type URI.
TypeRDS TypeURI = "type.googleapis.com/envoy.config.route.v3.RouteConfiguration"
// TypeEDS is the EDS type URI.
TypeEDS TypeURI = "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment"
// TypeUpstreamTLSContext is an Envoy type URI.
TypeUpstreamTLSContext TypeURI = "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext"
// TypeZipkinConfig is an Envoy type URI.
TypeZipkinConfig TypeURI = "type.googleapis.com/envoy.config.trace.v3.ZipkinConfig"
// TypeADS is not actually used by Envoy - but useful within OSM for logging
TypeADS TypeURI = "ADS"
)
// Filter names - can be any name (not used by Envoy to determine the filter to use)
// *Note: HTTP typed filters referenced in RDS require a wellknown name
const (
// HTTP filters
HTTPConnectionManagerFilterName = "http_connection_manager"
HTTPRouterFilterName = "http_router"
HTTPLuaFilterName = "http_lua"
HTTPExtAuthzFilterName = "http_external_authz"
HTTPHealthCheckFilterName = "http_health_check"
// The HTTP typed filters referenced in the RDS configuration still need to
// use wellknown names. These filters are configured as a map where the key is
// the filter name and value is the marshalled filter config.
// See https://github.com/envoyproxy/envoy/issues/21759#issuecomment-1163570994
HTTPRBACFilterName = "envoy.filters.http.rbac"
HTTPLocalRateLimitFilterName = "envoy.filters.http.local_ratelimit"
// Network (L4) filters
TCPProxyFilterName = "tcp_proxy"
L4LocalRateLimitFilterName = "l4_local_rate_limit"
L4RBACFilterName = "l4_rbac"
// Listener filters
OriginalDstFilterName = "original_dst"
TLSInspectorFilterName = "tls_inspector"
HTTPInspectorFilterName = "http_inspector"
)
// Filter TypeURLs - used by Envoy to determine the filter to use
const (
HTTPRouterFilterTypeURL = "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
HTTPRBACFilterTypeURL = "type.googleapis.com/envoy.extensions.filters.http.rbac.v3.RBAC"
OriginalDstFilterTypeURL = "type.googleapis.com/envoy.extensions.filters.listener.original_dst.v3.OriginalDst"
TLSInspectorFilterTypeURL = "type.googleapis.com/envoy.extensions.filters.listener.tls_inspector.v3.TlsInspector"
HTTPInspectorFilterTypeURL = "type.googleapis.com/envoy.extensions.filters.listener.http_inspector.v3.HttpInspector"
)
const (
// EnvoyActiveHealthCheckPath is the HTTP endpoint to be used to receive
// active health checks.
EnvoyActiveHealthCheckPath = "/healthz/osm"
// EnvoyActiveHealthCheckHeaderKey is the HTTP header key used to identify
// active health check traffic.
EnvoyActiveHealthCheckHeaderKey = "x-osm-envoy-healthcheck"
)
// ProxyKind is the type used to define the proxy's kind
type ProxyKind string
const (
// KindSidecar implies the proxy is a sidecar
KindSidecar ProxyKind = "sidecar"
)