dataplane

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DataPlaneConditionValidationFailed is a reason which indicates validation of
	// a dataplane is failed.
	DataPlaneConditionValidationFailed consts.ConditionReason = "ValidationFailed"
)

Variables

This section is empty.

Functions

func DataPlaneWatchBuilder

func DataPlaneWatchBuilder(mgr ctrl.Manager) *builder.Builder

DataPlaneWatchBuilder creates a controller builder pre-configured with the necessary watches for DataPlane resources that are managed by the operator.

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

func (r *BlueGreenReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile moves the current state of an object to the intended state.

func (*BlueGreenReconciler) SetupWithManager

func (r *BlueGreenReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type Callback

type Callback func(ctx context.Context, d *operatorv1beta1.DataPlane, c client.Client, s any) error

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

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

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

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

type DataPlaneOwnedResource interface {
	corev1.Service | appsv1.Deployment | corev1.Secret
}

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

Reconcile reconciles the DataPlaneOwnedResource object.

func (*DataPlaneOwnedResourceFinalizerReconciler[T, PT]) SetupWithManager

func (r *DataPlaneOwnedResourceFinalizerReconciler[T, PT]) SetupWithManager(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

WithOpts adds option functions to a DeploymentBuilder.

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
	// contains filtered or unexported fields
}

Reconciler reconciles a DataPlane object

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile moves the current state of an object to the intended state.

func (*Reconciler) SetupWithManager

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

Jump to

Keyboard shortcuts

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