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
- func Hash(cfg Config) (string, error)
- type AdminAPIEndpointsReconciler
- type Config
- type Env
- type Instance
- func (i *Instance) AdminAPIs() sets.Set[adminapi.DiscoveredAdminAPI]
- func (i *Instance) Config() Config
- func (i *Instance) ConfigHash() (string, error)
- func (i *Instance) DiagnosticsHandler() http.Handler
- func (i *Instance) ID() manager.ID
- func (i *Instance) IsReady() error
- func (i *Instance) Run(ctx context.Context) error
- type Manager
Constants ¶
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 ¶
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 ¶
func (r *AdminAPIEndpointsReconciler) Reconcile(ctx context.Context, _ reconcile.Request) (ctrl.Result, error)
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 ¶
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) ConfigHash ¶
ConfigHash returns a hash of the instance's configuration.
func (*Instance) DiagnosticsHandler ¶
DiagnosticsHandler returns nil: the instance does not expose diagnostics data yet. TODO: https://github.com/Kong/kong-operator/issues/5630
func (*Instance) IsReady ¶
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
type Manager ¶
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.