|
| 1 | +# Configure Storage Backend |
| 2 | + |
| 3 | +Pulp uses [django-storages](https://django-storages.readthedocs.io) to support multiple storage backends. |
| 4 | +See the reference for the [`STORAGES` settings](site:pulpcore/docs/admin/reference/settings/#storages). |
| 5 | + |
| 6 | +## Modifying the settings |
| 7 | + |
| 8 | +The settings can be updated via the `settings.py` file or through environment variables |
| 9 | +and have support to dynaconf merge features (learn more on the [Settings Introduction](site:pulpcore/docs/admin/guides/configure-pulp/introduction/)). |
| 10 | + |
| 11 | +To learn where and how to modify the files and envvars, refer to the appropriate installation method documentation: |
| 12 | + |
| 13 | +* [Container (single-process) quickstart](site:pulp-oci-images/docs/admin/tutorials/quickstart/#single-container) |
| 14 | +* [Container (multi-process) quickstart](site:pulp-oci-images/docs/admin/tutorials/quickstart/#podman-or-docker-compose) |
| 15 | +* [Pulp Operator quickstart](site:pulp-operator/docs/admin/tutorials/quickstart-kubernetes/) |
| 16 | + |
| 17 | +## Local Filesystem (default) |
| 18 | + |
| 19 | +### Example |
| 20 | + |
| 21 | +In this example, the storage file permission and `MEDIA_ROOT` are overridden: |
| 22 | + |
| 23 | +```python |
| 24 | +STORAGES = { |
| 25 | + "default": { |
| 26 | + "BACKEND": "pulpcore.app.models.storage.FileSystem", |
| 27 | + "OPTIONS": { |
| 28 | + "file_permissions_mode": 0o600, |
| 29 | + "directory_permissions_mode": 0o600, |
| 30 | + }, |
| 31 | + }, |
| 32 | +} |
| 33 | +MEDIA_ROOT="/custom/media/root" # default: /var/lib/pulp/media |
| 34 | +``` |
| 35 | + |
| 36 | +Notes: |
| 37 | + |
| 38 | +* The [`MEDIA_ROOT`](site:pulpcore/docs/admin/reference/settings/#media_root) setting specifies where Pulp |
| 39 | +will save the files. |
| 40 | +* Pulp customizes Django's default class, `django.core.files.storage.FileSystemStorage`. |
| 41 | +* There are some other related global definitions provided by django: |
| 42 | + * `MEDIA_URL` |
| 43 | + * `FILE_UPLOAD_PERMISSIONS` |
| 44 | + * `FILE_UPLOAD_DIRECTORY_PERMISSIONS` |
| 45 | + |
| 46 | +Comprehensive options for Local Filesystem can be found in |
| 47 | +[Django docs](https://docs.djangoproject.com/en/4.2/ref/files/storage/#django.core.files.storage.FileSystemStorage). |
| 48 | + |
| 49 | +### Amazon S3 |
| 50 | + |
| 51 | +#### Setup |
| 52 | + |
| 53 | +Before you can configure Amazon S3 storage to use with Pulp, ensure that you complete the following steps |
| 54 | +(consult the official Amazon S3 docs for precise steps). |
| 55 | + |
| 56 | +1. Set up an AWS account. |
| 57 | +2. Create an S3 bucket for Pulp to use. |
| 58 | +3. In AWS Identity and Access Management (IAM), create a user that Pulp can use to access your S3 bucket. |
| 59 | +4. Save the access key id and secret access key. |
| 60 | + |
| 61 | +#### Example |
| 62 | + |
| 63 | +In this example, the storage uses a bucket called `pulp3` that is hosted in region `eu-central-1`: |
| 64 | + |
| 65 | +```python |
| 66 | +MEDIA_ROOT = "" |
| 67 | +STORAGES = { |
| 68 | + "default": { |
| 69 | + "BACKEND": "storages.backends.s3.S3Storage", |
| 70 | + "OPTIONS": { |
| 71 | + "access_key": 'AKIAIT2Z5TDYPX3ARJBA', |
| 72 | + "secret_key": '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', |
| 73 | + "bucket_name": 'pulp3', |
| 74 | + "signature_version": "s3v4", |
| 75 | + "addressing_style": "path", |
| 76 | + "region_name": "eu-central-1", |
| 77 | + }, |
| 78 | + }, |
| 79 | +} |
| 80 | +``` |
| 81 | + |
| 82 | +Notes: |
| 83 | + |
| 84 | +* `MEDIA_ROOT` must be set to an empty string. |
| 85 | +* You can omit `access_key` and `secret_key` if: |
| 86 | + 1. The system that hosts Pulp is running on AWS |
| 87 | + 2. And 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 |
| 88 | + |
| 89 | +Comprehensive options for Amazon S3 can be found in |
| 90 | +[`django-storages` docs](https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#configuration-settings). |
| 91 | + |
| 92 | +### Azure Blob storage |
| 93 | + |
| 94 | +#### Setup |
| 95 | + |
| 96 | +Before you can configure Azure Blob storage to use with Pulp, ensure that you complete the following steps |
| 97 | +(consult the official Azure documentation for precise steps). |
| 98 | + |
| 99 | +1. Set up an Azure account and create a storage account. |
| 100 | +2. In your storage account, create a container under `Blob` service. |
| 101 | +3. Obtain the access credentials so that you can later configure Pulp to access your Azure Blob storage. You can find the access credentials |
| 102 | + at the storage account level, at Access keys (these are automatically generated). |
| 103 | + |
| 104 | +#### Example |
| 105 | + |
| 106 | +In this example, the storage uses a container called `pulp3` with the `pulp-account` username. |
| 107 | + |
| 108 | +```python |
| 109 | +MEDIA_ROOT = "" |
| 110 | +STORAGES = { |
| 111 | + "default": { |
| 112 | + "BACKEND": "storages.backends.azure_storage.AzureStorage", |
| 113 | + "OPTIONS": { |
| 114 | + "account_name": 'pulp-account', |
| 115 | + "azure_container": 'pulp3', |
| 116 | + "account_key": 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==', |
| 117 | + "expiration_secs": 60, |
| 118 | + "overwrite_files": 'True', |
| 119 | + "location": 'pulp3' |
| 120 | + }, |
| 121 | + }, |
| 122 | +} |
| 123 | +``` |
| 124 | + |
| 125 | +Notes: |
| 126 | + |
| 127 | +* `MEDIA_ROOT` must be set to an empty string. |
| 128 | + |
| 129 | +Comprehensive options for Azure Blob can be found in |
| 130 | +[`django-storages` docs](https://django-storages.readthedocs.io/en/latest/backends/azure.html#configuration-settings). |
0 commit comments