Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an overview of the nonadmin backup controller #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions docs/developer/non-admin-controller.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# OADP NonAdminBackup Controller

The OADP NonAdminBackup Kubernetes controller manages the lifecycle of custom resources called `NonAdminBackup`. Let's break down the code and understand its functionality.

## Purpose

The primary goal of this controller is to allow users with limited permissions (non-admins) to trigger and manage Velero backups within their namespaces. It acts as an intermediary between the non-admin user and Velero, ensuring that backups are created and managed securely within the defined boundaries.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?
Within the namespaces to which they have access to

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sounds ai'ish, talk about everything and nothing:
ensuring that backups are created and managed securely within the defined boundaries.


## Key Components

### NonAdminBackup Custom Resource

* Represents a backup request initiated by a non-admin user.
* Contains a `BackupSpec` field, which mirrors the Velero `BackupSpec` and defines what to back up.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current discussion it doesn't mirror the Velero BackupSpec but it's used to create BackupSpec

* Tracks the status of the backup process through the `Status` field.

### NonAdminBackupReconciler

* The core controller responsible for processing `NonAdminBackup` resources.
* Watches for changes to `NonAdminBackup` objects and triggers reconciliation loops.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also watches changes to the Velero Backup and updaates the NonAdminBackup


### Reconciliation Loop

* **Init:** Initializes the `NonAdminBackup` status if it's a new object.
* **ValidateSpec:** Ensures the provided `BackupSpec` is valid and adheres to security constraints.
* Rejects backups targeting namespaces outside the user's allowed scope.
* Sets appropriate conditions on the `NonAdminBackup` object to indicate success or failure.
* **UpdateSpecStatus:**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the comment from @shubham-pampattiwar this function will probably be changed to some other name.

* If the `VeleroBackup` doesn't exist, it creates one based on the validated `BackupSpec`.
* If the `VeleroBackup` exists, it synchronizes the `NonAdminBackup` status with the `VeleroBackup` status.
* Updates the `NonAdminBackup` object with relevant information from the `VeleroBackup`.

## Workflow

1. **User Creates NonAdminBackup:** A non-admin user creates a `NonAdminBackup` object, specifying the resources to back up within their namespace.
2. **Controller Detects Creation:** The `NonAdminBackupReconciler` detects the new object and triggers a reconciliation loop.
3. **Validation and Creation:** The controller validates the `BackupSpec` and creates a corresponding `VeleroBackup` object in the designated OADP namespace.
4. **Status Synchronization:** The controller continuously monitors the `VeleroBackup` and updates the `NonAdminBackup` status, reflecting the progress and completion state.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.


## Security Considerations

* **Namespace Isolation:** The controller ensures that non-admin users can only trigger backups within their own namespaces, preventing unauthorized access to resources in other namespaces.
* **Spec Validation:** The `ValidateSpec` function plays a crucial role in enforcing security policies. It verifies that the requested backup scope aligns with the user's permissions.

## Benefits

* **Self-Service Backups:** Empowers non-admin users to manage their backups without requiring elevated privileges.
* **Improved Security Posture:** Enforces strict access controls and prevents unauthorized backup operations.
Loading