controller

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRoleBindingForBackupConfig

func BuildRoleBindingForBackupConfig(
	cluster *cnpgv1.Cluster,
) *rbacv1.RoleBinding

BuildRoleBinding builds the role binding object for this cluster

func BuildRoleForBackupConfigs

func BuildRoleForBackupConfigs(
	role *rbacv1.Role,
	cluster *cnpgv1.Cluster,
	backupConfigs []v1beta1.BackupConfig,
)

BuildRole builds the Role object for this cluster It collects all BackupConfig objects used by cluster and grants read/watch permissions on them only It also finds all secrets referenced by these BackupConfig and grants read permission on them

func GetRoleNameForBackupConfig added in v0.2.0

func GetRoleNameForBackupConfig(clusterName string) string

GetRBACName returns the name of the RBAC entities for the wal-g backup configs

Types

type BackupConfigReconciler

type BackupConfigReconciler struct {
	client.Client
	Scheme                   *runtime.Scheme
	BackupDeletionController *BackupDeletionController
}

BackupConfigReconciler reconciles a BackupConfig object

func (*BackupConfigReconciler) Reconcile

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

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.4/pkg/reconcile

func (*BackupConfigReconciler) SetupWithManager

func (r *BackupConfigReconciler) SetupWithManager(mgr ctrl.Manager, backupDeletionController *BackupDeletionController) error

SetupWithManager sets up the controller with the Manager.

type BackupDeletionController added in v0.2.0

type BackupDeletionController struct {
	client.Client
	// contains filtered or unexported fields
}

BackupDeletionController handles Backup and BackupConfig deletion requests and processes them sequentially per BackupConfig to prevent operator from overloading and wal-g collisions at deleting backups at the same storage

func NewBackupDeletionController added in v0.2.0

func NewBackupDeletionController(client client.Client) *BackupDeletionController

NewBackupDeletionController creates a new BackupDeletionController

func (*BackupDeletionController) EnqueueBackupConfigDeletion added in v0.2.2

func (b *BackupDeletionController) EnqueueBackupConfigDeletion(ctx context.Context, backupConfig *v1beta1.BackupConfig) error

EnqueueBackupConfigDeletion adds a BackupConfig to the deletion queue If the queue doesn't exist, it creates a new one and starts a goroutine to process it

func (*BackupDeletionController) EnqueueBackupDeletion added in v0.2.0

func (b *BackupDeletionController) EnqueueBackupDeletion(ctx context.Context, backup *cnpgv1.Backup) error

EnqueueBackupDeletion adds a Backup to the deletion queue for its BackupConfig If the queue doesn't exist, it creates a new one and starts a goroutine to process it

func (*BackupDeletionController) Start added in v0.2.0

Start begins the backup deletion controller's periodic check

type BackupReconciler added in v0.2.0

type BackupReconciler struct {
	client.Client
	Scheme             *runtime.Scheme
	DeletionController *BackupDeletionController
}

BackupReconciler reconciles a Backup object

func (*BackupReconciler) Reconcile added in v0.2.0

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

Reconcile handles Backup resource events

func (*BackupReconciler) SetupWithManager added in v0.2.0

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

SetupWithManager sets up the controller with the Manager.

type ConfigMapReconciler added in v0.2.2

type ConfigMapReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

ConfigMapReconciler reconciles ConfigMap objects to protect them from accidental deletion when they are referenced by BackupConfig resources

func (*ConfigMapReconciler) Reconcile added in v0.2.2

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

Reconcile handles ConfigMap resource events

func (*ConfigMapReconciler) SetupWithManager added in v0.2.2

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

SetupWithManager sets up the controller with the Manager.

type DeletionRequest added in v0.2.2

type DeletionRequest struct {
	// Type of resource to delete
	Type ResourceType
	// NamespacedName of the resource
	Key types.NamespacedName
}

DeletionRequest represents a request to delete a resource

type ResourceType added in v0.2.2

type ResourceType string

ResourceType defines the type of resource being deleted

const (
	// ResourceTypeBackup represents a Backup resource
	ResourceTypeBackup ResourceType = "Backup"
	// ResourceTypeBackupConfig represents a BackupConfig resource
	ResourceTypeBackupConfig ResourceType = "BackupConfig"

	// Timeout for resource cleanup, if exceeded - deletion process will be aborted and retried
	// Needed to prevent stuck on deletion when incorrect BackupConfig / etc.
	DeletionRequestTimeout time.Duration = 10 * time.Minute
)

type RetentionController added in v0.2.0

type RetentionController struct {
	// contains filtered or unexported fields
}

RetentionController periodically checks all BackupConfig resources and applies retention policies to delete old backups

func NewRetentionController added in v0.2.0

func NewRetentionController(client client.Client, checkInterval time.Duration) *RetentionController

NewRetentionController creates a new RetentionController

func (*RetentionController) Start added in v0.2.0

func (r *RetentionController) Start(ctx context.Context) error

Start begins the retention controller's periodic check

type SecretReconciler added in v0.2.2

type SecretReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

SecretReconciler reconciles Secret objects to protect them from accidental deletion when they are referenced by BackupConfig resources

func (*SecretReconciler) Reconcile added in v0.2.2

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

Reconcile handles Secret resource events

func (*SecretReconciler) SetupWithManager added in v0.2.2

func (r *SecretReconciler) 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