Documentation
¶
Overview ¶
Package contour contains the translation business logic that listens to Kubernetes ResourceEventHandler events and translates those into additions/deletions in caches connected to the Envoy xDS gRPC API server.
Package contour contains the translation business logic that listens to Kubernetes ResourceEventHandler events and translates those into additions/deletions in caches connected to the Envoy xDS gRPC API server.
Package contour contains the translation business logic that listens to Kubernetes ResourceEventHandler events and translates those into additions/deletions in caches connected to the Envoy xDS gRPC API server.
Index ¶
- Constants
- func ObserversOf(in []ResourceCache) []dag.Observer
- func ResourcesOf(in []ResourceCache) []xds.Resource
- type ClusterCache
- type Cond
- type EndpointsTranslator
- func (e *EndpointsTranslator) Add(a *v2.ClusterLoadAssignment)
- func (e *EndpointsTranslator) Contents() []proto.Message
- func (e *EndpointsTranslator) OnAdd(obj interface{})
- func (e *EndpointsTranslator) OnChange(d *dag.DAG)
- func (e *EndpointsTranslator) OnDelete(obj interface{})
- func (e *EndpointsTranslator) OnUpdate(oldObj, newObj interface{})
- func (e *EndpointsTranslator) Query(names []string) []proto.Message
- func (e *EndpointsTranslator) Remove(name string)
- func (*EndpointsTranslator) TypeURL() string
- type EventHandler
- type EventRecorder
- type ListenerCache
- type ListenerConfig
- type RebuildMetricsObserver
- type ResourceCache
- type RouteCache
- type SecretCache
Examples ¶
Constants ¶
const ( ENVOY_HTTP_LISTENER = "ingress_http" ENVOY_FALLBACK_ROUTECONFIG = "ingress_fallbackcert" ENVOY_HTTPS_LISTENER = "ingress_https" DEFAULT_HTTP_ACCESS_LOG = "/dev/stdout" DEFAULT_HTTP_LISTENER_ADDRESS = "0.0.0.0" DEFAULT_HTTP_LISTENER_PORT = 8080 DEFAULT_HTTPS_ACCESS_LOG = "/dev/stdout" DEFAULT_HTTPS_LISTENER_ADDRESS = DEFAULT_HTTP_LISTENER_ADDRESS DEFAULT_HTTPS_LISTENER_PORT = 8443 DEFAULT_ACCESS_LOG_TYPE = "envoy" )
Variables ¶
This section is empty.
Functions ¶
func ObserversOf ¶ added in v1.8.0
func ObserversOf(in []ResourceCache) []dag.Observer
ObserversOf transliterates a slice of ResourceCache into a slice of dag.Observer.
func ResourcesOf ¶ added in v1.8.0
func ResourcesOf(in []ResourceCache) []xds.Resource
ResourcesOf transliterates a slice of ResourceCache into a slice of xds.Resource.
Types ¶
type ClusterCache ¶
type ClusterCache struct {
Cond
// contains filtered or unexported fields
}
ClusterCache manages the contents of the gRPC CDS cache.
func (*ClusterCache) Contents ¶ added in v1.0.0
func (c *ClusterCache) Contents() []proto.Message
Contents returns a copy of the cache's contents.
func (*ClusterCache) OnChange ¶ added in v1.8.0
func (c *ClusterCache) OnChange(root *dag.DAG)
func (*ClusterCache) Query ¶ added in v1.0.0
func (c *ClusterCache) Query(names []string) []proto.Message
func (*ClusterCache) TypeURL ¶ added in v1.0.0
func (*ClusterCache) TypeURL() string
type Cond ¶ added in v0.3.0
type Cond struct {
// contains filtered or unexported fields
}
Cond implements a condition variable, a rendezvous point for goroutines waiting for or announcing the ocurence of an event.
Unlike sync.Cond, Cond communciates with waiters via channels registered by the waiters. This permits goroutines to wait on Cond events using select.
Example ¶
package main
import (
"context"
"fmt"
"time"
"github.com/projectcontour/contour/internal/contour"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
ch := make(chan int, 1)
last := 0
var c contour.Cond
go func() {
for {
time.Sleep(100 * time.Millisecond)
c.Notify()
}
}()
for {
c.Register(ch, last)
select {
case last = <-ch:
fmt.Println("notification received:", last)
case <-ctx.Done():
fmt.Println("timeout")
return
}
}
}
Output:
func (*Cond) Notify ¶ added in v0.3.0
Notify notifies all interested waiters that an event has ocured.
func (*Cond) Register ¶ added in v0.3.0
Register registers ch to receive a value when Notify is called. The value of last is the count of the times Notify has been called on this Cond. It functions of a sequence counter, if the value of last supplied to Register is less than the Conds internal counter, then the caller has missed at least one notification and will fire immediately.
Sends by the broadcaster to ch must not block, therefore ch must have a capacity of at least 1.
type EndpointsTranslator ¶ added in v0.6.0
type EndpointsTranslator struct {
Cond
logrus.FieldLogger
// contains filtered or unexported fields
}
A EndpointsTranslator translates Kubernetes Endpoints objects into Envoy ClusterLoadAssignment objects.
func (*EndpointsTranslator) Add ¶ added in v0.6.0
func (e *EndpointsTranslator) Add(a *v2.ClusterLoadAssignment)
Add adds an entry to the cache. If a ClusterLoadAssignment with the same name exists, it is replaced.
func (*EndpointsTranslator) Contents ¶ added in v1.0.0
func (e *EndpointsTranslator) Contents() []proto.Message
Contents returns a copy of the contents of the cache.
func (*EndpointsTranslator) OnAdd ¶ added in v0.6.0
func (e *EndpointsTranslator) OnAdd(obj interface{})
func (*EndpointsTranslator) OnChange ¶ added in v1.8.0
func (e *EndpointsTranslator) OnChange(d *dag.DAG)
func (*EndpointsTranslator) OnDelete ¶ added in v0.6.0
func (e *EndpointsTranslator) OnDelete(obj interface{})
func (*EndpointsTranslator) OnUpdate ¶ added in v0.6.0
func (e *EndpointsTranslator) OnUpdate(oldObj, newObj interface{})
func (*EndpointsTranslator) Query ¶ added in v1.0.0
func (e *EndpointsTranslator) Query(names []string) []proto.Message
func (*EndpointsTranslator) Remove ¶ added in v0.6.0
func (e *EndpointsTranslator) Remove(name string)
Remove removes the named entry from the cache. If the entry is not present in the cache, the operation is a no-op.
func (*EndpointsTranslator) TypeURL ¶ added in v1.0.0
func (*EndpointsTranslator) TypeURL() string
type EventHandler ¶ added in v1.0.0
type EventHandler struct {
Builder dag.Builder
Observer dag.Observer
HoldoffDelay, HoldoffMaxDelay time.Duration
StatusClient k8s.StatusClient
logrus.FieldLogger
// IsLeader will become ready to read when this EventHandler becomes
// the leader. If IsLeader is not readable, or nil, status events will
// be suppressed.
IsLeader chan struct{}
// Sequence is a channel that receives a incrementing sequence number
// for each update processed. The updates may be processed immediately, or
// delayed by a holdoff timer. In each case a non blocking send to Sequence
// will be made once the resource update is received (note
// that the DAG is not guaranteed to be called each time).
Sequence chan int
// contains filtered or unexported fields
}
EventHandler implements cache.ResourceEventHandler, filters k8s events towards a dag.Builder and calls through to the Observer to notify it that a new DAG is available.
func (*EventHandler) OnAdd ¶ added in v1.0.0
func (e *EventHandler) OnAdd(obj interface{})
func (*EventHandler) OnDelete ¶ added in v1.0.0
func (e *EventHandler) OnDelete(obj interface{})
func (*EventHandler) OnUpdate ¶ added in v1.0.0
func (e *EventHandler) OnUpdate(oldObj, newObj interface{})
func (*EventHandler) Start ¶ added in v1.0.0
func (e *EventHandler) Start() func(<-chan struct{}) error
Start initializes the EventHandler and returns a function suitable for registration with a workgroup.Group.
func (*EventHandler) UpdateNow ¶ added in v1.0.0
func (e *EventHandler) UpdateNow()
UpdateNow enqueues a DAG update subject to the holdoff timer.
type EventRecorder ¶ added in v1.2.0
type EventRecorder struct {
Next cache.ResourceEventHandler
Counter *prometheus.CounterVec
}
EventRecorder records the count and kind of events forwarded to another ResourceEventHandler.
func (*EventRecorder) OnAdd ¶ added in v1.2.0
func (e *EventRecorder) OnAdd(obj interface{})
func (*EventRecorder) OnDelete ¶ added in v1.2.0
func (e *EventRecorder) OnDelete(obj interface{})
func (*EventRecorder) OnUpdate ¶ added in v1.2.0
func (e *EventRecorder) OnUpdate(oldObj, newObj interface{})
type ListenerCache ¶
type ListenerCache struct {
Config ListenerConfig
Cond
// contains filtered or unexported fields
}
ListenerCache manages the contents of the gRPC LDS cache.
func NewListenerCache ¶ added in v1.0.0
func NewListenerCache(config ListenerConfig, address string, port int) *ListenerCache
NewListenerCache returns an instance of a ListenerCache
func (*ListenerCache) Contents ¶ added in v1.0.0
func (c *ListenerCache) Contents() []proto.Message
Contents returns a copy of the cache's contents.
func (*ListenerCache) OnChange ¶ added in v1.8.0
func (l *ListenerCache) OnChange(root *dag.DAG)
func (*ListenerCache) Query ¶ added in v1.0.0
func (c *ListenerCache) Query(names []string) []proto.Message
Query returns the proto.Messages in the ListenerCache that match a slice of strings
func (*ListenerCache) TypeURL ¶ added in v1.0.0
func (*ListenerCache) TypeURL() string
type ListenerConfig ¶ added in v1.8.0
type ListenerConfig struct {
// Envoy's HTTP (non TLS) listener address.
// If not set, defaults to DEFAULT_HTTP_LISTENER_ADDRESS.
HTTPAddress string
// Envoy's HTTP (non TLS) listener port.
// If not set, defaults to DEFAULT_HTTP_LISTENER_PORT.
HTTPPort int
// Envoy's HTTP (non TLS) access log path.
// If not set, defaults to DEFAULT_HTTP_ACCESS_LOG.
HTTPAccessLog string
// Envoy's HTTPS (TLS) listener address.
// If not set, defaults to DEFAULT_HTTPS_LISTENER_ADDRESS.
HTTPSAddress string
// Envoy's HTTPS (TLS) listener port.
// If not set, defaults to DEFAULT_HTTPS_LISTENER_PORT.
HTTPSPort int
// Envoy's HTTPS (TLS) access log path.
// If not set, defaults to DEFAULT_HTTPS_ACCESS_LOG.
HTTPSAccessLog string
// UseProxyProto configures all listeners to expect a PROXY
// V1 or V2 preamble.
// If not set, defaults to false.
UseProxyProto bool
// MinimumTLSVersion defines the minimum TLS protocol version the proxy should accept.
MinimumTLSVersion envoy_api_v2_auth.TlsParameters_TlsProtocol
// DefaultHTTPVersions defines the default set of HTTP
// versions the proxy should accept. If not specified, all
// supported versions are accepted. This is applied to both
// HTTP and HTTPS listeners but has practical effect only for
// HTTPS, because we don't support h2c.
DefaultHTTPVersions []envoy.HTTPVersionType
// AccessLogType defines if Envoy logs should be output as Envoy's default or JSON.
// Valid values: 'envoy', 'json'
// If not set, defaults to 'envoy'
AccessLogType string
// AccessLogFields sets the fields that should be shown in JSON logs.
// Valid entries are the keys from internal/envoy/accesslog.go:jsonheaders
// Defaults to a particular set of fields.
AccessLogFields []string
// RequestTimeout configures the request_timeout for all Connection Managers.
RequestTimeout timeout.Setting
// ConnectionIdleTimeout configures the common_http_protocol_options.idle_timeout for all
// Connection Managers.
ConnectionIdleTimeout timeout.Setting
// StreamIdleTimeout configures the stream_idle_timeout for all Connection Managers.
StreamIdleTimeout timeout.Setting
// MaxConnectionDuration configures the common_http_protocol_options.max_connection_duration for all
// Connection Managers.
MaxConnectionDuration timeout.Setting
// ConnectionShutdownGracePeriod configures the drain_timeout for all Connection Managers.
ConnectionShutdownGracePeriod timeout.Setting
}
ListenerConfig holds configuration parameters for building Envoy Listeners.
type RebuildMetricsObserver ¶ added in v1.8.0
type RebuildMetricsObserver struct {
// Metrics to emit.
Metrics *metrics.Metrics
// IsLeader will become ready to read when this EventHandler becomes
// the leader. If IsLeader is not readable, or nil, status events will
// be suppressed.
IsLeader chan struct{}
// NextObserver contains the stack of dag.Observers that act on DAG rebuilds.
NextObserver dag.Observer
}
RebuildMetricsObserver is a dag.Observer that emits metrics for DAG rebuilds.
func (*RebuildMetricsObserver) OnChange ¶ added in v1.8.0
func (m *RebuildMetricsObserver) OnChange(d *dag.DAG)
type ResourceCache ¶ added in v1.8.0
ResourceCache is a store of an xDS resource type. It is able to visit the dag.DAG to update the its resource collection, then serve those resources over xDS.
type RouteCache ¶ added in v0.6.0
type RouteCache struct {
Cond
// contains filtered or unexported fields
}
RouteCache manages the contents of the gRPC RDS cache.
func (*RouteCache) Contents ¶ added in v1.0.0
func (c *RouteCache) Contents() []proto.Message
Contents returns a copy of the cache's contents.
func (*RouteCache) OnChange ¶ added in v1.8.0
func (r *RouteCache) OnChange(root *dag.DAG)
func (*RouteCache) Query ¶ added in v1.0.0
func (c *RouteCache) Query(names []string) []proto.Message
Query searches the RouteCache for the named RouteConfiguration entries.
func (*RouteCache) TypeURL ¶ added in v1.0.0
func (*RouteCache) TypeURL() string
TypeURL returns the string type of RouteCache Resource.
func (*RouteCache) Update ¶ added in v0.6.0
func (c *RouteCache) Update(v map[string]*v2.RouteConfiguration)
Update replaces the contents of the cache with the supplied map.
type SecretCache ¶ added in v1.0.0
type SecretCache struct {
Cond
// contains filtered or unexported fields
}
SecretCache manages the contents of the gRPC SDS cache.
func (*SecretCache) Contents ¶ added in v1.0.0
func (c *SecretCache) Contents() []proto.Message
Contents returns a copy of the cache's contents.
func (*SecretCache) OnChange ¶ added in v1.8.0
func (s *SecretCache) OnChange(root *dag.DAG)
func (*SecretCache) Query ¶ added in v1.0.0
func (c *SecretCache) Query(names []string) []proto.Message
func (*SecretCache) TypeURL ¶ added in v1.0.0
func (*SecretCache) TypeURL() string
func (*SecretCache) Update ¶ added in v1.0.0
func (c *SecretCache) Update(v map[string]*envoy_api_v2_auth.Secret)
Update replaces the contents of the cache with the supplied map.