store

package
v0.0.0-...-1716710 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDomainV1

func NewDomainV1(name string, namespace string) ingressv1alpha1.Domain

func NewHTTPSEdge

func NewHTTPSEdge(name string, namespace string, domain string) ingressv1alpha1.HTTPSEdge

func NewTestIngressClass

func NewTestIngressClass(name string, isDefault bool, isNgrok bool) netv1.IngressClass

func NewTestIngressV1

func NewTestIngressV1(name string, namespace string) netv1.Ingress

func NewTestIngressV1WithClass

func NewTestIngressV1WithClass(name string, namespace string, ingressClass string) netv1.Ingress

func NewTestNgrokModuleSet

func NewTestNgrokModuleSet(name string, namespace string, compressionEnabled bool) ingressv1alpha1.NgrokModuleSet

func NewTestNgrokTrafficPolicy

func NewTestNgrokTrafficPolicy(name string, namespace string, policyStr string) ngrokv1alpha1.NgrokTrafficPolicy

func NewTestServiceV1

func NewTestServiceV1(name string, namespace string) corev1.Service

Types

type AddHeadersConfig

type AddHeadersConfig struct {
	Headers map[string]string `json:"headers"`
}

type CacheStores

type CacheStores struct {
	// Core Kubernetes Stores
	IngressV1      cache.Store
	IngressClassV1 cache.Store
	ServiceV1      cache.Store

	// Gateway API Stores
	Gateway      cache.Store
	GatewayClass cache.Store
	HTTPRoute    cache.Store

	// Ngrok Stores
	DomainV1             cache.Store
	TunnelV1             cache.Store
	HTTPSEdgeV1          cache.Store
	NgrokModuleV1        cache.Store
	NgrokTrafficPolicyV1 cache.Store
	// contains filtered or unexported fields
}

CacheStores stores cache.Store for all Kinds of k8s objects that the Ingress Controller reads.

func NewCacheStores

func NewCacheStores(logger logr.Logger) CacheStores

NewCacheStores is a convenience function for CacheStores to initialize all attributes with new cache stores.

func (CacheStores) Add

func (c CacheStores) Add(obj runtime.Object) error

Add stores a provided runtime.Object into the CacheStore if it's of a supported type. The CacheStore must be initialized (see NewCacheStores()) or this will panic.

func (CacheStores) Delete

func (c CacheStores) Delete(obj runtime.Object) error

Delete removes a provided runtime.Object from the CacheStore if it's of a supported type. The CacheStore must be initialized (see NewCacheStores()) or this will panic.

func (CacheStores) Get

func (c CacheStores) Get(obj runtime.Object) (item interface{}, exists bool, err error)

Get checks whether or not there's already some version of the provided object present in the cache. The CacheStore must be initialized (see NewCacheStores()) or this will panic.

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

func (d *Driver) MigrateKubernetesIngressControllerLabelsToNgrokOperator(ctx context.Context, k8sClient client.Client) error

MigrateKubernetesIngressControllerLabelsToNgrokOperator migrates the labels from the old Kubernetes Ingress Controller to the new ngrok operator labels so that the ngrok operator can take over management of items previously managed by the Kubernetes Ingress Controller. TODO: Delete this function after users have migrated from the ngrok Kubernetes Ingress Controller to the ngrok Operator.

func (*Driver) PrintState

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

func (*Driver) Seed

func (d *Driver) Seed(ctx context.Context, c client.Reader) 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 - Services - Domains - Edges - Tunnels - ModuleSets - TrafficPolicies 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) SyncEdges

func (d *Driver) SyncEdges(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) 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 WithGatewayEnabled

func WithGatewayEnabled(enabled bool) DriverOpt

func WithSyncAllowConcurrent

func WithSyncAllowConcurrent(allowed bool) DriverOpt

type RemoveHeadersConfig

type RemoveHeadersConfig struct {
	Headers []string `json:"headers"`
}

type Store

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

Store implements Storer and can be used to list Ingress, Services and other resources from k8s APIserver. The backing stores should be synced and updated by the caller. It is ingressClass filter aware.

func (Store) Add

func (s Store) Add(obj runtime.Object) error

Add proxies the call to the underlying store.

func (Store) Delete

func (s Store) Delete(obj runtime.Object) error

Delete proxies the call to the underlying store.

func (Store) Get

func (s Store) Get(obj runtime.Object) (interface{}, bool, error)

Get proxies the call to the underlying store.

func (Store) GetGateway

func (s Store) GetGateway(name string, namespace string) (*gatewayv1.Gateway, error)

func (Store) GetHTTPRoute

func (s Store) GetHTTPRoute(name string, namespace string) (*gatewayv1.HTTPRoute, error)

func (Store) GetIngressClassV1

func (s Store) GetIngressClassV1(name string) (*netv1.IngressClass, error)

GetIngressClassV1 returns the 'name' IngressClass resource.

func (Store) GetIngressV1

func (s Store) GetIngressV1(name, namespcae string) (*netv1.Ingress, error)

GetIngressV1 returns the 'name' Ingress resource.

func (Store) GetNgrokIngressV1

func (s Store) GetNgrokIngressV1(name, namespace string) (*netv1.Ingress, error)

GetNgrokIngressV1 looks up the Ingress resource by name and namespace and returns it if it's found

func (Store) GetNgrokModuleSetV1

func (s Store) GetNgrokModuleSetV1(name, namespace string) (*ingressv1alpha1.NgrokModuleSet, error)

func (Store) GetNgrokTrafficPolicyV1

func (s Store) GetNgrokTrafficPolicyV1(name, namespace string) (*ngrokv1alpha1.NgrokTrafficPolicy, error)

func (Store) GetServiceV1

func (s Store) GetServiceV1(name, namespace string) (*corev1.Service, error)

func (Store) ListDomainsV1

func (s Store) ListDomainsV1() []*ingressv1alpha1.Domain

ListDomainsV1 returns the list of Domains in the Domain v1 store.

func (Store) ListGateways

func (s Store) ListGateways() []*gatewayv1.Gateway

func (Store) ListHTTPRoutes

func (s Store) ListHTTPRoutes() []*gatewayv1.HTTPRoute

func (Store) ListHTTPSEdgesV1

func (s Store) ListHTTPSEdgesV1() []*ingressv1alpha1.HTTPSEdge

ListHTTPSEdgesV1 returns the list of HTTPSEdges in the HTTPSEdge v1 store.

func (Store) ListIngressClassesV1

func (s Store) ListIngressClassesV1() []*netv1.IngressClass

ListIngressClassesV1 returns the list of Ingresses in the Ingress v1 store.

func (Store) ListIngressesV1

func (s Store) ListIngressesV1() []*netv1.Ingress

ListIngressesV1 returns the list of Ingresses in the Ingress v1 store.

func (Store) ListNgrokIngressClassesV1

func (s Store) ListNgrokIngressClassesV1() []*netv1.IngressClass

ListNgrokIngressClassesV1 returns the list of Ingresses in the Ingress v1 store filtered by ones that match the controllerName

func (Store) ListNgrokIngressesV1

func (s Store) ListNgrokIngressesV1() []*netv1.Ingress

func (Store) ListNgrokModuleSetsV1

func (s Store) ListNgrokModuleSetsV1() []*ingressv1alpha1.NgrokModuleSet

ListNgrokModuleSetsV1 returns the list of NgrokModules in the NgrokModuleSet v1 store.

func (Store) ListTunnelsV1

func (s Store) ListTunnelsV1() []*ingressv1alpha1.Tunnel

ListTunnelsV1 returns the list of Tunnels in the Tunnel v1 store.

func (Store) Update

func (s Store) Update(obj runtime.Object) error

Update proxies the call to the underlying store. An add for an object with the same key thats already present is just an update

type Storer

type Storer interface {
	Get(obj runtime.Object) (item interface{}, exists bool, err error)
	Add(runtime.Object) error
	Update(runtime.Object) error
	Delete(runtime.Object) error

	GetIngressClassV1(name string) (*netv1.IngressClass, error)
	GetIngressV1(name, namespace string) (*netv1.Ingress, error)
	GetServiceV1(name, namespace string) (*corev1.Service, error)
	GetNgrokIngressV1(name, namespace string) (*netv1.Ingress, error)
	GetNgrokModuleSetV1(name, namespace string) (*ingressv1alpha1.NgrokModuleSet, error)
	GetNgrokTrafficPolicyV1(name, namespace string) (*ngrokv1alpha1.NgrokTrafficPolicy, error)
	GetGateway(name string, namespace string) (*gatewayv1.Gateway, error)
	GetHTTPRoute(name string, namespace string) (*gatewayv1.HTTPRoute, error)

	ListIngressClassesV1() []*netv1.IngressClass
	ListNgrokIngressClassesV1() []*netv1.IngressClass

	ListIngressesV1() []*netv1.Ingress
	ListNgrokIngressesV1() []*netv1.Ingress

	ListGateways() []*gatewayv1.Gateway
	ListHTTPRoutes() []*gatewayv1.HTTPRoute

	ListDomainsV1() []*ingressv1alpha1.Domain
	ListTunnelsV1() []*ingressv1alpha1.Tunnel
	ListHTTPSEdgesV1() []*ingressv1alpha1.HTTPSEdge
	ListNgrokModuleSetsV1() []*ingressv1alpha1.NgrokModuleSet
}

Storer is the interface that wraps the required methods to gather information about ingresses, services, and other CRDs. It exposes methods to list both all and filtered resources

func New

func New(cs CacheStores, controllerName string, logger logr.Logger) Storer

New creates a new object store to be used in the ingress controller.

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"`
}

type UpdateStoreHandler

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

UpdateStoreHandler 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 NewUpdateStoreHandler

func NewUpdateStoreHandler(resourceName string, d *Driver, client client.Client) *UpdateStoreHandler

NewUpdateStoreHandler creates a new UpdateStoreHandler

func (*UpdateStoreHandler) Create

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

func (*UpdateStoreHandler) Delete

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

func (*UpdateStoreHandler) 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 (*UpdateStoreHandler) Update

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

Jump to

Keyboard shortcuts

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