contour

package
v0.0.0-...-146a38b Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: BSD-3-Clause, Apache-2.0 Imports: 25 Imported by: 0

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

Examples

Constants

View Source
const (
	ENVOY_HTTP_LISTENER            = "ingress_http"
	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
)
View Source
const DEFAULT_INGRESS_CLASS = "contour"

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheHandler

type CacheHandler struct {
	ListenerCache
	RouteCache
	ClusterCache

	IngressRouteStatus *k8s.IngressRouteStatus
	logrus.FieldLogger
	*metrics.Metrics
}

CacheHandler manages the state of xDS caches.

func (*CacheHandler) OnChange

func (ch *CacheHandler) OnChange(b *dag.Builder)

type ClusterCache

type ClusterCache struct {
	// contains filtered or unexported fields
}

ClusterCache manages the contents of the gRPC CDS cache.

func (*ClusterCache) Register

func (c *ClusterCache) Register(ch chan int, last int)

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 Cache. It functions of a sequence counter, if the value of last supplied to Register is less than the Cache's internal counter, then the caller has missed at least one notification and will fire immediately.

Sends by the broadcaster to ch must not block, therefor ch must have a capacity of at least 1.

func (*ClusterCache) Update

func (c *ClusterCache) Update(v map[string]*v2.Cluster)

Update replaces the contents of the cache with the supplied map.

func (*ClusterCache) Values

func (c *ClusterCache) Values(filter func(string) bool) []proto.Message

Values returns a slice of the value stored in the cache.

type Cond

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/heptio/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

func (c *Cond) Notify()

Notify notifies all registered waiters that an event has ocured.

func (*Cond) Register

func (c *Cond) Register(ch chan int, last int)

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, therefor ch must have a capacity of at least 1.

type EndpointsTranslator

type EndpointsTranslator struct {
	logrus.FieldLogger

	Cond
	// contains filtered or unexported fields
}

A EndpointsTranslator translates Kubernetes Endpoints objects into Envoy ClusterLoadAssignment objects.

func (*EndpointsTranslator) Add

func (c *EndpointsTranslator) Add(assignments ...*v2.ClusterLoadAssignment)

Add adds an entry to the cache. If a ClusterLoadAssignment with the same name exists, it is replaced.

func (*EndpointsTranslator) OnAdd

func (e *EndpointsTranslator) OnAdd(obj interface{})

func (*EndpointsTranslator) OnDelete

func (e *EndpointsTranslator) OnDelete(obj interface{})

func (*EndpointsTranslator) OnUpdate

func (e *EndpointsTranslator) OnUpdate(oldObj, newObj interface{})

func (*EndpointsTranslator) Remove

func (c *EndpointsTranslator) Remove(names ...string)

Remove removes the named entry from the cache. If the entry is not present in the cache, the operation is a no-op.

type HoldoffNotifier

type HoldoffNotifier struct {
	// Notifier to be called after delay.
	Notifier
	*metrics.Metrics

	logrus.FieldLogger
	// contains filtered or unexported fields
}

A HoldoffNotifier delays calls to OnChange in the hope of coalescing rapid calls into a single update.

func (*HoldoffNotifier) OnChange

func (hn *HoldoffNotifier) OnChange(builder *dag.Builder)

type ListenerCache

type ListenerCache 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 configurs all listeners to expect a PROXY protocol
	// V1 header on new connections.
	// If not set, defaults to false.
	UseProxyProto bool
	// contains filtered or unexported fields
}

ListenerCache manages the contents of the gRPC LDS cache.

func (*ListenerCache) Register

func (c *ListenerCache) Register(ch chan int, last int)

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 Cache. It functions of a sequence counter, if the value of last supplied to Register is less than the Cache's internal counter, then the caller has missed at least one notification and will fire immediately.

Sends by the broadcaster to ch must not block, therefor ch must have a capacity of at least 1.

func (*ListenerCache) Update

func (c *ListenerCache) Update(v map[string]*v2.Listener)

Update replaces the contents of the cache with the supplied map.

func (*ListenerCache) Values

func (c *ListenerCache) Values(filter func(string) bool) []proto.Message

Values returns a slice of the value stored in the cache.

type Notifier

type Notifier interface {
	// OnChange is called to notify the callee that the
	// contents of the *dag.Builder have changed.
	OnChange(*dag.Builder)
}

Notifier supplies a callback to be called when changes occur to a dag.Builder.

type ResourceEventHandler

type ResourceEventHandler struct {
	// Contour's IngressClass.
	// If not set, defaults to DEFAULT_INGRESS_CLASS.
	IngressClass string

	dag.Builder

	Notifier

	*metrics.Metrics
}

ResourceEventHandler implements cache.ResourceEventHandler, filters k8s watcher events towards a dag.Builder (which also implements the same interface) and calls through to the CacheHandler to notify it that the contents of the dag.Builder have changed.

func (*ResourceEventHandler) OnAdd

func (reh *ResourceEventHandler) OnAdd(obj interface{})

func (*ResourceEventHandler) OnDelete

func (reh *ResourceEventHandler) OnDelete(obj interface{})

func (*ResourceEventHandler) OnUpdate

func (reh *ResourceEventHandler) OnUpdate(oldObj, newObj interface{})

type RouteCache

type RouteCache struct {
	// contains filtered or unexported fields
}

RouteCache manages the contents of the gRPC RDS cache.

func (*RouteCache) Register

func (c *RouteCache) Register(ch chan int, last int)

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 Cache. It functions of a sequence counter, if the value of last supplied to Register is less than the Cache's internal counter, then the caller has missed at least one notification and will fire immediately.

Sends by the broadcaster to ch must not block, therefor ch must have a capacity of at least 1.

func (*RouteCache) Update

func (c *RouteCache) Update(v map[string]*v2.RouteConfiguration)

Update replaces the contents of the cache with the supplied map.

func (*RouteCache) Values

func (c *RouteCache) Values(filter func(string) bool) []proto.Message

Values returns a slice of the value stored in the cache.

Jump to

Keyboard shortcuts

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