aigateway

package
v2.4.0-rapid.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 49 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package aigateway is able to dynamically run multiple on-prem AI Gateway control plane instances and manage their lifecycle. The generic instance lifecycle is shared with the Kong Ingress Controller's multi-instance manager through the instances package.

Index

Constants

View Source
const ControllerNameAdminAPIEndpoints = "onprem-aigateway-adminapi-endpoints"

ControllerNameAdminAPIEndpoints is the name used for logging and event recording by the Admin API endpoints discovery controller.

Variables

This section is empty.

Functions

func Hash

func Hash(cfg Config) (string, error)

Hash computes a hash of the given config. It's used to detect configuration drift of running instances.

Types

type AdminAPIEndpointsReconciler

type AdminAPIEndpointsReconciler struct {
	client.Client

	// GatewayNN is the OnPremAIGateway whose referencing AIGatewayDataPlanes'
	// Admin API endpoints are discovered.
	GatewayNN types.NamespacedName

	// Discoverer performs the EndpointSlice -> Admin API endpoint discovery.
	Discoverer *adminapidiscovery.Discoverer

	// Log is the logger used by the reconciler.
	Log logr.Logger

	// OnDiscovery is called with the Admin APIs discovered for all the
	// AIGatewayDataPlanes referencing GatewayNN. It is called on every
	// successful reconciliation, including when the set is empty.
	OnDiscovery func(ctx context.Context, adminAPIs sets.Set[adminapidiscovery.DiscoveredAdminAPI])
}

AdminAPIEndpointsReconciler discovers the Admin API endpoints of all the AIGatewayDataPlanes referencing the Reconciler's OnPremAIGateway and notifies about the discovered set through OnDiscovery.

It reconciles whole data planes rather than individual EndpointSlices: on every relevant event it re-discovers the endpoints of all the referencing data planes' Admin API Services, so the notified set always reflects the complete state.

func (*AdminAPIEndpointsReconciler) Reconcile

Reconcile discovers the Admin API endpoints of all the AIGatewayDataPlanes referencing the Reconciler's OnPremAIGateway and notifies about the result. The reconcile.Request is ignored because we reconcile whole data planes instead of individual EndpointSlices: any relevant event (a data plane added or removed, an EndpointSlice changed) invalidates the complete discovered set, so re-discovering all of it is the only correct response. This is cheap - just a couple of cached list calls - and guarantees the notified set is always complete, with no state to keep in sync.

func (*AdminAPIEndpointsReconciler) SetupWithManager

func (r *AdminAPIEndpointsReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type Config

type Config struct {
	// DBLessConfig is the rendered dbless declarative payload for this gateway, ready to be
	// pushed to its data planes' Admin API.
	DBLessConfig []byte

	// AdminClientCertSecretNN is the reference to the mTLS client certificate Secret the
	// instance reads when pushing configuration to its data planes. It is part of the
	// hashed config so that a renewed Secret - recreated under a new GenerateName by
	// EnsureCertificate - drifts the hash and restarts the instance with the new reference.
	AdminClientCertSecretNN types.NamespacedName
}

Config is the resolved configuration of a single on-prem AI Gateway control plane instance.

type Env

type Env struct {
	// RestConfig is the rest config used to reach the Kubernetes API server.
	RestConfig *rest.Config

	// Scheme is the scheme the instance's manager registers its objects in.
	Scheme *runtime.Scheme

	// CacheSyncTimeout is the cache sync timeout for the instance's controllers.
	CacheSyncTimeout time.Duration

	// GatewayNN is the reference to the OnPremAIGateway resource the instance
	// serves. It is used to discover the AIGatewayDataPlanes referencing the
	// gateway and their Admin API endpoints.
	GatewayNN types.NamespacedName

	// AdminClientCertSecretNN is the reference to the mTLS client certificate Secret
	// provisioned by the OnPremAIGateway controller. The instance reads it to build
	// the Admin API clients that push configuration to the data planes.
	AdminClientCertSecretNN types.NamespacedName

	// TypeConverter is the SSA type converter used to patch the OnPremAIGateway status.
	TypeConverter managedfields.TypeConverter
}

Env carries the process-level dependencies an instance needs to build and run its own controller-runtime manager. They never drift with the spec, so they stay out of Config, which is hashed for drift detection.

type Instance

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

Instance is a single on-prem AI Gateway control plane instance. It runs its own controller-runtime manager hosting the configuration-entity controllers (AIGatewayModel, and its sibling kinds as they are added), so that the controllers start and stop together with the OnPremAIGateway resource that owns the instance.

func NewInstance

func NewInstance(
	id manager.ID,
	logger logr.Logger,
	cfg Config,
	env Env,
) *Instance

NewInstance creates a new on-prem AI Gateway control plane instance. It does not start it.

func (*Instance) AdminAPIs

func (i *Instance) AdminAPIs() sets.Set[adminapi.DiscoveredAdminAPI]

AdminAPIs returns a copy of the Admin API endpoints discovered for the AIGatewayDataPlanes referencing the instance's OnPremAIGateway.

func (*Instance) Config

func (i *Instance) Config() Config

Config returns the configuration of the instance.

func (*Instance) ConfigHash

func (i *Instance) ConfigHash() (string, error)

ConfigHash returns a hash of the instance's configuration.

func (*Instance) DiagnosticsHandler

func (i *Instance) DiagnosticsHandler() http.Handler

DiagnosticsHandler returns nil: the instance does not expose diagnostics data yet. TODO: https://github.com/Kong/kong-operator/issues/5630

func (*Instance) ID

func (i *Instance) ID() manager.ID

ID returns the unique identifier of the instance.

func (*Instance) IsReady

func (i *Instance) IsReady() error

IsReady returns an error if the instance is not ready yet.

The instance reports push failures on the gateway's DataPlanesConfigured condition, so there is nothing to wait for here yet. TODO: https://github.com/Kong/kong-operator/issues/5569

func (*Instance) Run

func (i *Instance) Run(ctx context.Context) error

Run runs the instance. It blocks until the passed context is cancelled.

type Manager

type Manager struct {
	*instances.Registry
}

Manager runs multiple on-prem AI Gateway control plane instances.

It currently adds nothing on top of the shared registry. It exists as the place to put the AI Gateway specifics as they land, and to keep the AI Gateway instance type from having to satisfy the Kong Ingress Controller's ManagerInstance interface.

func NewManager

func NewManager(logger logr.Logger, opts ...instances.RegistryOption) *Manager

NewManager creates a new AI Gateway multi-instance manager.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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