Skip to content

Commit

Permalink
Update docs about STORAGES setting
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-psb committed Dec 12, 2024
1 parent 4b4e310 commit e3cbeda
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 10 deletions.
146 changes: 146 additions & 0 deletions docs/admin/guides/configure-pulp/configure-storages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Configure Storage Backend

Pulp uses [django-storages](https://django-storages.readthedocs.io) to support multiple storage backends.
See the reference for the [`STORAGES` settings](site:pulpcore/docs/admin/reference/settings.md).

## Local Filesystem

This is the default storage backend Pulp will use if another is not specified.

### Configure

Configure the `BACKEND` and `OPTIONS` for the default django storage.

Example configuration:

```python
STORAGES = {
"default": {
"BACKEND": "storages.backends.s3.S3Storage",
"OPTIONS": {
"file_permissions_mode": 0o600,
"directory_permissions_mode": 0o600,
},
},
}
```

Compreheensive options for Local Filesystem can be found in
[Django docs](https://docs.djangoproject.com/en/4.2/ref/files/storage/#django.core.files.storage.FileSystemStorage).

### Further notes

- Read about how Pulp's modifies `MEDIA_ROOT` defaults [here]().
- Other relevant settings (module-scope settings) that are left as Django default's:
* `MEDIA_URL`
* `FILE_UPLOAD_PERMISSIONS`
* `FILE_UPLOAD_DIRECTORY_PERMISSIONS`

## Amazon S3

### Amazon Setup

Before you can configure Amazon S3 storage to use with Pulp, ensure that you complete the following steps.
To complete these steps, consult the official Amazon S3 documentation.

1. Set up an AWS account.
2. Create an S3 bucket for Pulp to use.
3. In AWS Identity and Access Management (IAM), create a user that Pulp can use to access your S3 bucket.
4. Save the access key id and secret access key.

### Pulp Setup

**TODO: learn how that works for oci-images and operator and provide links**

To have Pulp use S3, complete the following steps.
This assumes a simple install. For oci-images:
* ...
* ...

#### Install Python Dependencies

Ensure you have `django-storages` and `boto3` in your environement.

For example:

```bash
pip install django-storages[boto3]
```

#### Configure

Configure the `BACKEND` and `OPTIONS` for the default django storage.

Here is an example configuration that will use a bucket called `pulp3` that is hosted in
region `eu-central-1`:

```python
MEDIA_ROOT = ""
STORAGES = {
"default": {
"BACKEND": "storages.backends.s3.S3Storage",
"OPTIONS": {
"access_key": 'AKIAIT2Z5TDYPX3ARJBA',
"secret_key": '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',
"bucket_name": 'pulp3',
"signature_version": "s3v4",
"addressing_style": "path",
"region_name": "eu-central-1",
},
},
}
```

Compreheensive options for Amazon S3 can be found in
[`django-storages` docs](https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#configuration-settings).

#### Further notes

- You can omit `access_key` and `secret_key` if the following are true:
* The system that hosts Pulp is running in AWS
* The [`instance_profile`](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html) provides access to the S3 bucket

## Azure Blob storage

### Azure Setup

Before you can configure Azure Blob storage to use with Pulp, ensure that you complete the following steps.
To complete these steps, consult the official Azure Blob documentation.

1. Set up an Azure account and create a storage account.
2. In your storage account, create a container under `Blob` service.
3. Obtain the access credentials so that you can later configure Pulp to access your Azure Blob storage. You can find the access credentials
at the storage account level, at Access keys (these are automatically generated).

### Pulp Setup

#### Install Python Dependencies

Ensure you have `django-storages[azure]` in your environement:

```bash
pip install django-storages[azure]
```

#### Configure

```python
MEDIA_ROOT = ""
STORAGES = {
"default": {
"BACKEND": "storages.backends.azure_storage.AzureStorage",
"OPTIONS": {
"account_name": '<storage account name>',
"azure_container": '<container name>', # As created within the blob service of your storage account
"account_key": '<Key1 or Key2>', # From the access keys of your storage account
"expiration_secs": 60,
"overwrite_files": 'True',
"location": '<path>' # The folder within the container where your pulp objects will be stored
},
},
}
```

Compreheensive options for Azure Blob can be found in
[`django-storages` docs](https://django-storages.readthedocs.io/en/latest/backends/azure.html#configuration-settings).

File renamed without changes.
61 changes: 51 additions & 10 deletions docs/admin/reference/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,58 @@ For a zero downtime key rotation you can follow the slightly more complex recipe
By default Pulp uses PostgreSQL on localhost. PostgreSQL is the only supported database. For
instructions on how to configure the database, refer to `database installation <database-install>`.

### DEFAULT_FILE_STORAGE
### DEFULT_FILE_STORAGE

!!! warning "Removed in `3.70`"
The `DEFAULT_FILE_STORAGE` setting was deprecated in
[django `4.2`](https://docs.djangoproject.com/en/4.2/ref/settings/#default-file-storage).
Use [`STORAGES`](#STORAGES) instead.

### STORAGES

!!! note "Added in `3.70`"
Replaces [`DEFAULT_DJANGO_STORAGES`](#DEFULT_FILE_STORAGE).

Pulp uses [django-storages](https://django-storages.readthedocs.io/en/latest/index.html) to support multiple storage backends.
If no backend is configured, Pulp will by default use the local filesystem (`pulpcore.app.models.storage.FileSystem`).

To use another backend storage, you'll need to:

- 1. Setup your storage and gather required credentials and specific configs.
- 1. Ensure the `django-storage[ s3 | google | azure ]` python package is installed. This depends on the installation method. On
- 1. Configure the default `BACKEND` storage class.
- 1. Configure available `OPTIONS` for that backend.

An Amazon S3 might look like this:

```python
STORAGES = {
"default": {
"BACKEND": "storages.backends.s3.S3Storage",
"OPTIONS": {
"access_key": 'AKIAIT2Z5TDYPX3ARJBA',
"secret_key": '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',
"bucket_name": 'pulp3',
"signature_version": "s3v4",
"addressing_style": "path",
"region_name": "eu-central-1",
},
},
}
```

Overview of the integration with Pulp:

By default, Pulp uses the local filesystem to store files. The default option which
uses the local filesystem is `pulpcore.app.models.storage.FileSystem`.
- **Supported**: We support (test) Amazon S3 and Azure. You can find more detailed information about it in
[Configure Storages](site:pulpcore/docs/admin/guides/configure-pulp/configure-storages.md) guide.
- **Untested**: Other backends provided by `django-storages` should work as well, but we provide no guarantee.
- **Known caveat**: Using SFTP Storage is not recommended in Pulp's current state, and doing so can lead to file corruption. This is because Pulp currently uses coroutines that seem to be incompatible with Django's SFTPStorage implementation.

For more information about different Pulp storage options, see the
`storage documentation `.

### REDIRECT_TO_OBJECT_STORAGE

When set to `True` access to artifacts is redirected to the corresponding Cloud storage
configured in `DEFAULT_FILE_STORAGE` using pre-authenticated URLs. When set to `False`
configured in `STORAGES['default']['BACKEND']` using pre-authenticated URLs. When set to `False`
artifacts are always served by the content app instead.

Defaults to `True`; ignored for local file storage.
Expand All @@ -91,9 +131,10 @@ Defaults to `True`; ignored for local file storage.

The location where Pulp will store files. By default this is `/var/lib/pulp/media`.

This only affects storage location when `DEFAULT_FILE_STORAGE` is set to
`pulpcore.app.models.storage.FileSystem`. See the `storage documentation ` for
more info.
This only affects storage location when `STORAGES['default']['BACKEND']` is set to
`pulpcore.app.models.storage.FileSystem`.

See the [storage documentation](site:pulpcore/docs/admin/guides/configure-pulp/configure-storages.md) for more info.

It should have permissions of:

Expand Down Expand Up @@ -188,7 +229,7 @@ It should have permissions of:
### CHUNKED_UPLOAD_DIR

A relative path inside the DEPLOY_ROOT directory used exclusively for uploaded chunks. The
uploaded chunks are stored in the default storage specified by `DEFAULT_FILE_STORAGE`. This
uploaded chunks are stored in the default storage specified by `STORAGES['default']['BACKEND']`. This
option allows users to customize the actual place where chunked uploads should be stored within
the declared storage. The default, `upload`, is sufficient for most use cases. A change to
this setting only applies to uploads created after the change.
Expand Down

0 comments on commit e3cbeda

Please sign in to comment.