Documentation
¶
Index ¶
- Constants
- Variables
- func GatewayAPIHTTPMatchToIR(match gatewayv1.HTTPRouteMatch) *ir.IRHTTPMatch
- func HandleSyncResult(err error) (ctrl.Result, error)
- func MappingStrategyAnnotationToIR(obj client.Object) (ir.IRMappingStrategy, error)
- type AddHeadersConfig
- type ControllerEventHandler
- func (e *ControllerEventHandler) Create(_ context.Context, evt event.CreateEvent, ...)
- func (e *ControllerEventHandler) Delete(_ context.Context, evt event.DeleteEvent, ...)
- func (e *ControllerEventHandler) Generic(_ context.Context, evt event.GenericEvent, ...)
- func (e *ControllerEventHandler) Update(ctx context.Context, evt event.UpdateEvent, ...)
- type DrainState
- type Driver
- func (d *Driver) DeleteGateway(gateway *gatewayv1.Gateway) error
- func (d *Driver) DeleteHTTPRoute(httproute *gatewayv1.HTTPRoute) error
- func (d *Driver) DeleteIngress(ingress *netv1.Ingress) error
- func (d *Driver) DeleteNamedGateway(n types.NamespacedName) error
- func (d *Driver) DeleteNamedHTTPRoute(n types.NamespacedName) error
- func (d *Driver) DeleteNamedIngress(n types.NamespacedName) error
- func (d *Driver) DeleteNamedTCPRoute(n types.NamespacedName) error
- func (d *Driver) DeleteNamedTLSRoute(n types.NamespacedName) error
- func (d *Driver) DeleteNamespace(name string) error
- func (d *Driver) DeleteReferenceGrant(n types.NamespacedName) error
- func (d *Driver) DeleteTCPRoute(tcpRoute *gatewayv1alpha2.TCPRoute) error
- func (d *Driver) DeleteTLSRoute(tlsRoute *gatewayv1alpha2.TLSRoute) error
- func (d *Driver) GetStore() store.Storer
- func (d *Driver) PrintState(setupLog logr.Logger)
- func (d *Driver) Seed(ctx context.Context, c client.Reader, listOpts ...client.ListOption) error
- func (d *Driver) Sync(ctx context.Context, c client.Client) error
- func (d *Driver) SyncEndpoints(ctx context.Context, c client.Client) error
- func (d *Driver) UpdateGateway(gateway *gatewayv1.Gateway) (*gatewayv1.Gateway, error)
- func (d *Driver) UpdateHTTPRoute(httproute *gatewayv1.HTTPRoute) (*gatewayv1.HTTPRoute, error)
- func (d *Driver) UpdateIngress(ingress *netv1.Ingress) (*netv1.Ingress, error)
- func (d *Driver) UpdateNamespace(namespace *corev1.Namespace) (*corev1.Namespace, error)
- func (d *Driver) UpdateReferenceGrant(referenceGrant *gatewayv1beta1.ReferenceGrant) (*gatewayv1beta1.ReferenceGrant, error)
- func (d *Driver) UpdateTCPRoute(tcpRoute *gatewayv1alpha2.TCPRoute) (*gatewayv1alpha2.TCPRoute, error)
- func (d *Driver) UpdateTLSRoute(tlsRoute *gatewayv1alpha2.TLSRoute) (*gatewayv1alpha2.TLSRoute, error)
- func (d *Driver) WithNgrokMetadata(customNgrokMetadata map[string]string) *Driver
- type DriverOpt
- func WithClusterDomain(domain string) DriverOpt
- func WithDefaultDomainReclaimPolicy(policy ingressv1alpha1.DomainReclaimPolicy) DriverOpt
- func WithDisableGatewayReferenceGrants(disable bool) DriverOpt
- func WithDrainState(state DrainState) DriverOpt
- func WithEventRecorder(recorder events.EventRecorder) DriverOpt
- func WithGatewayControllerName(name string) DriverOpt
- func WithGatewayEnabled(enabled bool) DriverOpt
- func WithGatewayTCPRouteEnabled(enabled bool) DriverOpt
- func WithGatewayTLSRouteEnabled(enabled bool) DriverOpt
- func WithSyncAllowConcurrent(allowed bool) DriverOpt
- type GatewayMatch
- type RemoveHeadersConfig
- type TranslationResult
- type Translator
- type URLRedirectConfig
- type URLRewriteConfig
Constants ¶
const (
// Within the gateway, any keys in the tls.options field with this prefix get added to the terminate-tls action
TLSOptionKeyPrefix = "k8s.ngrok.com/terminate-tls."
)
Variables ¶
var ErrSyncRequeue = errors.New("sync requeue requested")
ErrSyncRequeue is a sentinel returned by the sync debouncer to indicate that a sync completed while the caller was waiting, and the caller should requeue to ensure its store changes are captured in a subsequent sync. This is not a real error — reconcilers should convert it to ctrl.Result{RequeueAfter: syncRequeueDelay} using HandleSyncResult.
var ( // These keys may not be supplied to the gateway listener's tls.options field since they are supported elsewhere and we don't want conflicts TLSOptionKeyReservedKeys = []string{ "k8s.ngrok.com/terminate-tls.server_private_key", "k8s.ngrok.com/terminate-tls.server_certificate", "k8s.ngrok.com/terminate-tls.mutual_tls_certificate_authorities", } )
Functions ¶
func GatewayAPIHTTPMatchToIR ¶
func GatewayAPIHTTPMatchToIR(match gatewayv1.HTTPRouteMatch) *ir.IRHTTPMatch
GatewayAPIHTTPMatchToIR translates an HTTPRouteMatch into an IRHTTPMatch
func HandleSyncResult ¶
HandleSyncResult converts a Sync or SyncEndpoints error into a controller-runtime reconcile result. If the error is ErrSyncRequeue it returns ctrl.Result{RequeueAfter: syncRequeueDelay} with a nil error so controller-runtime requeues without logging an error or applying exponential backoff. Real errors are passed through unchanged.
func MappingStrategyAnnotationToIR ¶
func MappingStrategyAnnotationToIR(obj client.Object) (ir.IRMappingStrategy, error)
MappingStrategyAnnotationToIR checks the supplied object for the mapping strategy annotation and returns the appropriate mapping strategy enum if it is set, or falls back to the default strategy
Types ¶
type AddHeadersConfig ¶
type ControllerEventHandler ¶
type ControllerEventHandler struct {
// contains filtered or unexported fields
}
ControllerEventHandler implements the controller-runtime eventhandler interface https://github.com/kubernetes-sigs/controller-runtime/blob/v0.14.1/pkg/handler/eventhandler.go This allows it to be used to handle each reconcile event for a watched resource type. This handler takes a basic object and updates/deletes the store with it. It is used to simply watch some resources and keep their values updated in the store. It is used to keep various crds like edges/tunnels/domains, and core resources like ingress classes, updated.
func NewControllerEventHandler ¶
func NewControllerEventHandler(resourceName string, d *Driver, client client.Client) *ControllerEventHandler
NewControllerEventHandler creates a new ControllerEventHandler
func (*ControllerEventHandler) Create ¶
func (e *ControllerEventHandler) Create(_ context.Context, evt event.CreateEvent, _ workqueue.TypedRateLimitingInterface[reconcile.Request])
Create is called in response to an create event - e.g. Edge Creation.
func (*ControllerEventHandler) Delete ¶
func (e *ControllerEventHandler) Delete(_ context.Context, evt event.DeleteEvent, _ workqueue.TypedRateLimitingInterface[reconcile.Request])
Delete is called in response to a delete event - e.g. Edge Deleted.
func (*ControllerEventHandler) Generic ¶
func (e *ControllerEventHandler) Generic(_ context.Context, evt event.GenericEvent, _ workqueue.TypedRateLimitingInterface[reconcile.Request])
Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or external trigger request
func (*ControllerEventHandler) Update ¶
func (e *ControllerEventHandler) Update(ctx context.Context, evt event.UpdateEvent, _ workqueue.TypedRateLimitingInterface[reconcile.Request])
Update is called in response to an update event - e.g. Edge Updated.
type DrainState ¶
DrainState is an alias for drain.State for convenience
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver maintains the store of information, can derive new information from the store, and can synchronize the desired state of the store to the actual state of the cluster.
func NewDriver ¶
func NewDriver(logger logr.Logger, scheme *runtime.Scheme, controllerName string, managerName types.NamespacedName, opts ...DriverOpt) *Driver
NewDriver creates a new driver with a basic logger and cache store setup
func (*Driver) DeleteHTTPRoute ¶
func (*Driver) DeleteNamedGateway ¶
func (d *Driver) DeleteNamedGateway(n types.NamespacedName) error
func (*Driver) DeleteNamedHTTPRoute ¶
func (d *Driver) DeleteNamedHTTPRoute(n types.NamespacedName) error
func (*Driver) DeleteNamedIngress ¶
func (d *Driver) DeleteNamedIngress(n types.NamespacedName) error
Delete an ingress object given the NamespacedName Takes a namespacedName string as a parameter and deletes the ingress object from the cacheStores map
func (*Driver) DeleteNamedTCPRoute ¶
func (d *Driver) DeleteNamedTCPRoute(n types.NamespacedName) error
func (*Driver) DeleteNamedTLSRoute ¶
func (d *Driver) DeleteNamedTLSRoute(n types.NamespacedName) error
func (*Driver) DeleteNamespace ¶
func (*Driver) DeleteReferenceGrant ¶
func (d *Driver) DeleteReferenceGrant(n types.NamespacedName) error
func (*Driver) DeleteTCPRoute ¶
func (d *Driver) DeleteTCPRoute(tcpRoute *gatewayv1alpha2.TCPRoute) error
func (*Driver) DeleteTLSRoute ¶
func (d *Driver) DeleteTLSRoute(tlsRoute *gatewayv1alpha2.TLSRoute) error
func (*Driver) PrintState ¶
func (*Driver) Seed ¶
Seed fetches all the upfront information the driver needs to operate It needs to be seeded fully before it can be used to make calculations otherwise each calculation will be based on an incomplete state of the world. It currently relies on: - Ingresses - IngressClasses - Gateways - HTTPRoutes - TCPRoutes - TLSRoutes - ReferenceGrants - Services - Secrets - Namespaces - ConfigMaps - Domains - Edges - Tunnels - ModuleSets - TrafficPolicies - AgentEndpoints - CloudEndpoints When the sync method becomes a background process, this likely won't be needed anymore
func (*Driver) Sync ¶
Sync calculates what the desired state for each of our CRDs should be based on the ingresses and other objects in the store. It then compares that to the actual state of the cluster and updates the cluster
func (*Driver) SyncEndpoints ¶
func (*Driver) UpdateGateway ¶
func (*Driver) UpdateHTTPRoute ¶
func (*Driver) UpdateIngress ¶
func (*Driver) UpdateNamespace ¶
func (*Driver) UpdateReferenceGrant ¶
func (d *Driver) UpdateReferenceGrant(referenceGrant *gatewayv1beta1.ReferenceGrant) (*gatewayv1beta1.ReferenceGrant, error)
func (*Driver) UpdateTCPRoute ¶
func (d *Driver) UpdateTCPRoute(tcpRoute *gatewayv1alpha2.TCPRoute) (*gatewayv1alpha2.TCPRoute, error)
func (*Driver) UpdateTLSRoute ¶
func (d *Driver) UpdateTLSRoute(tlsRoute *gatewayv1alpha2.TLSRoute) (*gatewayv1alpha2.TLSRoute, error)
type DriverOpt ¶
type DriverOpt func(*Driver)
func WithClusterDomain ¶
func WithDefaultDomainReclaimPolicy ¶
func WithDefaultDomainReclaimPolicy(policy ingressv1alpha1.DomainReclaimPolicy) DriverOpt
func WithDrainState ¶
func WithDrainState(state DrainState) DriverOpt
func WithEventRecorder ¶
func WithEventRecorder(recorder events.EventRecorder) DriverOpt
func WithGatewayEnabled ¶
func WithSyncAllowConcurrent ¶
type GatewayMatch ¶
type GatewayMatch struct {
ParentGateway types.NamespacedName
Hostname string
}
type RemoveHeadersConfig ¶
type RemoveHeadersConfig struct {
Headers []string `json:"headers"`
}
type TranslationResult ¶
type TranslationResult struct {
AgentEndpoints map[types.NamespacedName]*ngrokv1alpha1.AgentEndpoint
CloudEndpoints map[types.NamespacedName]*ngrokv1alpha1.CloudEndpoint
}
TranslationResult is the final set of translation output resources
type Translator ¶
type Translator interface {
Translate() *TranslationResult
}
Translator is responsible for translating kubernetes resources, first into IR internally, and then translating the IR into the desired output resource types. This separates the responsibilities of translation out of the Driver so that it can focus on resource storage/updates/deletes TODO (Alice): generate mocks for use in tests