Documentation
¶
Overview ¶
Package dataplane contains the DataPlane reconciliation logic shared by the specialized DataPlane controllers (AIGatewayDataPlane, KegDataPlane). The generic Reconciler is parameterized over the DataPlane type, the Konnect control plane type it references and the Konnect certificate type it provisions; type specific behavior is injected through Config.
Index ¶
- Constants
- func BuildDeployment[T Object, Cert CertificateObject](logger logr.Logger, tc managedfields.TypeConverter, dp T, ...) (*unstructured.Unstructured, error)
- func BuildService[T Object](tc managedfields.TypeConverter, dp T, cfg ServiceConfig[T]) (client.Object, error)
- func EnqueueDataPlanesForControlPlane(cl client.Client, newObjectList func() client.ObjectList, ...) handler.MapFunc
- func GenerateBaseDeployment[T Object, Cert CertificateObject](logger logr.Logger, dp T, cp ResolvedControlPlane, image string, ...) (*appsv1.Deployment, error)
- func GenerateBaseService[T Object](dp T, cfg ServiceConfig[T]) *corev1.Service
- func GenerateServiceOverlay[T Object](dp T, cfg ServiceConfig[T], opts *ServiceOptions) *corev1.Service
- func ResolveImage[T Object](dp T, cfg DeploymentConfig[T]) string
- func SelectorLabels[T Object](dp T, managedByLabelValue string) map[string]string
- func SetLicenseStatusCondition(dp k8sutils.ConditionsAndGenerationAware, getter LicenseGetter, ...)
- type AdminAPIConfig
- type CertificateConfig
- type CertificateObject
- type Conditions
- type Config
- type ControlPlaneConditions
- type ControlPlaneKindConfig
- type ControlPlaneObject
- type ControlPlaneRef
- type DeploymentConfig
- type EnsureCertificateFunc
- type KongLicenseCacheGetter
- type LicenseGetter
- type Object
- type Reconciler
- type ResolvedControlPlane
- type ServiceConfig
- type ServiceOptions
- type ServicePort
Constants ¶
const ( // KonnectCertVolumeName is the name of the volume that holds the Konnect mTLS certificate. KonnectCertVolumeName = "konnect-cert" // KonnectCertMountPath is the path where the Konnect certificate Secret is mounted in the DataPlane container. KonnectCertMountPath = "/var/konnect-client-certificate/" // AdminCertVolumeName is the name of the volume that holds the Admin API TLS server certificate. AdminCertVolumeName = "admin-cert" // AdminCertMountPath is the path where the Admin API certificate Secret is mounted in the DataPlane container. AdminCertMountPath = "/var/admin-certificate/" )
const LicenseMissingMessage = "No enabled KongLicense resource found; the gateway will run without a license"
LicenseMissingMessage is the message used when no enabled KongLicense is available and the gateway runs without a license.
Variables ¶
This section is empty.
Functions ¶
func BuildDeployment ¶ added in v2.4.0
func BuildDeployment[T Object, Cert CertificateObject]( logger logr.Logger, tc managedfields.TypeConverter, dp T, cp ResolvedControlPlane, image string, certSecretName string, adminCertSecretName string, certChecksum string, cfg Config[T, Cert], ) (*unstructured.Unstructured, error)
BuildDeployment constructs the desired DataPlane Deployment as *unstructured.Unstructured. If the user has provided a PodTemplateSpec overlay, it is merged with the operator base via SMD. The result always has spec.strategy removed so that SSA does not claim ownership of it, leaving the API server (or admission webhooks) free to apply their own default.
func BuildService ¶ added in v2.4.0
func BuildService[T Object]( tc managedfields.TypeConverter, dp T, cfg ServiceConfig[T], ) (client.Object, error)
BuildService constructs the desired Service. If the user has provided ServiceOptions, they are merged with the operator base via SMD: user-provided fields win on conflicts; the base supplies defaults (selector, default port) only when the user has not specified them.
func EnqueueDataPlanesForControlPlane ¶
func EnqueueDataPlanesForControlPlane( cl client.Client, newObjectList func() client.ObjectList, controlPlaneRefIndexField string, kind string, controlPlaneKind string, ) handler.MapFunc
EnqueueDataPlanesForControlPlane returns a MapFunc that enqueues reconcile requests for all DataPlanes in the same namespace whose control plane reference matches the changed control plane object.
func GenerateBaseDeployment ¶ added in v2.4.0
func GenerateBaseDeployment[T Object, Cert CertificateObject]( logger logr.Logger, dp T, cp ResolvedControlPlane, image string, certSecretName string, adminCertSecretName string, certChecksum string, cfg Config[T, Cert], ) (*appsv1.Deployment, error)
GenerateBaseDeployment creates the operator-managed DataPlane Deployment without user overlays.
func GenerateBaseService ¶ added in v2.4.0
func GenerateBaseService[T Object](dp T, cfg ServiceConfig[T]) *corev1.Service
GenerateBaseService returns the operator defaults for the Service: the pod selector and a default port. These are used only when the user has not provided conflicting values in ServiceOptions.
Service.spec.ports is a list-map keyed by [port, protocol], so SSA merges ports by port number. Two ports with different port numbers but the same name would both be kept after the merge, causing Kubernetes to reject the Service (port names must be unique). To prevent this, any base port whose name is already used by a user-provided port is omitted here so the user's port wins cleanly.
func GenerateServiceOverlay ¶ added in v2.4.0
func GenerateServiceOverlay[T Object](dp T, cfg ServiceConfig[T], opts *ServiceOptions) *corev1.Service
GenerateServiceOverlay builds a Service skeleton from the user-provided ServiceOptions. It is merged onto the base by MergeObjects, where the overlay wins on conflicts; the base only supplies the fields the overlay leaves unset (selector, default port).
func ResolveImage ¶ added in v2.4.0
func ResolveImage[T Object](dp T, cfg DeploymentConfig[T]) string
ResolveImage determines the DataPlane container image using the following priority:
- User-specified image in the pod template overlay (the DataPlane container)
- The related-image environment variable
- The configured default image
func SelectorLabels ¶ added in v2.4.0
SelectorLabels returns the labels uniquely identifying the pods of the given DataPlane.
func SetLicenseStatusCondition ¶ added in v2.4.0
func SetLicenseStatusCondition( dp k8sutils.ConditionsAndGenerationAware, getter LicenseGetter, condType, validReason, missingReason string, )
SetLicenseStatusCondition sets the license condition on dp based on the effective license provided by getter. It is a no-op when getter is nil or condType is empty (license reporting disabled). The condition never gates the Ready condition; see ensureReadyStatus. ponytail: no license validation is wired yet, so LicenseInvalidReason never fires; wire a ValidatorFunc into the KongLicense reconciler and map GetValidatedLicense().IsValid here when validation is needed.
Types ¶
type AdminAPIConfig ¶ added in v2.4.0
type AdminAPIConfig[T Object] struct { // Enabled reports whether the Admin API should be exposed for the // DataPlane given its resolved control plane. cp is the zero // ResolvedControlPlane when the DataPlane has no control plane reference // configured. Must not be nil. Enabled func(dp T, cp ResolvedControlPlane) bool // ServiceNameSuffix is appended to the DataPlane name to form the admin // Service name (e.g. "-admin"). Must not be empty. ServiceNameSuffix string // ServicePortName is the name of the admin Service port (e.g. "admin"). ServicePortName string // ServicePort is the port the admin Service exposes. Must be positive. ServicePort int32 // ManagedByLabelValue is the value of the managed-by label used in the // admin Service selector. ManagedByLabelValue string // CertificateLabelKey marks the provisioned Admin API TLS server // certificate Secret. It must be distinct from Certificate.LabelKey so // the two Secrets never collide in the owner-scoped Secret listings // performed during provisioning. Must not be empty. CertificateLabelKey string }
AdminAPIConfig carries the configuration of the DataPlane's Admin API exposure: a dedicated admin Service and a TLS server certificate for it, both gated on the same Enabled predicate. Control plane kinds that push configuration to the DataPlane over its Admin API (e.g. OnPremAIGateway) enable it. The certificate's subject is derived from the Service name: the in-cluster DNS name the control plane uses to reach the Admin API.
type CertificateConfig ¶ added in v2.4.0
type CertificateConfig[T Object, Cert CertificateObject] struct { // LabelKey marks the provisioned mTLS client certificate Secret. It must // be distinct from AdminAPI.CertificateLabelKey so the two Secrets never // collide in the owner-scoped Secret listings performed during // provisioning. LabelKey string // Kind is the certificate resource kind used in logs, errors and events // (e.g. "AIGatewayDataPlaneCertificate"). Kind string // Build builds the desired certificate object for the DataPlane. // certChecksum identifies the certificate Secret's content ("" when // checksum tracking is not configured): controllers that name the // certificate entity after the content should derive both the object name // and the Konnect title from it so a rotation registers a new entity // instead of mutating the previous one in place. // Only called for Konnect-backed control planes (cp.IsKonnect). Build func(dp T, cp ResolvedControlPlane, certSecretName, certChecksum string) Cert // Ensure provisions (or finds) the DataPlane's TLS certificate Secrets, // signed by the cluster CA: the mTLS client certificate Secret, and the // Admin API TLS server certificate Secret when AdminAPI is // configured. It is invoked on both provisioning paths, so overriding it // affects both. Ensure EnsureCertificateFunc[T] // Resolve, when non-nil, resolves the mTLS client certificate Secret // before the default Ensure-based provisioning runs. It may: // - return a non-nil Secret to use it as-is (e.g. a manually // provisioned, user-referenced Secret); // - return (op.Result, nil, nil) to wire no certificate at all (a // condition explaining why is expected to be set on dp); // - call resolveAutomatic to fall back to the default operator-managed // provisioning. Resolve func( ctx context.Context, cl client.Client, dp T, cp ResolvedControlPlane, resolveAutomatic func(ctx context.Context, dp T) (op.Result, *corev1.Secret, error), ) (op.Result, *corev1.Secret, error) // Requested, when non-nil, reports whether the DataPlane spec asks for // the mTLS client certificate at all. When resolution produced no // Secret, the reconcile only stops early if a certificate was requested // but could not be resolved (a condition explaining why is expected to // be set on dp); a DataPlane that requests no certificate proceeds to // reconcile its Deployment without any certificate wiring. When nil, a // nil resolved Secret always stops the reconcile early. Requested func(dp T) bool // Checksum, when non-nil, returns a stable checksum of the certificate // Secret content, recorded as a Pod-template annotation so that an // in-place Secret edit rolls the Deployment. Checksum func(secret *corev1.Secret) string // ChecksumAnnotation is the Pod-template annotation key used with // Checksum. Required when Checksum is set. ChecksumAnnotation string // CleanupStale, when non-nil, removes stale Konnect certificate entities // and operator-provisioned Secrets once the rollout onto the current // certificate completed. // Unlike Konnect certificate registration, this hook is intentionally // not gated on cp.IsKonnect: stale Konnect certificate entities still // need cleanup after a DataPlane switches to a non-Konnect control // plane. Implementations must tolerate a resolved control plane of any // configured kind (or an unconfigured one). CleanupStale func(ctx context.Context, cl client.Client, logger logr.Logger, dp T, cp ResolvedControlPlane, certChecksum string) error }
CertificateConfig groups the configuration of the DataPlane's TLS certificates: the mTLS client certificate used for the outbound connection to a Konnect-backed control plane (provisioning, optional manual resolution, Konnect registration and stale cleanup) and — when AdminAPI is configured — the Admin API TLS server certificate provisioned for on-prem control planes. Both Secrets are provisioned through the same Ensure hook.
type CertificateObject ¶ added in v2.4.0
CertificateObject is the constraint for the Konnect certificate types provisioned for the DataPlane (e.g. AIGatewayDataPlaneCertificate, EventGatewayDataPlaneCertificate).
type Conditions ¶ added in v2.4.0
type Conditions struct {
// ReadyType is the type of the top-level Ready condition.
ReadyType string
// ResourceReadyReason is the reason used when the resource is ready.
ResourceReadyReason string
// DependenciesNotReadyReason is the reason used when another condition is not true.
DependenciesNotReadyReason string
// DependenciesNotReadyMessage is the message used when the Deployment does not exist yet.
DependenciesNotReadyMessage string
// WaitingToBecomeReadyReason is the reason used while the Deployment rollout is in progress.
WaitingToBecomeReadyReason string
// WaitingToBecomeReadyMessage is the message used while the Deployment rollout is in progress.
WaitingToBecomeReadyMessage string
// UnableToProvisionReason is the reason used when provisioning a resource fails.
UnableToProvisionReason string
// CertificateProvisionedType is the type of the mTLS certificate Secret condition.
CertificateProvisionedType string
// CertificateProvisionedReason is the reason used when the certificate Secret has been provisioned.
CertificateProvisionedReason string
// KonnectCertificateRegisteredType is the type of the Konnect certificate registration condition.
KonnectCertificateRegisteredType string
// KonnectCertificateRegisteredReason is the reason used when the certificate is ensured and programmed.
KonnectCertificateRegisteredReason string
// KonnectCertificateRegistrationFailedReason is the reason used when the certificate could not be ensured.
KonnectCertificateRegistrationFailedReason string
// KonnectCertificateNotProgrammedReason is the reason used when the certificate is not yet programmed on Konnect.
KonnectCertificateNotProgrammedReason string
// ServiceReadyType is the type of the Service readiness condition.
ServiceReadyType string
// ServiceReadyReason is the reason used when the Service is ready.
ServiceReadyReason string
// ServiceReadyMessage is the message used when the Service is ready.
ServiceReadyMessage string
// WaitingForAddressReason is the reason used while the Service waits for an external address.
WaitingForAddressReason string
// WaitingForAddressMessage is the message used while the Service waits for an external address.
WaitingForAddressMessage string
// AdminCertificateProvisionedType is the type of the Admin API server
// certificate condition. Only used when AdminAPI is configured.
AdminCertificateProvisionedType string
// AdminCertificateProvisionedReason is the reason used when the Admin
// API certificate Secret has been provisioned.
AdminCertificateProvisionedReason string
// LicenseValidType is the type of the license condition. When empty, the
// license condition is disabled (the reconciler never sets it and the
// Ready computation ignores the feature).
LicenseValidType string
// LicenseValidReason is the reason used when a license is available.
LicenseValidReason string
// LicenseMissingReason is the reason used when no license is available.
LicenseMissingReason string
// LicenseInvalidReason is the reason used when the license is invalid.
// Currently unused: the operator does not wire a license validator yet.
LicenseInvalidReason string
}
Conditions carries the condition types, reasons and messages used by the reconciler. Values are supplied by each specialized controller from its API package constants so the shared logic stays bound to the API definitions.
type Config ¶ added in v2.4.0
type Config[T Object, Cert CertificateObject] struct { // ControllerName is the name used for logging and event recording. ControllerName string // Kind is the human-readable DataPlane kind used in logs, errors and // events (e.g. "AIGatewayDataPlane", "KegDataPlane"). Kind string // NewObject returns a new empty DataPlane object. NewObject func() T // NewCertificateObject returns a new empty certificate object. NewCertificateObject func() Cert // NewObjectList returns a new empty DataPlane list object, used by the // control plane watches to list the DataPlanes referencing them. NewObjectList func() client.ObjectList // ControlPlaneRef returns the kind and name of the control plane referenced // by the DataPlane. Name is empty when the DataPlane has no control plane // reference configured; in that case control plane resolution and Konnect // certificate automation are skipped. // The returned Kind must match the Kind of one of the ControlPlanes entries. ControlPlaneRef func(T) ControlPlaneRef // ControlPlanes lists the supported control plane kinds for this DataPlane // kind (e.g. KonnectAIGateway and OnPremAIGateway for AIGatewayDataPlane). // One watch and one index field are registered per entry. ControlPlanes []ControlPlaneKindConfig // Conditions carries the condition types, reasons and messages. Conditions Conditions // Certificate configures the DataPlane's TLS certificates. Certificate CertificateConfig[T, Cert] // ExtraWatches, when non-nil, registers additional watches on the // controller builder (e.g. a watch on user-referenced certificate // Secrets). It receives the in-progress builder and must return it. ExtraWatches func(blder *builder.Builder, mgr ctrl.Manager) *builder.Builder // Deployment configures the owned Deployment. Deployment DeploymentConfig[T] // Service configures the Ingress Service: the one feeding the DataPlane // status (SetStatusAddresses) and driving the ServiceReady condition. // It is always reconciled and never removed, so Enabled does not apply // to it and must be left nil. Service ServiceConfig[T] // AdminAPI, when non-nil, enables the exposure of the DataPlane's Admin // API: a dedicated admin Service and a TLS server certificate for it, // both gated on AdminAPI.Enabled. The certificate Secret is provisioned // through Certificate.Ensure, which has it signed by the cluster CA, and // its name is passed to Deployment.BuildContainer so the container can // wire the admin listener to it. AdminAPI *AdminAPIConfig[T] // HPAScalingSpec returns the HPA scaling spec, or nil when horizontal // scaling is not configured. HPAScalingSpec func(T) *k8sresources.HPAScalingSpec // SetStatusReplicas copies the Deployment replica counts into the DataPlane status. SetStatusReplicas func(dp T, replicas, readyReplicas int32) }
Config wires the type specific behavior of a specialized DataPlane reconciler into the shared generic Reconciler.
func (Config[T, Cert]) ControlPlaneKindConfig ¶ added in v2.4.0
func (c Config[T, Cert]) ControlPlaneKindConfig(kind string) (ControlPlaneKindConfig, bool)
ControlPlaneKindConfig returns the ControlPlaneKindConfig for the given kind.
type ControlPlaneConditions ¶ added in v2.4.0
type ControlPlaneConditions struct {
// ResolvedType is the type of the control plane resolution condition.
ResolvedType string
// ResolvedReason is the reason used when the control plane has been resolved.
ResolvedReason string
// ResolvedMessage is the message used when the control plane has been resolved.
ResolvedMessage string
// NotFoundReason is the reason used when the control plane was not found.
NotFoundReason string
// NotFoundMessage is the message used when the control plane was not found.
NotFoundMessage string
// NotProgrammedReason is the reason used when the control plane is not yet Programmed.
NotProgrammedReason string
// NotProgrammedMessage is the message used when the control plane is not yet Programmed.
NotProgrammedMessage string
// NotReadyReason is the reason used when a non-Konnect control plane is not yet Ready.
// Only used when the kind config sets ReadinessConditionType.
NotReadyReason string
// NotReadyMessage is the message used when a non-Konnect control plane is not yet Ready.
// Only used when the kind config sets ReadinessConditionType.
NotReadyMessage string
}
ControlPlaneConditions carries the condition types, reasons and messages used when resolving a control plane of a given kind. Values are supplied by each specialized controller from its API package constants.
type ControlPlaneKindConfig ¶ added in v2.4.0
type ControlPlaneKindConfig struct {
// Kind is the human-readable control plane kind used in logs, errors and
// events (e.g. "KonnectAIGateway", "OnPremAIGateway").
Kind string
// NewObject returns a new empty control plane object of this kind.
NewObject func() ControlPlaneObject
// ControlPlaneRefIndexField is the field index used to list DataPlanes by
// their reference to this kind of control plane.
ControlPlaneRefIndexField string
// IsKonnect reports whether this control plane kind is Konnect-backed.
// Konnect-backed control planes are checked for the Konnect Programmed
// condition during resolution and trigger Konnect certificate automation.
IsKonnect bool
// ReadinessConditionType is the condition type on a non-Konnect control
// plane (e.g. "Ready" for OnPremAIGateway) that must be True for the
// control plane to be considered resolved. When empty, a non-Konnect
// control plane is considered resolved as soon as it exists.
ReadinessConditionType string
// Conditions carries the control plane resolution condition types, reasons
// and messages for this kind.
Conditions ControlPlaneConditions
}
ControlPlaneKindConfig describes one kind of control plane that a DataPlane can reference. A DataPlane kind lists one entry per supported control plane kind in Config.ControlPlanes; each entry gets its own watch and index field.
type ControlPlaneObject ¶ added in v2.4.0
ControlPlaneObject is the constraint for the control plane types referenced by the DataPlane (e.g. KonnectAIGateway, KonnectEventGateway, OnPremAIGateway).
type ControlPlaneRef ¶ added in v2.4.0
type ControlPlaneRef struct {
// Kind is the human-readable kind of the referenced control plane. It must
// match the Kind of one of the Config's ControlPlanes entries.
Kind string
// Name is the name of the referenced control plane in the DataPlane's
// namespace. It is empty when the DataPlane has no control plane reference
// configured.
Name string
}
ControlPlaneRef identifies the control plane referenced by a DataPlane.
type DeploymentConfig ¶ added in v2.4.0
type DeploymentConfig[T Object] struct { // ContainerName is the name of the DataPlane container (e.g. "aigw", "keg"). ContainerName string // RelatedImageEnvVar is the environment variable used to override the container image. RelatedImageEnvVar string // DefaultImage is the fallback container image. DefaultImage string // ManagedByLabelValue is the value of the managed-by label (e.g. "aigateway-dataplane", "dataplane"). ManagedByLabelValue string // PodTemplateSpec returns the user-provided pod template overlay, or nil. PodTemplateSpec func(T) *corev1.PodTemplateSpec // DeploymentLabels returns the user-provided Deployment labels, or nil. DeploymentLabels func(T) map[string]string // DeploymentAnnotations returns the user-provided Deployment annotations, or nil. DeploymentAnnotations func(T) map[string]string // Replicas returns the replica count to seed on the Deployment: the static // replica count, or the HPA minReplicas when horizontal scaling is configured. Replicas func(T) *int32 // BuildContainer builds the DataPlane container and the additional volumes // it requires. The Konnect certificate volume itself is managed by the // shared machinery and appended separately when certSecretName is not empty, // and so is the Admin API certificate volume when adminCertSecretName is // not empty. cp.Object is nil when the DataPlane has no control plane // reference configured. BuildContainer func(dp T, cp ResolvedControlPlane, image, certSecretName, adminCertSecretName string) (corev1.Container, []corev1.Volume, error) // ReassertEnvVars lists env var names that the operator injects into the // DataPlane container and that must win over a user pod template overlay // (e.g. KONG_LICENSE_DATA): MergeObjects lets the overlay win on conflicts, // so the overlay's conflicting entries are dropped before the merge, like // the certificate checksum annotation is re-asserted after it. Leave it // empty for DataPlanes that inject no such env vars. ReassertEnvVars []string // LabelManaged, when non-nil, marks the Deployment and its pod template as // managed (e.g. k8sresources.LabelObjectAsAIGatewayDataPlaneManaged). LabelManaged func(metav1.Object) }
DeploymentConfig carries the type specific bits of the owned Deployment.
type EnsureCertificateFunc ¶ added in v2.4.0
type EnsureCertificateFunc[T Object] func( ctx context.Context, owner T, subject string, mtlsCASecretNN types.NamespacedName, usages []certificatesv1.KeyUsage, cl client.Client, additionalMatchingLabels client.MatchingLabels, certTTL time.Duration, ) (op.Result, *corev1.Secret, error)
EnsureCertificateFunc provisions (or finds) a TLS certificate Secret for a DataPlane, signed by the cluster CA: the mTLS client certificate used for the outbound connection to a Konnect-backed control plane, and the Admin API TLS server certificate when AdminAPI is configured. It mirrors secrets.EnsureCertificate, which cannot be called from generic code because of its union type constraint; pass an explicitly instantiated secrets.EnsureCertificate[*YourDataPlane] here.
type KongLicenseCacheGetter ¶ added in v2.4.0
type KongLicenseCacheGetter struct {
// contains filtered or unexported fields
}
KongLicenseCacheGetter is a LicenseGetter that picks the effective KongLicense directly from the manager's shared, informer-backed cache. Unlike the KongLicense reconciler's own cache, this is updated before watch events are delivered, so a reconcile triggered by a KongLicense add/update/delete never observes a stale license (no cross-workqueue ordering race).
func NewKongLicenseCacheGetter ¶ added in v2.4.0
func NewKongLicenseCacheGetter(r client.Reader) *KongLicenseCacheGetter
NewKongLicenseCacheGetter returns a LicenseGetter backed by the given (informer-backed) client reader.
func (KongLicenseCacheGetter) GetLicense ¶ added in v2.4.0
func (g KongLicenseCacheGetter) GetLicense() mo.Option[kong.License]
GetLicense returns the newest enabled KongLicense in the cache, in Kong configuration format. It does not check license validity.
type LicenseGetter ¶ added in v2.4.0
LicenseGetter provides the effective Kong license for DataPlane deployments. It is satisfied by the KongLicense reconciler (ingress-controller/internal/controllers/license); the local interface keeps this shared package decoupled from the KIC internals.
type Object ¶ added in v2.4.0
type Object interface {
client.Object
k8sutils.ConditionsAware
}
Object is the constraint for the reconciled DataPlane types (e.g. AIGatewayDataPlane, KegDataPlane).
type Reconciler ¶ added in v2.4.0
type Reconciler[T Object, Cert CertificateObject] struct { client.Client // LoggingMode controls the format of log output. LoggingMode logging.Mode ClusterCASecretName string ClusterCASecretNamespace string SecretLabelSelector string CertTTL time.Duration // TypeConverter is injected via the TypeConverterProvider at controller // registration time. It is used for both diff-before-apply and // structured-merge-diff based PodTemplateSpec merging. TypeConverter managedfields.TypeConverter // EventRecorder records Kubernetes events on the DataPlane objects. EventRecorder events.EventRecorder // LicenseGetter, when non-nil, provides the effective Kong license: the // reconciler propagates it to the gateway (via the type-specific // DeploymentConfig.BuildContainer) and reports its availability in the // license condition configured in Config.Conditions. LicenseGetter LicenseGetter // Config wires the type specific behavior. Config Config[T, Cert] }
Reconciler reconciles a specialized DataPlane object (e.g. AIGatewayDataPlane, KegDataPlane) using the behavior provided by Config.
func (*Reconciler[T, Cert]) Reconcile ¶ added in v2.4.0
Reconcile moves the current state of a DataPlane toward the desired state.
func (*Reconciler[T, Cert]) SetupWithManager ¶ added in v2.4.0
SetupWithManager sets up the controller with the Manager.
type ResolvedControlPlane ¶ added in v2.4.0
type ResolvedControlPlane struct {
// Kind is the human-readable kind of the resolved control plane
// (e.g. "KonnectAIGateway", "OnPremAIGateway").
Kind string
// IsKonnect reports whether the control plane is a Konnect-backed entity.
// Only Konnect-backed control planes are checked for the Konnect Programmed
// condition during resolution and trigger Konnect certificate automation.
IsKonnect bool
// Object is the resolved control plane object. It is nil when the DataPlane
// has no control plane reference configured.
Object ControlPlaneObject
}
ResolvedControlPlane carries the control plane resolved for a DataPlane through the reconcile flow. It abstracts over the concrete control plane kinds a DataPlane can reference (e.g. KonnectAIGateway, OnPremAIGateway for AIGatewayDataPlane); specialized controllers type-assert Object to the concrete type they support.
func (ResolvedControlPlane) IsResolved ¶ added in v2.4.0
func (cp ResolvedControlPlane) IsResolved() bool
IsResolved reports whether the DataPlane has a control plane reference resolved.
type ServiceConfig ¶ added in v2.4.0
type ServiceConfig[T Object] struct { // Description is the human-readable Service description used in logs, // errors and events (e.g. "Ingress", "Kafka"). Description string // NameSuffix is appended to the DataPlane name to form the Service name (e.g. "-ingress"). NameSuffix string // DefaultPortName is the name of the default port (e.g. "ingress"). DefaultPortName string // DefaultPort is the port exposed by default. DefaultPort int32 // ManagedByLabelValue is the value of the managed-by label used in the // Service selector (e.g. "aigateway-dataplane", "dataplane"). ManagedByLabelValue string // Options returns the user-provided Service options, or nil. Options func(T) *ServiceOptions // Enabled, when non-nil, reports whether this Service should be reconciled // for the DataPlane given its resolved control plane. A disabled Service // is not created, and a Service left over from an earlier reconcile in // which the predicate was true is removed. Only used on Services whose // existence is conditional (e.g. the Admin API Service derived from // AdminAPI): the primary Service always exists, so Config.Service.Enabled // must be left nil. Enabled func(dp T, cp ResolvedControlPlane) bool // SetStatusAddresses copies the Service's addresses into the DataPlane // status through this function; the Service's readiness feeds the // ServiceReady condition (see Conditions). Must be set on the primary // Service (Config.Service), which the status depends on; Services whose // existence is conditional (e.g. the Admin API Service derived from // AdminAPI) never set it. SetStatusAddresses func(dp T, addrs []operatorv1beta1.Address) }
ServiceConfig carries the type specific bits of an owned Service. For Ingress Service, defined in Config.Service For Admin Service, derived by Config.AdminAPI.serviceConfig().
type ServiceOptions ¶ added in v2.4.0
type ServiceOptions struct {
// Type determines how the Service is exposed.
Type corev1.ServiceType
// Annotations is an unstructured key value map stored with the Service resource.
Annotations map[string]string
// Labels are propagated to the Service.
Labels map[string]string
// ExternalTrafficPolicy describes how nodes distribute service traffic they
// receive on one of the Service's externally-facing addresses.
ExternalTrafficPolicy corev1.ServiceExternalTrafficPolicy
// TrafficDistribution offers a way to express preferences for how traffic is
// distributed to Service endpoints.
TrafficDistribution *string
// InternalTrafficPolicy describes how nodes distribute service traffic they
// receive on the ClusterIP.
InternalTrafficPolicy *corev1.ServiceInternalTrafficPolicy
// Ports is the list of ports that are exposed by the Service.
Ports []ServicePort
}
ServiceOptions mirrors the user-provided Service options of the specialized DataPlane APIs (e.g. spec.network.services.ingress). Each controller converts its API type into this shared representation.
type ServicePort ¶ added in v2.4.0
type ServicePort struct {
// Name is the name of the port.
Name *string
// Port is the port that will be exposed by the Service.
Port int32
// TargetPort is the port on the pod the Service routes traffic to.
TargetPort *intstr.IntOrString
// NodePort is the port on each node on which the Service is exposed when
// Type is NodePort or LoadBalancer.
NodePort *int32
}
ServicePort contains information on a user-provided Service port.