manager

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 84 Imported by: 0

Documentation

Index

Constants

View Source
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

func IsSSAProviderNeeded(cfg Config) bool

IsSSAProviderNeeded reports whether cfg requires the shared SSA TypeConverterProvider, i.e. whether any SSA-using controller (EventGatewayDataPlane, AIGatewayDataPlane, MCPServer, or the hybridgateway Gateway API controllers) is enabled.

func NewWatchNamespaces

func NewWatchNamespaces(watchNamespaces string) ([]string, error)

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 when manager.Start() is called. Pass nil if you don't need this signal.

func SetupCacheIndexes

func SetupCacheIndexes(ctx context.Context, mgr manager.Manager, cfg Config) error

SetupCacheIndexes sets up all the cache indexes required by the controllers.

Types

type AutoHandler

type AutoHandler func(client.Client) (bool, error)

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
	// 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
	// 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

	// Controllers for AI Gateway APIs.
	AIGatewayDataPlaneControllerEnabled bool

	// FeatureGates holds the set of feature gates enabled via the --feature-gates flag.
	FeatureGates FeatureGates

	// Webhook options.
	ConversionWebhookEnabled bool
	ValidatingWebhookEnabled bool

	// 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

type Controller interface {
	SetupWithManager(context.Context, ctrl.Manager) error
}

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

func (c *ControllerDef) MaybeSetupWithManager(ctx context.Context, mgr ctrl.Manager) error

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

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.

Directories

Path Synopsis
Package metadata includes metadata variables for logging and reporting.
Package metadata includes metadata variables for logging and reporting.

Jump to

Keyboard shortcuts

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