Documentation ¶
Index ¶
- Constants
- Variables
- func DataPlaneWatchBuilder(mgr ctrl.Manager) *builder.Builder
- type BlueGreenReconciler
- type Callback
- type CallbackManager
- type CallbackRunner
- type ClientObjectPointer
- type DataPlaneCallbacks
- type DataPlaneOwnedResource
- type DataPlaneOwnedResourceFinalizerReconciler
- type DataPlaneOwnedResourcePointer
- type DeepCopier
- type DeploymentBuilder
- func (d *DeploymentBuilder) BuildAndDeploy(ctx context.Context, dataplane *operatorv1beta1.DataPlane, ...) (*appsv1.Deployment, op.Result, error)
- func (d *DeploymentBuilder) WithAdditionalLabels(labels client.MatchingLabels) *DeploymentBuilder
- func (d *DeploymentBuilder) WithAfterCallbacks(c CallbackManager) *DeploymentBuilder
- func (d *DeploymentBuilder) WithBeforeCallbacks(c CallbackManager) *DeploymentBuilder
- func (d *DeploymentBuilder) WithClusterCertificate(name string) *DeploymentBuilder
- func (d *DeploymentBuilder) WithDefaultImage(image string) *DeploymentBuilder
- func (d *DeploymentBuilder) WithOpts(opts ...k8sresources.DeploymentOpt) *DeploymentBuilder
- type KonnectExtensionReconciler
- type Reconciler
Constants ¶
const ( // DataPlaneConditionValidationFailed is a reason which indicates validation of // a dataplane is failed. DataPlaneConditionValidationFailed consts.ConditionReason = "ValidationFailed" // DataPlaneConditionReferencedResourcesNotAvailable is a reason which indicates // that the referenced resources in DataPlane configuration (e.g. KongPluginInstallation) // are not available. DataPlaneConditionReferencedResourcesNotAvailable consts.ConditionReason = "ReferencedResourcesNotAvailable" )
Variables ¶
var ( // ErrCrossNamespaceReference is returned when a Konnect extension references a different namespace. ErrCrossNamespaceReference = errors.New("cross-namespace reference is not currently supported for Konnect extensions") // ErrKonnectExtensionNotFound is returned when a Konnect extension is not found. ErrKonnectExtensionNotFound = errors.New("konnect extension not found") // ErrClusterCertificateNotFound is returned when a cluster certificate secret referenced in the KonnectExtension is not found. ErrClusterCertificateNotFound = errors.New("cluster certificate not found") )
Functions ¶
Types ¶
type BlueGreenReconciler ¶
type BlueGreenReconciler struct { client.Client // DataPlaneController contains the DataPlaneReconciler to which we delegate // the DataPlane reconciliation when it's not yet ready to accept BlueGreen // rollout changes or BlueGreen rollout has not been configured. DataPlaneController reconcile.Reconciler // ClusterCASecretName contains the name of the Secret that contains the CA // certificate data which will be used when generating certificates for DataPlane's // Deployment. ClusterCASecretName string // ClusterCASecretName contains the namespace of the Secret that contains the CA // certificate data which will be used when generating certificates for DataPlane's // Deployment. ClusterCASecretNamespace string // DevelopmentMode indicates if the controller should run in development mode, // which causes it to e.g. perform less validations. DevelopmentMode bool // Callbacks is a set of Callback functions to run at various stages of reconciliation. Callbacks DataPlaneCallbacks ContextInjector ctxinjector.CtxInjector DefaultImage string }
BlueGreenReconciler reconciles a DataPlane objects for purposes of Blue Green rollouts.
func (*BlueGreenReconciler) Reconcile ¶
Reconcile moves the current state of an object to the intended state.
func (*BlueGreenReconciler) SetupWithManager ¶
SetupWithManager sets up the controller with the Manager.
type Callback ¶
Callback is a function that performs operations on some resource owned by a DataPlane.
type CallbackManager ¶
type CallbackManager struct {
// contains filtered or unexported fields
}
CallbackManager collects a set of callbacks.
func CreateCallbackManager ¶
func CreateCallbackManager() CallbackManager
CreateCallbackManager creates a new CallbackManager, with an empty callback set.
func (*CallbackManager) Do ¶
func (m *CallbackManager) Do(ctx context.Context, d *operatorv1beta1.DataPlane, c client.Client, s any) []error
Do runs all callbacks in the manager's callback set on a subject. It returns a slice of errors wrapped with the callback name.
func (*CallbackManager) Register ¶
func (m *CallbackManager) Register(c Callback, name string) error
Register adds a callback to the manager's callback set. Returns an error on duplicate names.
func (*CallbackManager) Unregister ¶
func (m *CallbackManager) Unregister(name string) error
Unregister removes a callback with a given name from the callback set.
type CallbackRunner ¶
type CallbackRunner struct {
// contains filtered or unexported fields
}
CallbackRunner runs a set of callbacks for a DataPlane on a subject child resource. All callbacks executed by a CallbackRunner instance must share the same subject type.
func NewCallbackRunner ¶
func NewCallbackRunner(cl client.Client) *CallbackRunner
NewCallbackRunner creates a callback runner.
func (*CallbackRunner) Do ¶
func (r *CallbackRunner) Do(ctx context.Context, subject any) []error
Do runs all registered callbacks in the runner's manager on a subject and returns a slice of callback errors.
func (*CallbackRunner) For ¶
func (r *CallbackRunner) For(dataplane *operatorv1beta1.DataPlane) *CallbackRunner
For sets the owner of the callback runner.
func (*CallbackRunner) Modifies ¶
func (r *CallbackRunner) Modifies(subjType reflect.Type) *CallbackRunner
Modifies sets the child resource type this callback runner operates on.
func (*CallbackRunner) Runs ¶
func (r *CallbackRunner) Runs(m CallbackManager) *CallbackRunner
Runs provides the callback set manager the callback runner will run.
type ClientObjectPointer ¶
type ClientObjectPointer[T DataPlaneOwnedResource] interface { *T client.Object }
ClientObjectPointer is a type contraint which enforces client.Object interface and holds *T.
type DataPlaneCallbacks ¶
type DataPlaneCallbacks struct { // BeforeDeployment runs before the controller starts building its Deployment. BeforeDeployment CallbackManager // AfterDeployment runs after the controller has initially built its Deployment, but before it applies // user patches and sets default EnvVars. AfterDeployment CallbackManager }
DataPlaneCallbacks holds callback managers for the DataPlane controller.
type DataPlaneOwnedResource ¶
DataPlaneOwnedResource is a type that represents a Kubernetes resource that is owned by a DataPlane.
type DataPlaneOwnedResourceFinalizerReconciler ¶
type DataPlaneOwnedResourceFinalizerReconciler[T DataPlaneOwnedResource, PT DataPlaneOwnedResourcePointer[T, PT]] struct { Client client.Client DevelopmentMode bool }
DataPlaneOwnedResourceFinalizerReconciler reconciles DataPlaneOwnedResource objects. It removes the finalizer from the object only when the parent DataPlane is deleted to prevent accidental deletion of the DataPlane owned resources. This is a stop gap solution until we implement proper self-healing for the DataPlane resources, see: https://github.com/Kong/gateway-operator/issues/1028
func NewDataPlaneOwnedResourceFinalizerReconciler ¶
func NewDataPlaneOwnedResourceFinalizerReconciler[T DataPlaneOwnedResource, PT DataPlaneOwnedResourcePointer[T, PT]]( client client.Client, developmentMode bool, ) *DataPlaneOwnedResourceFinalizerReconciler[T, PT]
NewDataPlaneOwnedResourceFinalizerReconciler returns a new DataPlaneOwnedResourceFinalizerReconciler for a type passed as the first parameter. The PT param is used only to allow inferring the type of the object so that we can write:
NewDataPlaneOwnedResourceFinalizerReconciler(&corev1.Service{}, ...)
instead of repeating the type twice as follows:
NewDataPlaneOwnedResourceFinalizerReconciler[corev1.Service, *corev1.Service](...).
func (DataPlaneOwnedResourceFinalizerReconciler[T, PT]) Reconcile ¶
func (r DataPlaneOwnedResourceFinalizerReconciler[T, PT]) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile reconciles the DataPlaneOwnedResource object.
func (*DataPlaneOwnedResourceFinalizerReconciler[T, PT]) SetupWithManager ¶
func (r *DataPlaneOwnedResourceFinalizerReconciler[T, PT]) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type DataPlaneOwnedResourcePointer ¶
type DataPlaneOwnedResourcePointer[T DataPlaneOwnedResource, PT ClientObjectPointer[T]] interface { // We need DeepCopier part of the type constraint to ensure that we can use // DeepCopy() *T on DataPlaneOwnedResourcePointer objects. DeepCopier[T, PT] // ClientObjectPointer is needed to ensure that we get access to the methods // of T with pointer receivers and to enforce fulfilling the client.Object // interface. ClientObjectPointer[T] }
DataPlaneOwnedResourcePointer is a type that represents a pointer to a DataPlaneOwnedResource that implements client.Object interface. It allows us to use it to create a new instance of the object using DataPlaneOwnedResource type param and cast it in compile time to DataPlaneOwnedResourcePointer. See: https://stackoverflow.com/a/69575720/7958339
type DeepCopier ¶
type DeepCopier[T DataPlaneOwnedResource, PT ClientObjectPointer[T]] interface { DeepCopy() PT }
DeepCopier is a type contraint which allows enforcing DeepCopy() *T method on objects.
type DeploymentBuilder ¶
type DeploymentBuilder struct {
// contains filtered or unexported fields
}
DeploymentBuilder builds a Deployment for a DataPlane.
func NewDeploymentBuilder ¶
func NewDeploymentBuilder(logger logr.Logger, client client.Client) *DeploymentBuilder
NewDeploymentBuilder creates a DeploymentBuilder.
func (*DeploymentBuilder) BuildAndDeploy ¶
func (d *DeploymentBuilder) BuildAndDeploy( ctx context.Context, dataplane *operatorv1beta1.DataPlane, developmentMode bool, ) (*appsv1.Deployment, op.Result, error)
BuildAndDeploy builds and deploys a DataPlane Deployment, or reduces Deployments if there are more than one. It returns the Deployment if it created or updated one, or nil if it needed to reduce or did not need to update an existing Deployment.
func (*DeploymentBuilder) WithAdditionalLabels ¶
func (d *DeploymentBuilder) WithAdditionalLabels(labels client.MatchingLabels) *DeploymentBuilder
WithAdditionalLabels configures additional labels for a DeploymentBuilder.
func (*DeploymentBuilder) WithAfterCallbacks ¶
func (d *DeploymentBuilder) WithAfterCallbacks(c CallbackManager) *DeploymentBuilder
WithAfterCallbacks sets callbacks to run after initial Deployment generation.
func (*DeploymentBuilder) WithBeforeCallbacks ¶
func (d *DeploymentBuilder) WithBeforeCallbacks(c CallbackManager) *DeploymentBuilder
WithBeforeCallbacks sets callbacks to run before initial Deployment generation.
func (*DeploymentBuilder) WithClusterCertificate ¶
func (d *DeploymentBuilder) WithClusterCertificate(name string) *DeploymentBuilder
WithClusterCertificate configures a cluster certificate name for a DeploymentBuilder.
func (*DeploymentBuilder) WithDefaultImage ¶
func (d *DeploymentBuilder) WithDefaultImage(image string) *DeploymentBuilder
WithDefaultImage configures the default image.
func (*DeploymentBuilder) WithOpts ¶
func (d *DeploymentBuilder) WithOpts(opts ...k8sresources.DeploymentOpt) *DeploymentBuilder
WithOpts adds option functions to a DeploymentBuilder.
type KonnectExtensionReconciler ¶ added in v1.4.0
type KonnectExtensionReconciler struct { client.Client ContextInjector ctxinjector.CtxInjector // DevelopmentMode indicates if the controller should run in development mode, // which causes it to e.g. perform less validations. DevelopmentMode bool }
KonnectExtensionReconciler reconciles a KonnectExtension object.
func (*KonnectExtensionReconciler) Reconcile ¶ added in v1.4.0
func (r *KonnectExtensionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile reconciles a KonnectExtension object.
func (*KonnectExtensionReconciler) SetupWithManager ¶ added in v1.4.0
SetupWithManager sets up the controller with the Manager.
type Reconciler ¶
type Reconciler struct { client.Client Scheme *runtime.Scheme ClusterCASecretName string ClusterCASecretNamespace string DevelopmentMode bool Validator dataPlaneValidator Callbacks DataPlaneCallbacks ContextInjector ctxinjector.CtxInjector DefaultImage string KonnectEnabled bool // contains filtered or unexported fields }
Reconciler reconciles a DataPlane object
func (*Reconciler) Reconcile ¶
Reconcile moves the current state of an object to the intended state.
func (*Reconciler) SetupWithManager ¶
SetupWithManager sets up the controller with the Manager.
Source Files ¶
- bluegreen_controller.go
- controller.go
- controller_conditions.go
- controller_rbac.go
- controller_reconciler_utils.go
- controller_utils.go
- dynamic.go
- konnectextension.go
- konnectextension_controller.go
- konnectextension_controller_rbac.go
- owned_custom_plugins.go
- owned_deployment.go
- owned_finalizer_controller.go
- owned_resources.go
- watch.go