managerdriver

package
v0.0.0-...-3187082 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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.

View Source
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

func HandleSyncResult(err error) (ctrl.Result, error)

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 AddHeadersConfig struct {
	Headers map[string]string `json:"headers"`
}

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

Create is called in response to an create event - e.g. Edge Creation.

func (*ControllerEventHandler) Delete

Delete is called in response to a delete event - e.g. Edge Deleted.

func (*ControllerEventHandler) Generic

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

Update is called in response to an update event - e.g. Edge Updated.

type DrainState

type DrainState = drain.State

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) DeleteGateway

func (d *Driver) DeleteGateway(gateway *gatewayv1.Gateway) error

func (*Driver) DeleteHTTPRoute

func (d *Driver) DeleteHTTPRoute(httproute *gatewayv1.HTTPRoute) error

func (*Driver) DeleteIngress

func (d *Driver) DeleteIngress(ingress *netv1.Ingress) error

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 (d *Driver) DeleteNamespace(name string) error

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) GetStore

func (d *Driver) GetStore() store.Storer

Useful for tests

func (*Driver) PrintState

func (d *Driver) PrintState(setupLog logr.Logger)

func (*Driver) Seed

func (d *Driver) Seed(ctx context.Context, c client.Reader, listOpts ...client.ListOption) error

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

func (d *Driver) Sync(ctx context.Context, c client.Client) error

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 (d *Driver) SyncEndpoints(ctx context.Context, c client.Client) error

func (*Driver) UpdateGateway

func (d *Driver) UpdateGateway(gateway *gatewayv1.Gateway) (*gatewayv1.Gateway, error)

func (*Driver) UpdateHTTPRoute

func (d *Driver) UpdateHTTPRoute(httproute *gatewayv1.HTTPRoute) (*gatewayv1.HTTPRoute, error)

func (*Driver) UpdateIngress

func (d *Driver) UpdateIngress(ingress *netv1.Ingress) (*netv1.Ingress, error)

func (*Driver) UpdateNamespace

func (d *Driver) UpdateNamespace(namespace *corev1.Namespace) (*corev1.Namespace, error)

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)

func (*Driver) WithNgrokMetadata

func (d *Driver) WithNgrokMetadata(customNgrokMetadata map[string]string) *Driver

WithNgrokMetadata allows you to pass in custom ngrokmetadata to be added to all resources created by the controller

type DriverOpt

type DriverOpt func(*Driver)

func WithClusterDomain

func WithClusterDomain(domain string) DriverOpt

func WithDefaultDomainReclaimPolicy

func WithDefaultDomainReclaimPolicy(policy ingressv1alpha1.DomainReclaimPolicy) DriverOpt

func WithDisableGatewayReferenceGrants

func WithDisableGatewayReferenceGrants(disable bool) DriverOpt

func WithDrainState

func WithDrainState(state DrainState) DriverOpt

func WithEventRecorder

func WithEventRecorder(recorder events.EventRecorder) DriverOpt

func WithGatewayControllerName

func WithGatewayControllerName(name string) DriverOpt

func WithGatewayEnabled

func WithGatewayEnabled(enabled bool) DriverOpt

func WithGatewayTCPRouteEnabled

func WithGatewayTCPRouteEnabled(enabled bool) DriverOpt

func WithGatewayTLSRouteEnabled

func WithGatewayTLSRouteEnabled(enabled bool) DriverOpt

func WithSyncAllowConcurrent

func WithSyncAllowConcurrent(allowed bool) DriverOpt

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

func NewTranslator

func NewTranslator(
	log logr.Logger,
	store store.Storer,
	managedResourceLabels map[string]string,
	defaultIngressMetadata string,
	defaultGatewayMetadata string,
	clusterDomain string,
	disableGatewayReferenceGrants bool,
) Translator

NewTranslator creates a new default Translator

type URLRedirectConfig

type URLRedirectConfig struct {
	To         *string `json:"to"`
	From       *string `json:"from"`
	StatusCode *int    `json:"status_code"`
	// convert to response headers
	Headers map[string]string `json:"headers"`
}

type URLRewriteConfig

type URLRewriteConfig struct {
	To   *string `json:"to"`
	From *string `json:"from"`
}

Jump to

Keyboard shortcuts

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