Documentation
¶
Index ¶
- Constants
- func IsSSAProviderNeeded(cfg Config) bool
- func NewWatchNamespaces(watchNamespaces string) ([]string, error)
- func Run(cfg Config, scheme *runtime.Scheme, setupControllers SetupControllersFunc, ...) error
- func SecretCacheByObject(selector string) (map[client.Object]cache.ByObject, error)
- func SetupCacheIndexes(ctx context.Context, mgr manager.Manager, cfg Config) error
- type AutoHandler
- type Config
- type Controller
- type ControllerDef
- type FeatureGate
- type FeatureGates
- type MetricsAccessFilter
- type SetupControllersFunc
Constants ¶
const ( // DefaultMetricsAddr is the default bind address for the metrics server. DefaultMetricsAddr = ":8080" // DefaultProbeAddr is the default bind address for the health probe server. DefaultProbeAddr = ":8081" // DefaultControlPlaneConfigurationDumpAddr is the default bind address for the server to dump ControlPlane configuration. DefaultControlPlaneConfigurationDumpAddr = ":10256" )
Variables ¶
This section is empty.
Functions ¶
func IsSSAProviderNeeded ¶ added in v2.3.0
IsSSAProviderNeeded reports whether cfg requires the shared SSA TypeConverterProvider, i.e. whether any SSA-using controller (EventGatewayDataPlane, AIGatewayDataPlane, OnPremAIGateway, GWAdmin, MCPServer, or the hybridgateway Gateway API controllers) is enabled.
func NewWatchNamespaces ¶
NewWatchNamespaces parses the watchNamespaces string and returns a slice of trimmed namespace names.
func Run ¶
func Run( cfg Config, scheme *runtime.Scheme, setupControllers SetupControllersFunc, startedChan chan<- struct{}, metadata metadata.Info, ) error
Run runs the manager. Parameter cfg represents the configuration for the manager that for normal operation is derived from command-line flags. The function setupControllers is expected to return a list of configured ControllerDef that will be added to the manager. The function admissionRequestHandler is used to construct the admission webhook handler for the validating webhook that is added to the manager too. Argument startedChan can be used as a signal to notify the caller when the manager has been started. Specifically, this channel gets closed once the manager's caches are synced and its controllers are started. Pass nil if you don't need this signal.
func SecretCacheByObject ¶ added in v2.4.0
SecretCacheByObject returns the cache options the manager uses to only cache the Secrets whose selector label is set to "true" or "internal". It lets tests run a manager whose Secret cache is filtered as in production.
Types ¶
type AutoHandler ¶
AutoHandler decides whether the specific controller shall be enabled (true) or disabled (false).
type Config ¶
type Config struct {
MetricsAddr string
MetricsAccessFilter MetricsAccessFilter
ProbeAddr string
LeaderElection bool
LeaderElectionNamespace string
LeaderElectionLeaseDuration time.Duration
LeaderElectionRenewDeadline time.Duration
LeaderElectionRetryPeriod time.Duration
AnonymousReports bool
LoggingMode logging.Mode
ValidateImages bool
Out *os.File
ControllerName string
ControllerNamespace string
APIServerHost string
APIServerQPS int
APIServerBurst int
KubeconfigPath string
CacheSyncPeriod time.Duration
CacheSyncTimeout time.Duration
ClusterCASecretName string
ClusterCASecretNamespace string
LoggerOpts *zap.Options
EnforceConfig bool
ClusterDomain string
FQDNModeEnabled bool
EmitKubernetesEvents bool
// ReadYourOwnWritesConsistencyEnabled makes reads through the cached client
// wait for the cache to observe the operator's own preceding writes.
ReadYourOwnWritesConsistencyEnabled bool
// IPFamily is the cluster's IP family, used to decide which IP family
// (or families) DataPlanes' Kong listens bind to. Defaults to
// ipfamily.Auto, in which case Run resolves it to a concrete family by
// detecting the cluster's IP family before controllers are set up.
// Resolution of ipfamily.Auto is fatal if detection fails: the operator
// exits with an error instead of assuming a concrete family.
IPFamily ipfamily.IPFamily
// Platform is the k8s platform flavor the operator runs on. When
// admission assigns the container user and group (OpenShift
// SecurityContextConstraints), the operator leaves them unset on hardened
// containers instead of pinning them. platform.Auto resolves the flavor
// by probing the apiserver. Resolution of platform.Auto is fatal if the
// probe fails: the operator exits with an error instead of assuming a
// concrete flavor.
Platform platform.Platform
// SecretLabelSelector specifies the label which will be used to limit the ingestion of secrets. Only those that have this label set to "true" will be ingested.
SecretLabelSelector string
// ConfigMapLabelSelector specifies the label which will be used to limit the ingestion of configmaps. Only those that have this label set to "true" will be ingested.
ConfigMapLabelSelector string
// WatchNamespaces is a list of namespaces to watch. If empty (default), all namespaces are watched.
WatchNamespaces []string
// ServiceAccountToImpersonate is the name of the service account to impersonate,
// by the controller manager, when making requests to the API server.
// Use for testing purposes only.
ServiceAccountToImpersonate string
// controllers for standard APIs and features
GatewayControllerEnabled bool
ControlPlaneControllerEnabled bool
DataPlaneControllerEnabled bool
DataPlaneBlueGreenControllerEnabled bool
// Options for controlling features related to ControlPlanes.
ControlPlaneConfigurationDumpEnabled bool
ControlPlaneConfigurationDumpAddr string
// Controllers for specialty APIs and experimental features.
AIGatewayControllerEnabled bool
KongPluginInstallationControllerEnabled bool
KonnectSyncPeriod time.Duration
KonnectRequestTimeout time.Duration
// KonnectListPageSize is the page size requested when listing Konnect
// entities page by page, e.g. to find an entity by its Kubernetes UID.
// 0 means consts.DefaultKonnectListPageSize.
KonnectListPageSize int64
// KonnectServerURLDomains are the domains a KonnectAPIAuthConfiguration
// serverURL host must belong to. A host outside the list is refused before
// any request is made. Defaults to konnectserver.DefaultDomains.
KonnectServerURLDomains konnectserver.Domains
// TODO: remove this a couple of versions after 2.1 release
// TODO: https://github.com/Kong/kong-operator/issues/2768
KonnectControllerMaxConcurrentReconciles uint
MaxConcurrentReconcilesKonnect uint
MaxConcurrentReconcilesDataPlane uint
MaxConcurrentReconcilesControlPlane uint
MaxConcurrentReconcilesGateway uint
GatewayAPIExperimentalEnabled bool
ControlPlaneExtensionsControllerEnabled bool
// Controllers for Konnect APIs.
KonnectControllersEnabled bool
// Controllers for Event Gateway APIs.
KEGDataPlaneControllerEnabled bool
OnPremEventGatewayControllerEnabled bool
// OnPremEventGatewayKindAvailable tells whether the cluster serves the
// resources of the OnPremEventGateway control plane kind of the
// KegDataPlane controller. It isn't a flag: it is decided once at
// startup, so that the indexes and the watches of the kind agree.
OnPremEventGatewayKindAvailable bool
// Controller for gw-admin, the on-prem control plane of the data planes
// that do not use Konnect.
GWAdminControllerEnabled bool
// GWAdminCATTL is the validity of the certificate authorities created
// for a GWAdmin.
GWAdminCATTL time.Duration
// GWAdminCertTTL is the validity of the certificates issued for a
// GWAdmin.
GWAdminCertTTL time.Duration
// Controllers for AI Gateway APIs.
AIGatewayDataPlaneControllerEnabled bool
OnPremAIGatewayControllerEnabled bool
// FeatureGates holds the set of feature gates enabled via the --feature-gates flag.
FeatureGates FeatureGates
// Webhook options.
ConversionWebhookEnabled bool
ValidatingWebhookEnabled bool
// ValidatingWebhookCertDir is the directory that holds the validating
// webhook's TLS certificate (tls.crt) and key (tls.key).
ValidatingWebhookCertDir string
// CertTTL is the time-to-live for certificates issued by the operator.
CertTTL time.Duration
// CertExpirationMargin is the duration before certificate expiration at which
// the secret_cert controller will trigger certificate renewal.
CertExpirationMargin time.Duration
}
Config represents the configuration for the manager.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a default configuration for the manager.
type Controller ¶
Controller is a Kubernetes controller that can be plugged into Manager.
type ControllerDef ¶
type ControllerDef struct {
Enabled bool
Controller Controller
}
ControllerDef is a specification of a Controller that can be conditionally registered with Manager.
func SetupControllers ¶
func SetupControllers(mgr manager.Manager, c *Config, cpsMgr *multiinstance.Manager, ssaProvider *controllerpkgssa.TypeConverterProvider) ([]ControllerDef, error)
SetupControllers returns a list of ControllerDefs based on config.
func (*ControllerDef) MaybeSetupWithManager ¶
MaybeSetupWithManager runs SetupWithManager on the controller if it is enabled and its AutoHandler (if any) indicates that it can load.
func (*ControllerDef) Name ¶
func (c *ControllerDef) Name() string
Name returns a human-readable name of the controller.
type FeatureGate ¶ added in v2.2.0
type FeatureGate string
FeatureGate is a named feature that can be enabled via the --feature-gates flag.
const ( // FeatureGateMCPServer enables the MCPServer controller. FeatureGateMCPServer FeatureGate = "mcp-server" )
type FeatureGates ¶ added in v2.2.0
type FeatureGates map[FeatureGate]struct{}
FeatureGates holds the set of enabled feature gates parsed from the --feature-gates flag.
func NewFeatureGates ¶ added in v2.2.0
func NewFeatureGates(s string) (FeatureGates, error)
NewFeatureGates parses a comma-separated list of feature gate names. An empty string is valid and results in no gates being enabled. Returns an error if any name is not a known feature gate.
func (FeatureGates) Enabled ¶ added in v2.2.0
func (f FeatureGates) Enabled(gate FeatureGate) bool
Enabled reports whether the given feature gate is enabled.
func (FeatureGates) String ¶ added in v2.2.0
func (f FeatureGates) String() string
String returns the comma-separated, sorted list of enabled feature gates.
type MetricsAccessFilter ¶
type MetricsAccessFilter string
MetricsAccessFilter defines the access filter function for the metrics endpoint.
const ( // MetricsAccessFilterOff disabled the access filter on metrics endpoint. MetricsAccessFilterOff MetricsAccessFilter = "off" // MetricsAccessFilterRBAC enables the access filter on metrics endpoint. // For more information consult: // https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/metrics/filters#WithAuthenticationAndAuthorization MetricsAccessFilterRBAC MetricsAccessFilter = "rbac" )
func (*MetricsAccessFilter) Set ¶
func (mf *MetricsAccessFilter) Set(v string) error
Set implements flag.Value.
func (MetricsAccessFilter) String ¶
func (mf MetricsAccessFilter) String() string
String returns the string representation of the MetricsFilter.
type SetupControllersFunc ¶
type SetupControllersFunc func(manager.Manager, *Config, *multiinstance.Manager, *controllerpkgssa.TypeConverterProvider) ([]ControllerDef, error)
SetupControllersFunc represents function to setup controllers, which is called in Run function. ssaProvider is non-nil only when at least one SSA-using controller is active (KEGDataPlane or MCPServer); it is nil otherwise.