controllers

package
v0.0.0-...-4854836 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeploymentHelper

type DeploymentHelper interface {
	ValidateAndCreateDeployment(ctx context.Context, memcached *cachev1beta1.Memcached) (ctrl.Result, error)
	CreateNewDeployment(ctx context.Context, memcached *cachev1beta1.Memcached) (ctrl.Result, error)
	GenerateDeploymentSpec(memcached *cachev1beta1.Memcached) (*appsv1.DeploymentSpec, error)
	GeneratePodSpec(memcached *cachev1beta1.Memcached, image string) (*corev1.PodSpec, error)
	GenerateSecurityContext() *corev1.SecurityContext
	GetLabels(name string, image string) map[string]string
}
DeploymentHelper handles all deployment related operations

for the Memcached controller including creation, updates and security configuration.

func NewDeploymentHelper

func NewDeploymentHelper(controller *MemcachedReconciler) DeploymentHelper

type MemcachedReconciler

type MemcachedReconciler struct {
	client.Client
	Scheme   *runtime.Scheme
	Recorder record.EventRecorder
	// contains filtered or unexported fields
}

MemcachedReconciler reconciles a Memcached object This is the primary controller struct that handles the reconciliation of Memcached resources

func (*MemcachedReconciler) Reconcile

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

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state.

It is essential for the controller's reconciliation loop to be idempotent. By following the Operator pattern you will create Controllers which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster. Breaking this recommendation goes against the design principles of controller-runtime. and may lead to unforeseen consequences such as resources becoming stuck and requiring manual intervention.

For further info: - About Operator Pattern: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/ - About Controllers: https://kubernetes.io/docs/concepts/architecture/controller/ - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.0/pkg/reconcile

func (*MemcachedReconciler) SetupWithManager

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

SetupWithManager sets up the controller with the Manager. Note that the Deployment will be also watched in order to ensure its desirable state on the cluster

type ReconciliationHelper

type ReconciliationHelper interface {
	FetchMemcachedInstance(ctx context.Context, req ctrl.Request) (*cachev1beta1.Memcached, error)
	ReconcileDeployment(ctx context.Context, memcached *cachev1beta1.Memcached) (ctrl.Result, error)
	ExecuteFinalizer(ctx context.Context, memcached *cachev1beta1.Memcached) (ctrl.Result, error)
	AddFinalizer(ctx context.Context, memcached *cachev1beta1.Memcached) (ctrl.Result, error)
}

ReconciliationHelper provides core reconciliation operations for the Memcached controller.

It implements the core reconciliation loop which aims to move the current state of the cluster closer to the desired state. The reconciliation must be idempotent.

func NewReconciliationHelper

func NewReconciliationHelper(statusHelper StatusHelper, deployHelper DeploymentHelper, controller *MemcachedReconciler) ReconciliationHelper

type StatusHelper

type StatusHelper interface {
	InitializeStatus(ctx context.Context, memcached *cachev1beta1.Memcached) error
	UpdateSuccessStatus(ctx context.Context, memcached *cachev1beta1.Memcached, size int32) error
	UpdateStatusWithError(ctx context.Context, memcached *cachev1beta1.Memcached, message string, err error) error
	UpdateDegradedStatus(ctx context.Context, memcached *cachev1beta1.Memcached, message string) error
}

StatusHelper manages all status-related operations for the Memcached controller.

It handles setting and updating various status conditions that reflect the state of the Memcached custom resource and its associated components. Status conditions are crucial for providing visibility into the operational state of the resource.

Key responsibilities: - Initializing status conditions - Updating success/failure states - Managing degraded states during deletion

func NewStatusHelper

func NewStatusHelper(controller *MemcachedReconciler) StatusHelper

Jump to

Keyboard shortcuts

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