|
| 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.md). |
| 5 | + |
| 6 | +## Local Filesystem |
| 7 | + |
| 8 | +This is the default storage backend Pulp will use if another is not specified. |
| 9 | + |
| 10 | +### Configure |
| 11 | + |
| 12 | +Configure the `BACKEND` and `OPTIONS` for the default django storage. |
| 13 | + |
| 14 | +Example configuration: |
| 15 | + |
| 16 | +```python |
| 17 | +STORAGES = { |
| 18 | + "default": { |
| 19 | + "BACKEND": "storages.backends.s3.S3Storage", |
| 20 | + "OPTIONS": { |
| 21 | + "file_permissions_mode": 0o600, |
| 22 | + "directory_permissions_mode": 0o600, |
| 23 | + }, |
| 24 | + }, |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +Compreheensive options for Local Filesystem can be found in |
| 29 | +[Django docs](https://docs.djangoproject.com/en/4.2/ref/files/storage/#django.core.files.storage.FileSystemStorage). |
| 30 | + |
| 31 | +### Further notes |
| 32 | + |
| 33 | +- Read about how Pulp's modifies `MEDIA_ROOT` defaults [here](). |
| 34 | +- Other relevant settings (module-scope settings) that are left as Django default's: |
| 35 | + * `MEDIA_URL` |
| 36 | + * `FILE_UPLOAD_PERMISSIONS` |
| 37 | + * `FILE_UPLOAD_DIRECTORY_PERMISSIONS` |
| 38 | + |
| 39 | +## Amazon S3 |
| 40 | + |
| 41 | +### Amazon Setup |
| 42 | + |
| 43 | +Before you can configure Amazon S3 storage to use with Pulp, ensure that you complete the following steps. |
| 44 | +To complete these steps, consult the official Amazon S3 documentation. |
| 45 | + |
| 46 | +1. Set up an AWS account. |
| 47 | +2. Create an S3 bucket for Pulp to use. |
| 48 | +3. In AWS Identity and Access Management (IAM), create a user that Pulp can use to access your S3 bucket. |
| 49 | +4. Save the access key id and secret access key. |
| 50 | + |
| 51 | +### Pulp Setup |
| 52 | + |
| 53 | +**TODO: learn how that works for oci-images and operator and provide links** |
| 54 | + |
| 55 | +To have Pulp use S3, complete the following steps. |
| 56 | +This assumes a simple install. For oci-images: |
| 57 | +* ... |
| 58 | +* ... |
| 59 | + |
| 60 | +#### Install Python Dependencies |
| 61 | + |
| 62 | +Ensure you have `django-storages` and `boto3` in your environement. |
| 63 | + |
| 64 | +For example: |
| 65 | + |
| 66 | +```bash |
| 67 | +pip install django-storages[boto3] |
| 68 | +``` |
| 69 | + |
| 70 | +#### Configure |
| 71 | + |
| 72 | +Configure the `BACKEND` and `OPTIONS` for the default django storage. |
| 73 | + |
| 74 | +Here is an example configuration that will use a bucket called `pulp3` that is hosted in |
| 75 | +region `eu-central-1`: |
| 76 | + |
| 77 | +```python |
| 78 | +MEDIA_ROOT = "" |
| 79 | +STORAGES = { |
| 80 | + "default": { |
| 81 | + "BACKEND": "storages.backends.s3.S3Storage", |
| 82 | + "OPTIONS": { |
| 83 | + "access_key": 'AKIAIT2Z5TDYPX3ARJBA', |
| 84 | + "secret_key": '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', |
| 85 | + "bucket_name": 'pulp3', |
| 86 | + "signature_version": "s3v4", |
| 87 | + "addressing_style": "path", |
| 88 | + "region_name": "eu-central-1", |
| 89 | + }, |
| 90 | + }, |
| 91 | +} |
| 92 | +``` |
| 93 | + |
| 94 | +Compreheensive options for Amazon S3 can be found in |
| 95 | +[`django-storages` docs](https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#configuration-settings). |
| 96 | + |
| 97 | +#### Further notes |
| 98 | + |
| 99 | +- You can omit `access_key` and `secret_key` if the following are true: |
| 100 | + * The system that hosts Pulp is running in AWS |
| 101 | + * 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 |
| 102 | + |
| 103 | +## Azure Blob storage |
| 104 | + |
| 105 | +### Azure Setup |
| 106 | + |
| 107 | +Before you can configure Azure Blob storage to use with Pulp, ensure that you complete the following steps. |
| 108 | +To complete these steps, consult the official Azure Blob documentation. |
| 109 | + |
| 110 | +1. Set up an Azure account and create a storage account. |
| 111 | +2. In your storage account, create a container under `Blob` service. |
| 112 | +3. Obtain the access credentials so that you can later configure Pulp to access your Azure Blob storage. You can find the access credentials |
| 113 | + at the storage account level, at Access keys (these are automatically generated). |
| 114 | + |
| 115 | +### Pulp Setup |
| 116 | + |
| 117 | +#### Install Python Dependencies |
| 118 | + |
| 119 | +Ensure you have `django-storages[azure]` in your environement: |
| 120 | + |
| 121 | +```bash |
| 122 | +pip install django-storages[azure] |
| 123 | +``` |
| 124 | + |
| 125 | +#### Configure |
| 126 | + |
| 127 | +```python |
| 128 | +MEDIA_ROOT = "" |
| 129 | +STORAGES = { |
| 130 | + "default": { |
| 131 | + "BACKEND": "storages.backends.azure_storage.AzureStorage", |
| 132 | + "OPTIONS": { |
| 133 | + "account_name": '<storage account name>', |
| 134 | + "azure_container": '<container name>', # As created within the blob service of your storage account |
| 135 | + "account_key": '<Key1 or Key2>', # From the access keys of your storage account |
| 136 | + "expiration_secs": 60, |
| 137 | + "overwrite_files": 'True', |
| 138 | + "location": '<path>' # The folder within the container where your pulp objects will be stored |
| 139 | + }, |
| 140 | + }, |
| 141 | +} |
| 142 | +``` |
| 143 | + |
| 144 | +Compreheensive options for Azure Blob can be found in |
| 145 | +[`django-storages` docs](https://django-storages.readthedocs.io/en/latest/backends/azure.html#configuration-settings). |
| 146 | + |
0 commit comments